From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmm5h-00016j-2p for qemu-devel@nongnu.org; Wed, 21 Sep 2016 14:17:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmm5c-0002wA-RP for qemu-devel@nongnu.org; Wed, 21 Sep 2016 14:17:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmm5c-0002vv-IH for qemu-devel@nongnu.org; Wed, 21 Sep 2016 14:17:48 -0400 References: <1474471622-12802-1-git-send-email-felipe@nutanix.com> <1474471622-12802-2-git-send-email-felipe@nutanix.com> From: Eric Blake Message-ID: <9b762b1d-66ec-38db-37b7-83b1ad64ccbd@redhat.com> Date: Wed, 21 Sep 2016 13:17:46 -0500 MIME-Version: 1.0 In-Reply-To: <1474471622-12802-2-git-send-email-felipe@nutanix.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="JRq47ksmVlp1GaqvfTHc1EMlHLN8tLORX" Subject: Re: [Qemu-devel] [PATCH 2/2] replay: Ignore the return value of fwrite() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Felipe Franciosi , Pavel Dovgalyuk , "Daniel P. Berrange" Cc: Markus Armbruster , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --JRq47ksmVlp1GaqvfTHc1EMlHLN8tLORX From: Eric Blake To: Felipe Franciosi , Pavel Dovgalyuk , "Daniel P. Berrange" Cc: Markus Armbruster , qemu-devel@nongnu.org Message-ID: <9b762b1d-66ec-38db-37b7-83b1ad64ccbd@redhat.com> Subject: Re: [PATCH 2/2] replay: Ignore the return value of fwrite() References: <1474471622-12802-1-git-send-email-felipe@nutanix.com> <1474471622-12802-2-git-send-email-felipe@nutanix.com> In-Reply-To: <1474471622-12802-2-git-send-email-felipe@nutanix.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/21/2016 10:27 AM, Felipe Franciosi wrote: > If building with GCC 3.4 or newer (and using -Werror=3Dunused-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: >=20 > replay/replay-internal.c: In function =E2=80=98replay_put_array=E2=80= =99: > replay/replay-internal.c:68:15: error: ignoring return value of > =E2=80=98fwrite=E2=80=99, declared with attribute warn_unused_resul= t [-Werror=3Dunused-result] > fwrite(buf, 1, size, replay_file); > ^ >=20 > This commit wraps the fwrite() call with the ignore_value() macro, whic= h > currently suppresses the error for existing GCC versions. This explains what you did, but not quite why. In other words, convince me that ignoring the error is the right thing to do in the first place...= >=20 > Signed-off-by: Felipe Franciosi > --- > replay/replay-internal. | 0 > replay/replay-internal.c | 2 +- > 2 files changed, 1 insertion(+), 1 deletion(-) > create mode 100644 replay/replay-internal. >=20 > 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)); I would be more convinced that this patch is correct if you added a comment here why fwrite() failures can be ignored in this situation, so that someone doesn't undo your commit to add in proper error handling. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --JRq47ksmVlp1GaqvfTHc1EMlHLN8tLORX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJX4s7KAAoJEKeha0olJ0NqcNEH/26Q+tttth6t7c0+eEJevPVj zFOb49pvavhIc25r40JL6VZsVoWJZudkVLX4ZnQWZcx52rg6rm7OXnunNGIih/W4 MdY+pXMrqTV3tzDaaqB+Q8PmmrRVuZyyhX+DfnIXkw5Gq7TwBcoKmRUKo+PafCV+ n2UVtmKVS3siNqG4fKgPS4p7F8tSyml+qiDZQR91PgipmP9j6oiKmwLJGCCUR61B fcVy0m0dl3pw9CbadA5J1eF9DWeFWlQmkq/z6/TfJtenEOLXn8bmUMMVnh3JoTrq /XKrHuWMajvq4x6TeG3w3fc9maCwTQo/l9Z+LGS3uS6Qe9xEuKTKuPcmdDYD2ac= =MrlN -----END PGP SIGNATURE----- --JRq47ksmVlp1GaqvfTHc1EMlHLN8tLORX--