]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: avoid warnings due to attribute warn_unused_result
authorJim Meyering <meyering@redhat.com>
Wed, 8 Oct 2008 08:44:12 +0000 (10:44 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 17 Oct 2008 05:06:54 +0000 (07:06 +0200)
Now that a (void) cast no longer suffices to ignore warnings from gcc
about uses of functions marked with the warn_unused_result attribute,
we need an alternative.  For the record, here's one of the ignorable
warnings: "copy.c:233: warning: ignoring return value of 'fchown',
declared with attribute warn_unused_result"
* bootstrap.conf (gnulib_modules): Import ignore-value.
* src/copy.c: Include "ignore-value.h".
(set_owner): Use ignore_value in place of "(void)" casts,
to ignore lchown and fchown failures.
* src/cp.c (re_protect): Likewise, to ignore lchown failure.
* src/remove.c (preprocess_dir): Remove unnecessary "(void)" cast.

bootstrap.conf
src/copy.c
src/cp.c
src/remove.c

index 6405955c6ff5d2b552fd71f41696a44cba3db989..c6698f1140bc6a27259b406e1379a1f7a8977207 100644 (file)
@@ -61,6 +61,7 @@ gnulib_modules="
        gitlog-to-changelog
        gnu-make gnumakefile gnupload
        group-member hard-locale hash hash-pjw host-os human idcache
+       ignore-value
        inttostr inttypes isapipe
        lchmod lchown lib-ignore linebuffer link-follow
        long-options lstat malloc mbswidth memcasecmp mempcpy
index 82c6978e4ef67b8497c8ced2cbadbe524f06085f..5a584752d41ed2b2e742b935d2a72dd6ff6ace61 100644 (file)
@@ -44,6 +44,7 @@
 #include "full-write.h"
 #include "hash.h"
 #include "hash-triple.h"
+#include "ignore-value.h"
 #include "lchmod.h"
 #include "quote.h"
 #include "same.h"
@@ -230,7 +231,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
          /* We've failed to set *both*.  Now, try to set just the group
             ID, but ignore any failure here, and don't change errno.  */
           int saved_errno = errno;
-          (void) fchown (dest_desc, -1, gid);
+          ignore_value (fchown (dest_desc, -1, gid));
           errno = saved_errno;
         }
     }
@@ -243,7 +244,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
          /* We've failed to set *both*.  Now, try to set just the group
             ID, but ignore any failure here, and don't change errno.  */
           int saved_errno = errno;
-          (void) lchown (dst_name, -1, gid);
+          ignore_value (lchown (dst_name, -1, gid));
           errno = saved_errno;
         }
     }
index 77d47027d0aa7880fad9d601abe5adada4327f61..58c9c0953be9e113b050a268edb0aa2498e56bbe 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -29,6 +29,7 @@
 #include "cp-hash.h"
 #include "error.h"
 #include "filenamecat.h"
+#include "ignore-value.h"
 #include "lchmod.h"
 #include "quote.h"
 #include "stat-time.h"
@@ -326,7 +327,7 @@ re_protect (char const *const_dst_name, size_t src_offset,
                 }
               /* Failing to preserve ownership is OK. Still, try to preserve
                  the group, but ignore the possible error. */
-              (void) lchown (dst_name, -1, p->st.st_gid);
+              ignore_value (lchown (dst_name, -1, p->st.st_gid));
             }
        }
 
index 2e342c0922845f1bd2353405c8fc10f6ebcdf343..e92f78caf3ec99bd97eee94cdba6f01c7d66d099 100644 (file)
@@ -1423,7 +1423,7 @@ preprocess_dir (DIR **dirp, struct rm_options const *x)
   for (size_t i = 0; i < n; i++)
     {
       /* ignore failure */
-      (void) unlinkat (dir_fd, vv[i]->name, 0);
+      unlinkat (dir_fd, vv[i]->name, 0);
     }
 
  cleanup: