[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] test-getcwd.c: avoid new set-but-not-used warning
From: |
Jim Meyering |
Subject: |
[PATCH] test-getcwd.c: avoid new set-but-not-used warning |
Date: |
Fri, 29 Apr 2011 10:20:36 +0200 |
Eric Blake wrote:
> * gnulib: Update to latest.
> * bootstrap.conf (gnulib_modules): Add xgetgroups.
> ---
>
> Okay to push?
>
> * gnulib a81348d...d6d01fd (70):
Thanks, but not yet.
That would pull in changes that induce two build failures
when configuring coreutils with --enable-gcc-warnings:
test-hash.c: In function 'main':
test-hash.c:213:23: error: declaration of 'dup' shadows a global
declaration\
[-Werror=shadow]
test-getcwd.c: In function 'test_abort_bug':
test-getcwd.c:49:7: error: variable 'fail' set but not used\
[-Werror=unused-but-set-variable]
I've already pushed the trivial fix for test-hash.c:
http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=20abe9a92c71d7cc
I'm about to push this, to fix the second one:
>From c1bb7ba6ba9e685da05f48da5368d9342ba272c1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 29 Apr 2011 09:53:25 +0200
Subject: [PATCH] test-getcwd.c: avoid new set-but-not-used warning
* tests/test-getcwd.c (test_abort_bug): Exit nonzero for any problem,
not just the glibc/abort one that getcwd-abort-bug.m4 detects.
This also adds an additional test for an unlikely chdir("..") failure.
* m4/getcwd-abort-bug.m4: Update this now-duplicated code to match,
and adjust the code that sets gl_cv_func_getcwd_abort_bug accordingly.
---
ChangeLog | 6 ++++++
m4/getcwd-abort-bug.m4 | 17 ++++++++++++-----
tests/test-getcwd.c | 9 ++++++---
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3cc245e..dc01efd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2011-04-29 Jim Meyering <address@hidden>
+ test-getcwd.c: avoid new set-but-not-used warning
+ * tests/test-getcwd.c (test_abort_bug): Exit nonzero for any problem,
+ not just the glibc/abort one that getcwd-abort-bug.m4 detects.
+ * m4/getcwd-abort-bug.m4: Update this now-duplicated code to match,
+ and adjust the code that sets gl_cv_func_getcwd_abort_bug accordingly.
+
test-hash.c: avoid a new shadowing warning
* tests/test-hash.c (main): Don't shadow "dup".
diff --git a/m4/getcwd-abort-bug.m4 b/m4/getcwd-abort-bug.m4
index 0b59a6b..fd6820d 100644
--- a/m4/getcwd-abort-bug.m4
+++ b/m4/getcwd-abort-bug.m4
@@ -1,4 +1,4 @@
-# serial 3
+# serial 4
# Determine whether getcwd aborts when the length of the working directory
# name is unusually large. Any length between 4k and 16k trigger the bug
# when using glibc-2.4.90-9 or older.
@@ -65,7 +65,7 @@ main ()
cwd = getcwd (NULL, 0);
if (cwd == NULL)
- return 0;
+ return 2;
initial_cwd_len = strlen (cwd);
free (cwd);
@@ -92,15 +92,22 @@ main ()
while (0 < d--)
{
if (chdir ("..") < 0)
- break;
+ {
+ fail = 5;
+ break;
+ }
rmdir (dir_name);
}
- return 0;
+ return fail;
}
]])],
[gl_cv_func_getcwd_abort_bug=no],
- [gl_cv_func_getcwd_abort_bug=yes],
+ dnl A "regular" nonzero return does not indicate this bug.
+ dnl An abort will provoke an exit code of something like 134 (128 + 6).
+ [test $? -gt 128 \
+ && gl_cv_func_getcwd_abort_bug=yes \
+ || gl_cv_func_getcwd_abort_bug=no],
[gl_cv_func_getcwd_abort_bug=yes])
])
AS_IF([test $gl_cv_func_getcwd_abort_bug = yes], [$1], [$2])
diff --git a/tests/test-getcwd.c b/tests/test-getcwd.c
index 0e0f90f..14a526f 100644
--- a/tests/test-getcwd.c
+++ b/tests/test-getcwd.c
@@ -55,7 +55,7 @@ test_abort_bug (void)
cwd = getcwd (NULL, 0);
if (cwd == NULL)
- return 0;
+ return 2;
initial_cwd_len = strlen (cwd);
free (cwd);
@@ -82,11 +82,14 @@ test_abort_bug (void)
while (0 < d--)
{
if (chdir ("..") < 0)
- break;
+ {
+ fail = 5;
+ break;
+ }
rmdir (dir_name);
}
- return 0;
+ return fail;
}
/* The length of this name must be 8. */
--
1.7.5.421.g9d34e
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] test-getcwd.c: avoid new set-but-not-used warning,
Jim Meyering <=