coreutils
[Top][All Lists]
Advanced

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

-Wredundant-decls -Wjump-misses-init


From: Jim Meyering
Subject: -Wredundant-decls -Wjump-misses-init
Date: Sun, 04 Dec 2011 10:37:10 +0100

I've been using gcc-4.7.0 and experimenting with an even
longer list of warnings.  Here's some fallout:

>From bea7b10489afcc845db00b03da6ccea71de6cb1d Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 3 Dec 2011 16:42:19 +0100
Subject: [PATCH 1/2] maint: remove redundant usage declarations
 (-Wredundant-decls)

* src/csplit.c (usage): Remove declaration.
* src/ls.c (usage): Likewise.
* src/pr.c (usage): Likewise.
---
 src/csplit.c |    1 -
 src/ls.c     |    1 -
 src/pr.c     |    1 -
 3 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/src/csplit.c b/src/csplit.c
index 5d84c45..49ef3db 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -111,7 +111,6 @@ static void close_output_file (void);
 static void create_output_file (void);
 static void delete_all_files (bool);
 static void save_line_to_file (const struct cstring *line);
-void usage (int status);

 /* Start of buffer list. */
 static struct buffer_record *head = NULL;
diff --git a/src/ls.c b/src/ls.c
index 96f7c98..8be9b6a 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -282,7 +282,6 @@ static void queue_directory (char const *name, char const 
*realname,
                              bool command_line_arg);
 static void sort_files (void);
 static void parse_ls_color (void);
-void usage (int status);

 /* Initial size of hash table.
    Most hierarchies are likely to be shallower than this.  */
diff --git a/src/pr.c b/src/pr.c
index d1adc55..395e1e3 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -426,7 +426,6 @@ static void pad_across_to (int position);
 static void add_line_number (COLUMN *p);
 static void getoptarg (char *arg, char switch_char, char *character,
                        int *number);
-void usage (int status);
 static void print_files (int number_of_files, char **av);
 static void init_parameters (int number_of_files);
 static void init_header (char const *filename, int desc);
--
1.7.8.rc4


>From 63098ee58235f5a1877220e8c073f6f23b09264f Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 3 Dec 2011 17:49:57 +0100
Subject: [PATCH 2/2] od,test: address warnings from gcc's -Wjump-misses-init

* src/test.c (unary_operator): gcc reported that initializations
in two case statements were skipped.  Enclose in braces.
* src/od.c (decode_one_format): Likewise.
---
 src/od.c   |   46 ++++++++++++++++++++++++----------------------
 src/test.c |   32 ++++++++++++++++++--------------
 2 files changed, 42 insertions(+), 36 deletions(-)

diff --git a/src/od.c b/src/od.c
index 2f3593e..6a6eb80 100644
--- a/src/od.c
+++ b/src/od.c
@@ -771,32 +771,34 @@ this system doesn't provide a %lu-byte floating point 
type"),
         }
       size_spec = fp_type_size[size];

-      struct lconv const *locale = localeconv ();
-      size_t decimal_point_len =
-        (locale->decimal_point[0] ? strlen (locale->decimal_point) : 1);
-
-      switch (size_spec)
-        {
-        case FLOAT_SINGLE:
-          print_function = print_float;
-          field_width = FLT_STRLEN_BOUND_L (decimal_point_len);
-          break;
+      {
+        struct lconv const *locale = localeconv ();
+        size_t decimal_point_len =
+          (locale->decimal_point[0] ? strlen (locale->decimal_point) : 1);
+
+        switch (size_spec)
+          {
+          case FLOAT_SINGLE:
+            print_function = print_float;
+            field_width = FLT_STRLEN_BOUND_L (decimal_point_len);
+            break;

-        case FLOAT_DOUBLE:
-          print_function = print_double;
-          field_width = DBL_STRLEN_BOUND_L (decimal_point_len);
-          break;
+          case FLOAT_DOUBLE:
+            print_function = print_double;
+            field_width = DBL_STRLEN_BOUND_L (decimal_point_len);
+            break;

-        case FLOAT_LONG_DOUBLE:
-          print_function = print_long_double;
-          field_width = LDBL_STRLEN_BOUND_L (decimal_point_len);
-          break;
+          case FLOAT_LONG_DOUBLE:
+            print_function = print_long_double;
+            field_width = LDBL_STRLEN_BOUND_L (decimal_point_len);
+            break;

-        default:
-          abort ();
-        }
+          default:
+            abort ();
+          }

-      break;
+        break;
+      }

     case 'a':
       ++s;
diff --git a/src/test.c b/src/test.c
index 1b06ca8..a5df7c8 100644
--- a/src/test.c
+++ b/src/test.c
@@ -413,22 +413,26 @@ unary_operator (void)
       return euidaccess (argv[pos - 1], X_OK) == 0;

     case 'O':                  /* File is owned by you? */
-      unary_advance ();
-      if (stat (argv[pos - 1], &stat_buf) != 0)
-        return false;
-      errno = 0;
-      uid_t euid = geteuid ();
-      uid_t NO_UID = -1;
-      return ! (euid == NO_UID && errno) && euid == stat_buf.st_uid;
+      {
+        unary_advance ();
+        if (stat (argv[pos - 1], &stat_buf) != 0)
+          return false;
+        errno = 0;
+        uid_t euid = geteuid ();
+        uid_t NO_UID = -1;
+        return ! (euid == NO_UID && errno) && euid == stat_buf.st_uid;
+      }

     case 'G':                  /* File is owned by your group? */
-      unary_advance ();
-      if (stat (argv[pos - 1], &stat_buf) != 0)
-        return false;
-      errno = 0;
-      gid_t egid = getegid ();
-      gid_t NO_GID = -1;
-      return ! (egid == NO_GID && errno) && egid == stat_buf.st_gid;
+      {
+        unary_advance ();
+        if (stat (argv[pos - 1], &stat_buf) != 0)
+          return false;
+        errno = 0;
+        gid_t egid = getegid ();
+        gid_t NO_GID = -1;
+        return ! (egid == NO_GID && errno) && egid == stat_buf.st_gid;
+      }

     case 'f':                  /* File is a file? */
       unary_advance ();
--
1.7.8.rc4



reply via email to

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