From 5f680f24104d2dfd9ea0885a608a9a9ab8d66192 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 16 Oct 2016 16:59:45 +0200 Subject: [PATCH] Fix some "gcc -Wall" warnings. * tests/test-ffsl.c (main): Use variable x, not i. * tests/test-posix_spawn3.c (parent_main): Consider the return value of freopen. * tests/test-sethostname1.c (main): Explicitly ignore the return value of sethostname. --- ChangeLog | 9 +++++++++ tests/test-ffsl.c | 4 ++-- tests/test-posix_spawn3.c | 6 +++++- tests/test-sethostname1.c | 7 +++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index bff00494d2..edc5962952 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2016-10-16 Bruno Haible + + Fix some "gcc -Wall" warnings. + * tests/test-ffsl.c (main): Use variable x, not i. + * tests/test-posix_spawn3.c (parent_main): Consider the return value of + freopen. + * tests/test-sethostname1.c (main): Explicitly ignore the return value + of sethostname. + 2016-10-16 Bruno Haible gnulib-tool: Make --create-testdir on all modules work again. diff --git a/tests/test-ffsl.c b/tests/test-ffsl.c index e903509096..117bc4ab8f 100644 --- a/tests/test-ffsl.c +++ b/tests/test-ffsl.c @@ -44,8 +44,8 @@ main (int argc, char *argv[]) long int x; int i; - for (i = -128; i <= 128; i++) - ASSERT (ffsl (i) == naive (i)); + for (x = -128; x <= 128; x++) + ASSERT (ffsl (x) == naive (x)); for (i = 0; i < NBITS; i++) { ASSERT (ffsl (1UL << i) == naive (1UL << i)); diff --git a/tests/test-posix_spawn3.c b/tests/test-posix_spawn3.c index 90745fdc12..f2a699c8bd 100644 --- a/tests/test-posix_spawn3.c +++ b/tests/test-posix_spawn3.c @@ -75,7 +75,11 @@ parent_main (void) } /* Avoid reading from our stdin, as it could block. */ - freopen ("/dev/null", "rb", stdin); + if (freopen ("/dev/null", "rb", stdin) == NULL) + { + perror ("cannot redirect stdin"); + return 1; + } /* Test whether posix_spawn_file_actions_addopen with this file name actually works, but spawning a child that reads from this file. */ diff --git a/tests/test-sethostname1.c b/tests/test-sethostname1.c index 5ed6a8360b..08441f3281 100644 --- a/tests/test-sethostname1.c +++ b/tests/test-sethostname1.c @@ -30,8 +30,11 @@ main () /* Some code that has a link-time dependency to the sethostname() function and that is likely not optimized away by compilers. */ if (do_dangerous_things) - /* Never executed. */ - sethostname ("oprah", 5); + { + /* Never executed. */ + int ret = sethostname ("oprah", 5); + (void) ret; + } return 0; } -- 2.39.5