From mboxrd@z Thu Jan 1 00:00:00 1970 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 Message-ID: <4E12C5B0.3040704@redhat.com> References: <2cb2082c25eadc24d1e22ebbd4293e3e6b53c832.1309816302.git.rprabhu@wnohang.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Peter Maydell , Raghavendra D Prabhu , qemu-devel@nongnu.org, Raghavendra D Prabhu , kvm@vger.kernel.org To: Markus Armbruster Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:55921 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754481Ab1GEIFI (ORCPT ); Tue, 5 Jul 2011 04:05:08 -0400 Received: by wyg8 with SMTP id 8so3808549wyg.19 for ; Tue, 05 Jul 2011 01:05:07 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: 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