From: Ewan Mellor Subject: Re: [PATCH] Check some returns of common functions Date: Wed, 26 Apr 2006 09:29:13 +0100 Message-ID: <20060426082913.GA19433@leeni.uk.xensource.com> References: <1146017884.3007.13.camel@aglarond.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1146017884.3007.13.camel@aglarond.local> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jeremy Katz Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Tue, Apr 25, 2006 at 10:18:04PM -0400, Jeremy Katz wrote: > When building with FORTIFY_SOURCE to ensure that return codes of common > functions are checked to avoid some bugs, a few warnings pop up and > become errors due to -Werror. Attached checks the return codes > > Signed-off-by: Jeremy Katz > --- xen-unstable.hg/tools/xenstore/xenstored_core.c.unused 2006-04-25 22:06:11.000000000 -0400 > +++ xen-unstable.hg/tools/xenstore/xenstored_core.c 2006-04-25 22:11:22.000000000 -0400 > @@ -173,7 +173,7 @@ > va_list arglist; > char *str; > char sbuf[1024]; > - int ret; > + int ret, dummy; > > if (tracefd < 0) > return; > @@ -184,7 +184,7 @@ > va_end(arglist); > > if (ret <= 1024) { > - write(tracefd, sbuf, ret); > + dummy = write(tracefd, sbuf, ret); > return; Does (void)write(tracefd, sbuf, ref) not work? This ought to make it clear that the return value is being ignored without additional dummy variables. Ewan.