]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: silence GCC warnings
authorKefu Chai <kchai@redhat.com>
Wed, 18 Apr 2018 03:08:44 +0000 (11:08 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 18 Apr 2018 07:10:54 +0000 (15:10 +0800)
Preforker.h:111:8: warning: ignoring return value of ‘ssize_t
safe_write(int, const void*, size_t)’, declared with attribute
warn_unused_result [-Wunused-result]
        (void)safe_write(fd[1], &r, sizeof(r));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and

compat.cc:36:28: warning: comparison between signed and unsigned integer
expressions [-Wsign-compare]
     if (off + sizeof(data) > len)
         ~~~~~~~~~~~~~~~~~~~^~~~~

Fixes: http://tracker.ceph.com/issues/23774
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/Preforker.h
src/common/compat.cc

index f6671a5d302d6ef9125fd6745199385b2d018721..8925d944daa3458f8a6e04f39d9939ac9a9c3e72 100644 (file)
@@ -108,7 +108,7 @@ public:
   int signal_exit(int r) {
     if (forked) {
       /* If we get an error here, it's too late to do anything reasonable about it. */
-      (void)safe_write(fd[1], &r, sizeof(r));
+      [[maybe_unused]] auto n = safe_write(fd[1], &r, sizeof(r));
     }
     return r;
   }
index 18b75874ad055f247bd4a9d4625ebb160f07c274..66f6e7e8f6b30f60e604ca467af8d6af5d9788a4 100644 (file)
@@ -33,7 +33,7 @@ int manual_fallocate(int fd, off_t offset, off_t len) {
   // TODO: compressing filesystems would require random data
   memset(data, 0x42, sizeof(data));
   for (off_t off = 0; off < len; off += sizeof(data)) {
-    if (off + sizeof(data) > len)
+    if (off + static_cast<off_t>(sizeof(data)) > len)
       r = safe_write(fd, data, len - off);
     else
       r = safe_write(fd, data, sizeof(data));