bug-gnulib
[Top][All Lists]
Advanced

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

Re: shadowing warning from test-printf-posix.h


From: Bruno Haible
Subject: Re: shadowing warning from test-printf-posix.h
Date: Thu, 3 Apr 2008 00:07:06 +0200
User-agent: KMail/1.5.4

Jim Meyering wrote:
> I always build coreutils with -Wshadow

It's a pity that this warning also generates noise each time you have a
variable called 'index'.

> 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?

I find this naming suitable when single-stepping through it in the debugger.
Therefore I prefer this patch:


2008-04-02  Bruno Haible  <address@hidden>

        Avoid some warnings from "gcc -Wshadow".
        * tests/tests-vfprintf-posix.c (my_fprintf): Move after test_function.
        * tests/tests-vprintf-posix.c (my_printf): Move after test_function.
        * tests/tests-vsnprintf-posix.c (my_snprintf): Move after test_function.
        * tests/tests-vsprintf-posix.c (my_sprintf): Move after test_function.
        Reported by Jim Meyering.

*** tests/test-vfprintf-posix.c.orig    2008-04-03 00:03:25.000000000 +0200
--- tests/test-vfprintf-posix.c 2008-04-02 23:59:22.000000000 +0200
***************
*** 1,5 ****
  /* Test of POSIX compatible vfprintf() function.
!    Copyright (C) 2007 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
--- 1,5 ----
  /* Test of POSIX compatible vfprintf() function.
!    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
***************
*** 38,43 ****
--- 38,45 ----
      }                                                                      \
    while (0)
  
+ #include "test-fprintf-posix.h"
+ 
  static int
  my_fprintf (FILE *fp, const char *format, ...)
  {
***************
*** 50,57 ****
    return ret;
  }
  
- #include "test-fprintf-posix.h"
- 
  int
  main (int argc, char *argv[])
  {
--- 52,57 ----
*** tests/test-vprintf-posix.c.orig     2008-04-03 00:03:25.000000000 +0200
--- tests/test-vprintf-posix.c  2008-04-02 23:59:23.000000000 +0200
***************
*** 1,5 ****
  /* Test of POSIX compatible vfprintf() function.
!    Copyright (C) 2007 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
--- 1,5 ----
  /* Test of POSIX compatible vfprintf() function.
!    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
***************
*** 38,43 ****
--- 38,45 ----
      }                                                                      \
    while (0)
  
+ #include "test-printf-posix.h"
+ 
  static int
  my_printf (const char *format, ...)
  {
***************
*** 50,57 ****
    return ret;
  }
  
- #include "test-printf-posix.h"
- 
  int
  main (int argc, char *argv[])
  {
--- 52,57 ----
*** tests/test-vsnprintf-posix.c.orig   2008-04-03 00:03:25.000000000 +0200
--- tests/test-vsnprintf-posix.c        2008-04-02 23:59:23.000000000 +0200
***************
*** 1,5 ****
  /* Test of POSIX compatible vsnprintf() function.
!    Copyright (C) 2007 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
--- 1,5 ----
  /* Test of POSIX compatible vsnprintf() function.
!    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
***************
*** 40,45 ****
--- 40,47 ----
      }                                                                      \
    while (0)
  
+ #include "test-snprintf-posix.h"
+ 
  static int
  my_snprintf (char *str, size_t size, const char *format, ...)
  {
***************
*** 52,59 ****
    return ret;
  }
  
- #include "test-snprintf-posix.h"
- 
  int
  main (int argc, char *argv[])
  {
--- 54,59 ----
*** tests/test-vsprintf-posix.c.orig    2008-04-03 00:03:25.000000000 +0200
--- tests/test-vsprintf-posix.c 2008-04-02 23:59:23.000000000 +0200
***************
*** 1,5 ****
  /* Test of POSIX compatible vsprintf() function.
!    Copyright (C) 2007 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
--- 1,5 ----
  /* Test of POSIX compatible vsprintf() function.
!    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
***************
*** 40,45 ****
--- 40,47 ----
      }                                                                      \
    while (0)
  
+ #include "test-sprintf-posix.h"
+ 
  static int
  my_sprintf (char *str, const char *format, ...)
  {
***************
*** 52,59 ****
    return ret;
  }
  
- #include "test-sprintf-posix.h"
- 
  int
  main (int argc, char *argv[])
  {
--- 54,59 ----





reply via email to

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