qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Franciosi <felipe@nutanix.com>
To: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>,
	Eric Blake <eblake@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>,
	qemu-devel@nongnu.org, Felipe Franciosi <felipe@nutanix.com>
Subject: [Qemu-devel] [PATCH 2/2] replay: Ignore the return value of fwrite()
Date: Wed, 21 Sep 2016 16:27:02 +0100	[thread overview]
Message-ID: <1474471622-12802-2-git-send-email-felipe@nutanix.com> (raw)
In-Reply-To: <1474471622-12802-1-git-send-email-felipe@nutanix.com>

If building with GCC 3.4 or newer (and using -Werror=unused-result),
replay-internal.c will fail to compile due to a call to fwrite() where
the return value is not used. Since fwrite() is declared with WUR in
glibc, callers should check the return value or find other ways to
ignore it. The error message in this specific case is:

    replay/replay-internal.c: In function ‘replay_put_array’:
    replay/replay-internal.c:68:15: error: ignoring return value of
    ‘fwrite’, declared with attribute warn_unused_result [-Werror=unused-result]
             fwrite(buf, 1, size, replay_file);
                   ^

This commit wraps the fwrite() call with the ignore_value() macro, which
currently suppresses the error for existing GCC versions.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
---
 replay/replay-internal.  | 0
 replay/replay-internal.c | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 create mode 100644 replay/replay-internal.

diff --git a/replay/replay-internal. b/replay/replay-internal.
new file mode 100644
index 0000000..e69de29
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index 5835e8d..61de8f9 100644
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -65,7 +65,7 @@ void replay_put_array(const uint8_t *buf, size_t size)
 {
     if (replay_file) {
         replay_put_dword(size);
-        fwrite(buf, 1, size, replay_file);
+        ignore_value(fwrite(buf, 1, size, replay_file));
     }
 }
 
-- 
1.9.5

  reply	other threads:[~2016-09-21 15:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21 15:27 [Qemu-devel] [PATCH 1/2] compiler: add ignore_value() macro Felipe Franciosi
2016-09-21 15:27 ` Felipe Franciosi [this message]
2016-09-21 18:17   ` [Qemu-devel] [PATCH 2/2] replay: Ignore the return value of fwrite() Eric Blake
2016-09-21 18:43     ` Felipe Franciosi
2016-09-21 18:15 ` [Qemu-devel] [PATCH 1/2] compiler: add ignore_value() macro Eric Blake
2016-10-12 17:20   ` Felipe Franciosi
2016-10-25 15:21     ` Felipe Franciosi
2016-11-18 21:09       ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474471622-12802-2-git-send-email-felipe@nutanix.com \
    --to=felipe@nutanix.com \
    --cc=Pavel.Dovgaluk@ispras.ru \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).