bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shadowing warning from test-printf-posix.h


From: Jim Meyering
Subject: shadowing warning from test-printf-posix.h
Date: Wed, 02 Apr 2008 22:11:34 +0200

Hi Bruno,

I always build coreutils with -Wshadow, so often see these warnings:

  test-printf-posix.h: In function 'test_function':
  test-printf-posix.h:20: warning: declaration of 'my_printf' shadows a global 
declaration
  test-vfprintf-posix.c:43: warning: shadowed declaration is here

Any reason not to rename one of them to avoid it?
Tell me which you prefer and I'll be happy to do it.

With only two uses in the .c file, I'd change it there, e.g., to test_printf.

I went ahead and wrote the patch for that.
While I was at it, here are changes to fix all other gnulib-test
warnings that afflict coreutils.  With the following, "make check"
finally generates no compile-time warnings.

Ok to apply?
(with ChangeLog entries like the commit logs, of course)


>From 17273f5c6471f10ba29cee8c07a1022877588146 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 2 Apr 2008 22:04:16 +0200
Subject: [PATCH] Avoid -Wshadow warnings.

* tests/test-vfprintf-posix.c (test_fprintf): Rename to avoid
being shadowed by definition of included my_fprintf.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/test-vfprintf-posix.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/test-vfprintf-posix.c b/tests/test-vfprintf-posix.c
index 2af148d..b2ac213 100644
--- a/tests/test-vfprintf-posix.c
+++ b/tests/test-vfprintf-posix.c
@@ -1,5 +1,5 @@
 /* Test of POSIX compatible vfprintf() function.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
   while (0)

 static int
-my_fprintf (FILE *fp, const char *format, ...)
+test_fprintf (FILE *fp, const char *format, ...)
 {
   va_list args;
   int ret;
@@ -55,6 +55,6 @@ my_fprintf (FILE *fp, const char *format, ...)
 int
 main (int argc, char *argv[])
 {
-  test_function (my_fprintf);
+  test_function (test_fprintf);
   return 0;
 }
--
1.5.5.rc2.26.g7bba


>From 44975b6fb51b5cf25ec8b98f15df77ab4987b523 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 2 Apr 2008 22:05:24 +0200
Subject: [PATCH] Avoid -Wshadow warnings.

* tests/test-frexpl.c (exp): #define to 'exponent' to avoid
shadowing the function.
* tests/test-frexp.c: Likewise.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/test-frexp.c  |    3 +++
 tests/test-frexpl.c |    5 ++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/tests/test-frexp.c b/tests/test-frexp.c
index 9e92667..0bdf1cd 100644
--- a/tests/test-frexp.c
+++ b/tests/test-frexp.c
@@ -27,6 +27,9 @@
 #include "isnand.h"
 #include "nan.h"

+/* Avoid warnings from -Wshadow.  */
+#define exp exponent
+
 #define ASSERT(expr) \
   do                                                                        \
     {                                                                       \
diff --git a/tests/test-frexpl.c b/tests/test-frexpl.c
index f6e5af8..1a0514f 100644
--- a/tests/test-frexpl.c
+++ b/tests/test-frexpl.c
@@ -1,5 +1,5 @@
 /* Test of splitting a 'long double' into fraction and mantissa.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -27,6 +27,9 @@
 #include "fpucw.h"
 #include "isnanl-nolibm.h"

+/* Avoid warnings from -Wshadow.  */
+#define exp exponent
+
 #define ASSERT(expr) \
   do                                                                        \
     {                                                                       \
--
1.5.5.rc2.26.g7bba


>From f1a6b3bd4a8b534c2e4eeb04f7ae06aff7ea7765 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 2 Apr 2008 22:08:00 +0200
Subject: [PATCH] Avoid "statement with no effect" warning.

* tests/test-wctype.c (main): Don't use is* function return values.

Signed-off-by: Jim Meyering <address@hidden>
---
 tests/test-wctype.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/tests/test-wctype.c b/tests/test-wctype.c
index 517b478..5d1296e 100644
--- a/tests/test-wctype.c
+++ b/tests/test-wctype.c
@@ -23,21 +23,22 @@
 int
 main ()
 {
+  int i = 0;
   /* Check that the isw* functions exist as functions or as macros.  */
-  iswalnum (0);
-  iswalpha (0);
+  i += !!iswalnum (0);
+  i += !!iswalpha (0);
 #if 0 /* not portable: missing on mingw */
-  iswblank (0);
+  i += !!iswblank (0);
 #endif
-  iswcntrl (0);
-  iswdigit (0);
-  iswgraph (0);
-  iswlower (0);
-  iswprint (0);
-  iswpunct (0);
-  iswspace (0);
-  iswupper (0);
-  iswxdigit (0);
+  i += !!iswcntrl (0);
+  i += !!iswdigit (0);
+  i += !!iswgraph (0);
+  i += !!iswlower (0);
+  i += !!iswprint (0);
+  i += !!iswpunct (0);
+  i += !!iswspace (0);
+  i += !!iswupper (0);
+  i += !!iswxdigit (0);

   return 0;
 }
--
1.5.5.rc2.26.g7bba




reply via email to

[Prev in Thread] Current Thread [Next in Thread]