From: "Jan Beulich" Subject: Re: [PATCH] Add missing return value checks Date: Mon, 12 Aug 2013 09:24:59 +0100 Message-ID: <5208B7FB02000078000EB091@nat28.tlf.novell.com> References: <20130811201020.GA3460@mail.waldi.eu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1V8oao-0000dD-MY for xen-devel@lists.xenproject.org; Mon, 12 Aug 2013 09:39:14 +0000 In-Reply-To: <20130811201020.GA3460@mail.waldi.eu.org> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Bastian Blank Cc: ian.jackson@citrix.com, ian.campbell@citrix.com, xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 11.08.13 at 22:10, Bastian Blank wrote: > The return value of vasprintf must be checked. This check is enforced > with the compiler options used in Debian by request and in Ubuntu by > default. The function is not declared with __attribute__((warn_unused_result)), so what's the deal here? Are you saying that the compiler options are such that _any_ unused return value would be complained about? I doubt that, as I'd expect a lot more instances of such throughout the tree. Hence - what's going on here? Jan > Check the return value and abort on error. > > Signed-off-by: Bastian Blank > > diff --git a/tools/tests/mce-test/tools/xen-mceinj.c > b/tools/tests/mce-test/tools/xen-mceinj.c > index e3e62f7..21a488b 100644 > --- a/tools/tests/mce-test/tools/xen-mceinj.c > +++ b/tools/tests/mce-test/tools/xen-mceinj.c > @@ -92,7 +92,8 @@ static void Lprintf(const char *fmt, ...) > va_list args; > > va_start(args, fmt); > - vasprintf(&buf, fmt, args); > + if (vasprintf(&buf, fmt, args) < 0) > + abort(); > fprintf(LOGFILE, "%s", buf); > va_end(args); > free(buf); > @@ -104,7 +105,8 @@ static void err(xc_interface *xc_handle, const char *fmt, > ...) > va_list args; > > va_start(args, fmt); > - vasprintf(&buf, fmt, args); > + if (vasprintf(&buf, fmt, args) < 0) > + abort(); > perror(buf); > va_end(args); > free(buf); > -- > Emotions are alien to me. I'm a scientist. > -- Spock, "This Side of Paradise", stardate 3417.3 > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel