mirror of
https://github.com/flatpak/flatpak.git
synced 2026-03-27 19:33:06 -04:00
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>
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user