]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: avoid new warning from gcc (GCC) 7.0.0 20160503 (experimental)
authorJim Meyering <meyering@fb.com>
Wed, 4 May 2016 03:56:20 +0000 (20:56 -0700)
committerJim Meyering <meyering@fb.com>
Wed, 4 May 2016 15:05:54 +0000 (08:05 -0700)
* src/id.c (main): When configured with --enable-gcc-warnings and using
the very latest gcc built from git, building would fail with this:
  src/id.c:200:8: error: assuming signed overflow does not occur when \
    simplifying conditional to constant [-Werror=strict-overflow]
     bool default_format = (just_user + just_group + just_group_list
          ^~~~~~~~~~~~~~
Rewrite to use bool-appropriate operators.

src/id.c

index 38844af70a4a27942ffeaa14192afd48b06a5f92..218ee5a318e1a5e6c4bf0440debfee1d8aba0066 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -197,8 +197,10 @@ main (int argc, char **argv)
   if (just_user + just_group + just_group_list + just_context > 1)
     error (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice"));
 
-  bool default_format = (just_user + just_group + just_group_list
-                         + just_context == 0);
+  bool default_format = ! (just_user
+                           || just_group
+                           || just_group_list
+                           || just_context);
 
   if (default_format && (use_real || use_name))
     error (EXIT_FAILURE, 0,