|
From: | Paolo Bonzini |
Subject: | Re: [Qemu-devel] [PATCH 3/3] Avoid Wunsed-but-set warnings (or errors in case of Werror) |
Date: | Tue, 05 Jul 2011 10:05:04 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Mnenhy/0.8.3 Thunderbird/3.1.10 |
On 07/05/2011 09:49 AM, Markus Armbruster wrote:
> If 'ret' has been used to silence compiler warnings about functions > which have been declared with attribute __warn_unused_result__ > (eg write() and various other libc functions) then "(void)write()" > is insufficient -- gcc requires the variable. gcc being silly. Oh well.
In this particular case I think that the return value should be checked. It's good if something is printed in the log saying that the reset wasn't done for some reason---even if it is just defensive.
The really silly thing is in glibc, not gcc. __warn_unused_result__ was added to fwrite, where you have no certainty that the write has been done, but not to either fclose or fflush. Oh well...
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |