diff options
author | Simon McVittie <smcv@collabora.com> | 2022-10-10 15:35:11 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-10-10 15:35:11 +0100 |
commit | 416744a26533b7beabb32b0af3042ea32f808d0d (patch) | |
tree | 49ba55e1c1effbc66d52dabfcdc3ad46845742ee /tests/test-libglnx-testing.c | |
parent | 8f2e676d9bf4d620e4b3e7b9b1cef382c1ae240f (diff) | |
download | libglnx-416744a26533b7beabb32b0af3042ea32f808d0d.tar.gz |
tests: Ensure saveptr is NULL before first call to strtok_r()
The standards-conformant behaviour is that the contents of saveptr
are ignored when the first argument is non-NULL, but the man page notes
that some older implementations required saveptr to be NULL in that
situation, and the gcc 4.8 provided by the Steam Runtime warns about this.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'tests/test-libglnx-testing.c')
-rw-r--r-- | tests/test-libglnx-testing.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/test-libglnx-testing.c b/tests/test-libglnx-testing.c index 279e0e1..8435113 100644 --- a/tests/test-libglnx-testing.c +++ b/tests/test-libglnx-testing.c @@ -171,7 +171,7 @@ test_failures (void) int wait_status = -1; const char *argv[] = { NULL, NULL, NULL, NULL }; char *line; - char *saveptr; + char *saveptr = NULL; argv[0] = exe; argv[1] = failures[i]; @@ -195,6 +195,8 @@ test_failures (void) line = strtok_r (NULL, "\n", &saveptr)) g_test_message ("stdout: %s", line); + saveptr = NULL; + for (line = strtok_r (err, "\n", &saveptr); line != NULL; line = strtok_r (NULL, "\n", &saveptr)) @@ -241,7 +243,7 @@ test_skips (void) int wait_status = -1; const char *argv[] = { NULL, NULL, NULL, NULL }; char *line; - char *saveptr; + char *saveptr = NULL; argv[0] = exe; argv[1] = skips[i]; @@ -265,6 +267,8 @@ test_skips (void) line = strtok_r (NULL, "\n", &saveptr)) g_test_message ("stdout: %s", line); + saveptr = NULL; + for (line = strtok_r (err, "\n", &saveptr); line != NULL; line = strtok_r (NULL, "\n", &saveptr)) @@ -311,7 +315,7 @@ test_successes (void) int wait_status = -1; const char *argv[] = { NULL, NULL, NULL, NULL }; char *line; - char *saveptr; + char *saveptr = NULL; argv[0] = exe; argv[1] = successes[i]; @@ -335,6 +339,8 @@ test_successes (void) line = strtok_r (NULL, "\n", &saveptr)) g_test_message ("stdout: %s", line); + saveptr = NULL; + for (line = strtok_r (err, "\n", &saveptr); line != NULL; line = strtok_r (NULL, "\n", &saveptr)) |