]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Port to gcc -Wimplicit-fallthrough=5
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 18 Nov 2017 16:39:33 +0000 (08:39 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 18 Nov 2017 16:42:23 +0000 (08:42 -0800)
* src/common.h (FALLTHROUGH): New macro, for use with gcc
-Wimplicit-fallthrough=5, which is now the default when used with
Gnulib after commit 2017-05-16T16:23:52!eggert@cs.ucla.edu
and with --enable-gcc-warnings

src/buffer.c
src/common.h
src/compare.c
src/delete.c
src/extract.c
src/list.c
src/names.c
src/sparse.c
src/tar.c
src/update.c

index 6f96c2fa6aa69943cb5b63c1e140eeb1e341ea0b..51f299fddebb9cfd543e402424114ce9df3345fd 100644 (file)
@@ -106,7 +106,7 @@ bool write_archive_to_stdout;
 /* When creating a multi-volume archive, each 'bufmap' represents
    a member stored (perhaps partly) in the current record buffer.
    Bufmaps are form a single-linked list in chronological order.
-   
+
    After flushing the record to the output media, all bufmaps that
    represent fully written members are removed from the list, the
    nblocks and sizeleft values in the bufmap_head and start values
@@ -1004,7 +1004,7 @@ void
 flush_archive (void)
 {
   size_t buffer_level;
-  
+
   if (access_mode == ACCESS_READ && time_to_start_writing)
     {
       access_mode = ACCESS_WRITE;
@@ -1296,8 +1296,7 @@ change_tape_menu (FILE *read_file)
               sys_spawn_shell ();
               break;
             }
-          /* FALL THROUGH */
-
+         FALLTHROUGH;
         default:
           fprintf (stderr, _("Invalid input. Type ? for help.\n"));
         }
@@ -1506,8 +1505,7 @@ try_new_volume (void)
       header = find_next_block ();
       if (header->header.typeflag != GNUTYPE_MULTIVOL)
         break;
-      /* FALL THROUGH */
-
+      FALLTHROUGH;
     case GNUTYPE_MULTIVOL:
       if (!read_header0 (&dummy))
         return false;
@@ -1532,7 +1530,7 @@ try_new_volume (void)
                 quote (bufmap_head->file_name)));
          return false;
        }
-      
+
       if (strcmp (continued_file_name, bufmap_head->file_name))
         {
           if ((archive_format == GNU_FORMAT || archive_format == OLDGNU_FORMAT)
index 964f0b648f24ba2a119ce3757407d6097e4ad28a..bbe167efd4e59e92452a7e570c4a35fa842e66cd 100644 (file)
 # define GLOBAL extern
 #endif
 
+#if 7 <= __GNUC__
+# define FALLTHROUGH __attribute__ ((__fallthrough__))
+#else
+# define FALLTHROUGH ((void) 0)
+#endif
+
 #define TAREXIT_SUCCESS PAXEXIT_SUCCESS
 #define TAREXIT_DIFFERS PAXEXIT_DIFFERS
 #define TAREXIT_FAILURE PAXEXIT_FAILURE
index 8d609e89a79a7aec51a68ea7b9b3d54c87c8937e..fee137297ed70f901c85a23da1861ef24780538f 100644 (file)
@@ -480,8 +480,7 @@ diff_archive (void)
       ERROR ((0, 0, _("%s: Unknown file type '%c', diffed as normal file"),
              quotearg_colon (current_stat_info.file_name),
              current_header->header.typeflag));
-      /* Fall through.  */
-
+      FALLTHROUGH;
     case AREGTYPE:
     case REGTYPE:
     case GNUTYPE_SPARSE:
index 0b3c27f2fa883484e7d88358acbe003a3fb23178..9044ba2cc805554166d4139ff76655d2617da61c 100644 (file)
@@ -187,8 +187,7 @@ delete_archive_members (void)
              skip_member ();
              break;
            }
-
-         /* Fall through.  */
+         FALLTHROUGH;
        case HEADER_SUCCESS_EXTENDED:
          logical_status = status;
          break;
@@ -199,7 +198,7 @@ delete_archive_members (void)
              set_next_block_after (current_header);
              break;
            }
-         /* Fall through.  */
+         FALLTHROUGH;
        case HEADER_END_OF_FILE:
          logical_status = HEADER_END_OF_FILE;
          break;
@@ -210,14 +209,12 @@ delete_archive_members (void)
            {
            case HEADER_STILL_UNREAD:
              WARN ((0, 0, _("This does not look like a tar archive")));
-             /* Fall through.  */
-
+             FALLTHROUGH;
            case HEADER_SUCCESS:
            case HEADER_SUCCESS_EXTENDED:
            case HEADER_ZERO_BLOCK:
              ERROR ((0, 0, _("Skipping to next header")));
-             /* Fall through.  */
-
+             FALLTHROUGH;
            case HEADER_FAILURE:
              break;
 
index 36919daceac6d91e443787f15b671617c920adee..395db557328ad34952924a48052fe629935ac46f 100644 (file)
@@ -394,7 +394,7 @@ set_stat (char const *file_name,
 }
 
 /* Find the direct ancestor of FILE_NAME in the delayed_set_stat list.
- */   
+ */
 static struct delayed_set_stat *
 find_direct_ancestor (char const *file_name)
 {
@@ -758,10 +758,9 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
            break;
          stp = &st;
        }
-
       /* The caller tried to open a symbolic link with O_NOFOLLOW.
         Fall through, treating it as an already-existing file.  */
-
+      FALLTHROUGH;
     case EEXIST:
       /* Remove an old file, if the options allow this.  */
 
@@ -778,8 +777,7 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
        case KEEP_NEWER_FILES:
          if (file_newer_p (file_name, stp, &current_stat_info))
            break;
-         /* FALL THROUGH */
-
+         FALLTHROUGH;
        case DEFAULT_OLD_FILES:
        case NO_OVERWRITE_DIR_OLD_FILES:
        case OVERWRITE_OLD_FILES:
@@ -939,7 +937,7 @@ is_directory_link (const char *file_name)
   struct stat st;
   int e = errno;
   int res;
-  
+
   res = (fstatat (chdir_fd, file_name, &st, AT_SYMLINK_NOFOLLOW) == 0 &&
         S_ISLNK (st.st_mode) &&
         fstatat (chdir_fd, file_name, &st, 0) == 0 &&
@@ -1011,7 +1009,7 @@ extract_dir (char *file_name, int typeflag)
 
          if (keep_directory_symlink_option && is_directory_link (file_name))
            return 0;
-         
+
          if (deref_stat (file_name, &st) == 0)
            {
              current_mode = st.st_mode;
index 84e73aceb2ca1fad1a12a370ade9a467f9d7e597..14388a557ae67a67dc2cb7e67c077c42a266357d 100644 (file)
@@ -120,7 +120,7 @@ enforce_one_top_level (char **pfile_name)
 {
   char *file_name = *pfile_name;
   char *p;
-  
+
   for (p = file_name; *p && (ISSLASH (*p) || *p == '.'); p++)
     ;
 
@@ -132,7 +132,7 @@ enforce_one_top_level (char **pfile_name)
          if (ISSLASH (p[pos]) || p[pos] == 0)
            return;
        }
-    
+
       *pfile_name = make_file_name (one_top_level_dir, file_name);
       normalize_filename_x (*pfile_name);
     }
@@ -218,7 +218,7 @@ read_and (void (*do_something) (void))
                  if (show_omitted_dirs_option)
                    WARN ((0, 0, _("%s: Omitting"),
                           quotearg_colon (current_stat_info.file_name)));
-                 /* Fall through.  */
+                 FALLTHROUGH;
                default:
                  skip_member ();
                  continue;
@@ -273,8 +273,7 @@ read_and (void (*do_something) (void))
            {
            case HEADER_STILL_UNREAD:
              ERROR ((0, 0, _("This does not look like a tar archive")));
-             /* Fall through.  */
-
+             FALLTHROUGH;
            case HEADER_ZERO_BLOCK:
            case HEADER_SUCCESS:
              if (block_number_option)
index bd1e44e35526d5ca3a823462e13a7a3fa0c5aa6d..f6ad9fe0a64254789dfd9092f17db7b7da45c6f0 100644 (file)
@@ -146,7 +146,7 @@ static struct argp_option names_options[] = {
   {"no-wildcards-match-slash", NO_WILDCARDS_MATCH_SLASH_OPTION, 0, 0,
    N_("wildcards do not match '/'"), GRID+1 },
 #undef GRID
-  
+
   {NULL}
 };
 
@@ -160,7 +160,7 @@ file_selection_option (int key)
     if (p->key == key)
       return p;
   return NULL;
-}  
+}
 
 static char const *
 file_selection_option_name (int key)
@@ -173,7 +173,7 @@ static bool
 is_file_selection_option (int key)
 {
   return file_selection_option (key) != NULL;
-}  
+}
 \f
 /* Either NL or NUL, as decided by the --null option.  */
 static char filename_terminator = '\n';
@@ -221,7 +221,7 @@ static int matching_flags = 0;
   /* exclude_fnmatch options */
 static int include_anchored = EXCLUDE_ANCHORED;
   /* Pattern anchoring options used for file inclusion */
-  
+
 #define EXCLUDE_OPTIONS                                                \
   (((wildcards != disable_wildcards) ? EXCLUDE_WILDCARDS : 0)  \
   | matching_flags                                             \
@@ -696,7 +696,7 @@ name_list_adjust (void)
 
    For simplicity, only a tail pointer of the list is maintained.
 */
-   
+
 struct name_elt *unconsumed_option_tail;
 
 /* Push an option to the list */
@@ -729,7 +729,7 @@ unconsumed_option_report (void)
   if (unconsumed_option_tail)
     {
       struct name_elt *elt;
-      
+
       ERROR ((0, 0, _("The following options were used after any non-optional arguments in archive create or update mode.  These options are positional and affect only arguments that follow them.  Please, rearrange them properly.")));
 
       elt = unconsumed_option_tail;
@@ -753,13 +753,13 @@ unconsumed_option_report (void)
                ERROR ((0, 0, _("--%s has no effect"),
                        file_selection_option_name (elt->v.opt.option)));
              break;
-             
+
            default:
              break;
            }
          elt = elt->next;
        }
-      
+
       unconsumed_option_free ();
     }
 }
@@ -967,7 +967,7 @@ handle_option (const char *str, struct name_elt const *ent)
   struct wordsplit ws;
   int i;
   struct option_locus loc;
-  
+
   while (*str && isspace (*str))
     ++str;
   if (*str != '-')
@@ -1025,7 +1025,7 @@ read_next_name (struct name_elt *ent, struct name_elt *ret)
                   (0, 0, N_("%s: file name read contains nul character"),
                    quotearg_colon (ent->v.file.name)));
          ent->v.file.term = 0;
-         /* fall through */
+         FALLTHROUGH;
        case file_list_success:
          if (!ent->v.file.verbatim)
            {
@@ -1110,7 +1110,7 @@ name_next_elt (int change_dirs)
              name_list_advance ();
              break;
            }
-         /* fall through */
+         FALLTHROUGH;
        case NELT_NAME:
          copy_name (ep);
          if (unquote_option)
@@ -1128,7 +1128,7 @@ name_next_elt (int change_dirs)
     }
 
   unconsumed_option_report ();
-  
+
   return NULL;
 }
 
index b3a3fd3f8d07df5f44ae89cc3975f0698b7f2015..d41c0eacd1f355284a4cdb185c1d3c00bf4f0c08 100644 (file)
@@ -361,11 +361,12 @@ sparse_scan_file (struct tar_sparse_file *file)
       /* fall back to "raw" for this and all other files */
       hole_detection = HOLE_DETECTION_RAW;
 #endif
+      FALLTHROUGH;
     case HOLE_DETECTION_RAW:
       if (sparse_scan_file_raw (file))
        return true;
     }
-  
+
   return false;
 }
 
index 07a69956a8e2a55f54f8887441182d451f1b546d..3f844a8fd8dce372c59e1593d7ee38eea9dfbcff 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -1241,7 +1241,7 @@ parse_owner_group (char *arg, uintmax_t field_max, char const **name_option)
              u = u1;
              break;
            }
-         /* Fall through.  */
+         FALLTHROUGH;
        case LONGINT_OVERFLOW:
          invalid_num = arg;
          break;
@@ -1396,8 +1396,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
       optloc_save (OC_LISTED_INCREMENTAL, args->loc);
       listed_incremental_option = arg;
       after_date_option = true;
-      /* Fall through.  */
-
+      FALLTHROUGH;
     case 'G':
       /* We are making an incremental dump (FIXME: are we?); save
         directories at the beginning of the archive, and include in each
@@ -1522,8 +1521,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
 
     case 'N':
       after_date_option = true;
-      /* Fall through.  */
-
+      FALLTHROUGH;
     case NEWER_MTIME_OPTION:
       if (TIME_OPTION_INITIALIZED (newer_mtime_option))
        USAGE_ERROR ((0, 0, _("More than one threshold date")));
@@ -2066,6 +2064,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
 
       argp_error (state,
                  _("Options '-[0-7][lmh]' not supported by *this* tar"));
+      exit (EX_USAGE);
 
 #endif /* not DEVICE_PREFIX */
 
index 73fbbe1eeb2dc4f2de614a66670bd3152dec1083..2f823e45a02a29e5719a0a43dd1b6472217b34bb 100644 (file)
@@ -186,13 +186,11 @@ update_archive (void)
            {
            case HEADER_STILL_UNREAD:
              WARN ((0, 0, _("This does not look like a tar archive")));
-             /* Fall through.  */
-
+             FALLTHROUGH;
            case HEADER_SUCCESS:
            case HEADER_ZERO_BLOCK:
              ERROR ((0, 0, _("Skipping to next header")));
-             /* Fall through.  */
-
+             FALLTHROUGH;
            case HEADER_FAILURE:
              break;