From c4f51c85df3ba2b20572159f4ebdacb29fe3d6ff Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 18 Apr 2018 11:08:44 +0800 Subject: [PATCH] common: silence GCC warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/common/Preforker.h | 2 +- src/common/compat.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/Preforker.h b/src/common/Preforker.h index f6671a5d302d6..8925d944daa34 100644 --- a/src/common/Preforker.h +++ b/src/common/Preforker.h @@ -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; } diff --git a/src/common/compat.cc b/src/common/compat.cc index 18b75874ad055..66f6e7e8f6b30 100644 --- a/src/common/compat.cc +++ b/src/common/compat.cc @@ -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(sizeof(data)) > len) r = safe_write(fd, data, len - off); else r = safe_write(fd, data, sizeof(data)); -- 2.39.5