Skip to content

Commit 46862df

Browse files
committed
tests: adjust type for new compiler wanring
Preserve the const-ness of the string constants as identified by the newer compiler.
1 parent a7a0a10 commit 46862df

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

tests/dispatch_context_for_key.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#if DISPATCH_API_VERSION >= 20100825 && DISPATCH_API_VERSION != 20101110
3333

34-
static char *ctxts[] = {"ctxt for app", "ctxt for key 1",
34+
static const char *ctxts[] = {"ctxt for app", "ctxt for key 1",
3535
"ctxt for key 2", "ctxt for key 1 bis", "ctxt for key 4"};
3636
volatile long ctxts_destroyed;
3737
static dispatch_group_t g;
@@ -58,20 +58,20 @@ test_context_for_key(void)
5858
dispatch_queue_t ttq = dispatch_get_global_queue(0, 0);
5959
dispatch_group_enter(g);
6060
#if DISPATCH_API_VERSION >= 20101011
61-
dispatch_queue_set_specific(tq, &ctxts[4], ctxts[4], destructor);
61+
dispatch_queue_set_specific(tq, &ctxts[4], (char *)ctxts[4], destructor);
6262
#else
6363
dispatch_set_context_for_key(tq, &ctxts[4], ctxts[4], ttq, destructor);
6464
#endif
6565
dispatch_set_target_queue(tq, ttq);
6666
dispatch_group_enter(g);
67-
dispatch_set_context(q, ctxts[0]);
67+
dispatch_set_context(q, (char *)ctxts[0]);
6868
dispatch_set_target_queue(q, tq);
6969
dispatch_set_finalizer_f(q, destructor);
7070

7171
dispatch_async(q, ^{
7272
dispatch_group_enter(g);
7373
#if DISPATCH_API_VERSION >= 20101011
74-
dispatch_queue_set_specific(q, &ctxts[1], ctxts[1], destructor);
74+
dispatch_queue_set_specific(q, &ctxts[1], (char *)ctxts[1], destructor);
7575
#else
7676
dispatch_set_context_for_key(q, &ctxts[1], ctxts[1], ttq, destructor);
7777
#endif
@@ -80,7 +80,7 @@ test_context_for_key(void)
8080
dispatch_async(dispatch_get_global_queue(0, 0), ^{
8181
dispatch_group_enter(g);
8282
#if DISPATCH_API_VERSION >= 20101011
83-
dispatch_queue_set_specific(q, &ctxts[2], ctxts[2], destructor);
83+
dispatch_queue_set_specific(q, &ctxts[2], (char *)ctxts[2], destructor);
8484
#else
8585
dispatch_set_context_for_key(q, &ctxts[2], ctxts[2], ttq, destructor);
8686
#endif
@@ -114,7 +114,7 @@ test_context_for_key(void)
114114
dispatch_group_enter(g);
115115
void *ctxt;
116116
#if DISPATCH_API_VERSION >= 20101011
117-
dispatch_queue_set_specific(q, &ctxts[1], ctxts[3], destructor);
117+
dispatch_queue_set_specific(q, &ctxts[1], (char *)ctxts[3], destructor);
118118
ctxt = dispatch_queue_get_specific(q, &ctxts[1]);
119119
#else
120120
dispatch_set_context_for_key(q, &ctxts[1], ctxts[3], ttq, destructor);

tests/dispatch_data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ test_concat(void)
4343
{
4444
dispatch_group_enter(g);
4545
dispatch_async(dispatch_get_main_queue(), ^{
46-
char* buffer1 = "This is buffer1 ";
46+
const char* buffer1 = "This is buffer1 ";
4747
size_t size1 = 17;
48-
char* buffer2 = "This is buffer2 ";
48+
const char* buffer2 = "This is buffer2 ";
4949
size_t size2 = 17;
5050
__block bool buffer2_destroyed = false;
5151

tests/dispatch_io_muxed.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,21 @@ test_file_muxed(void)
4747
printf("\nFile Muxed\n");
4848

4949
#if defined(_WIN32)
50-
char *temp_dir = getenv("TMP");
50+
const char *temp_dir = getenv("TMP");
5151
if (!temp_dir) {
5252
temp_dir = getenv("TEMP");
5353
}
5454
if (!temp_dir) {
5555
test_ptr_notnull("temporary directory", temp_dir);
5656
test_stop();
5757
}
58-
char *path_separator = "\\";
58+
const char *path_separator = "\\";
5959
#else
60-
char *temp_dir = getenv("TMPDIR");
60+
const char *temp_dir = getenv("TMPDIR");
6161
if (!temp_dir) {
6262
temp_dir = "/tmp";
6363
}
64-
char *path_separator = "/";
64+
const char *path_separator = "/";
6565
#endif
6666
char *path = NULL;
6767
asprintf(&path, "%s%sdispatchtest_io.XXXXXX", temp_dir, path_separator);

0 commit comments

Comments
 (0)