]> git.ipfire.org Git - thirdparty/coreutils.git/commit
maint: pacify ‘gcc -Wswitch-enum’
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 3 Feb 2025 06:09:09 +0000 (22:09 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 3 Feb 2025 06:09:52 +0000 (22:09 -0800)
commit008bb4732b75310f1aaf59e6311888058e81ca77
tree57fb34212bbaf1f8815215bac906129ac440cd97
parentd7c6f85189c9cb957694869f0960e104050bfb57
maint: pacify ‘gcc -Wswitch-enum’

I thought of a way to pacify -Wswitch-enum without much trouble.
Either add all the enums, or if that’s too verbose use ‘switch (+E)’
to indicate to the reader that there need not be a case for
every enum value.  Since this approach improves static checking,
make the change everywhere and check it with -Wswitch-enum.
* configure.ac: Compile with -Wswitch-enum if it works and
--enable-gcc-warnings.  No need to remove -Wswitch-default
since Gnulib no longer adds it.
* src/chmod.c (describe_change):
* src/chown-core.c (describe_change):
* src/copy.c (copy_debug_string, copy_debug_sparse_string):
* src/df.c (decode_output_arg, get_dev):
* src/du.c (main):
* src/factor.c (print_factors):
* src/head.c (diagnose_copy_fd_failure):
* src/ls.c (time_type_to_statx, calc_req_mask)
(decode_line_length, get_funky_string, parse_ls_color)
(gobble_file, print_long_format):
* src/split.c (main):
* src/sync.c (sync_arg):
* src/tr.c (is_char_class_member):
* src/wc.c (main):
Add switch cases to pacify -Wswitch-enum.
* src/copy.c (copy_debug_string, copy_debug_sparse_string):
Add unreachable () for unreachable cases.
* src/digest.c (main):
* src/od.c (decode_one_format):
* src/tr.c (get_next, get_spec_stats):
switch (E) → switch (+E).
* src/digest.c (main):
* src/tr.c (get_next):
Omit unnecessary ‘default: break;’ that merely pacified GCC,
as the new pacification style is better.
* src/ls.c (decode_line_length):
Add default unreachable case to prevent warning that function
might not return a value.
(gobble_file): Distinguish DEREF_NEVER from unreachable cases.
15 files changed:
configure.ac
src/chmod.c
src/chown-core.c
src/copy.c
src/df.c
src/digest.c
src/du.c
src/factor.c
src/head.c
src/ls.c
src/od.c
src/split.c
src/sync.c
src/tr.c
src/wc.c