From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id E13C62E8B for ; Fri, 8 Sep 2017 11:01:20 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Sep 2017 02:01:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,360,1500966000"; d="scan'208";a="149599764" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.24]) by fmsmga006.fm.intel.com with SMTP; 08 Sep 2017 02:01:17 -0700 Received: by (sSMTP sendmail emulation); Fri, 08 Sep 2017 10:01:17 +0100 Date: Fri, 8 Sep 2017 10:01:16 +0100 From: Bruce Richardson To: Olivier MATZ Cc: Stephen Hemminger , dev@dpdk.org Message-ID: <20170908090116.GD35580@bricha3-MOBL3.ger.corp.intel.com> References: <20170907130923.157924-1-bruce.richardson@intel.com> <20170907105020.62f8eb79@xeon-e3> <20170907194617.igcohinh53imc3mk@neon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170907194617.igcohinh53imc3mk@neon> Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.8.3 (2017-05-23) Subject: Re: [dpdk-dev] [PATCH] cmdline: fix warning for unused return value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 09:01:21 -0000 On Thu, Sep 07, 2017 at 09:46:18PM +0200, Olivier MATZ wrote: > On Thu, Sep 07, 2017 at 10:50:20AM -0700, Stephen Hemminger wrote: > > On Thu, 7 Sep 2017 14:09:23 +0100 > > Bruce Richardson wrote: > > > > > When DPDK is compiled on Ubuntu with extra warnings turned on, there is a > > > warning about the return value from write() being unchecked. Rather than > > > having builds disable the warning, which may mask other cases we do care > > > about, we can add a dummy use of the return value in the code to silence it > > > in this instance. > > > > > > Signed-off-by: Bruce Richardson > > > --- > > > lib/librte_cmdline/cmdline.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c > > > index a9c47be..d749165 100644 > > > --- a/lib/librte_cmdline/cmdline.c > > > +++ b/lib/librte_cmdline/cmdline.c > > > @@ -205,7 +205,8 @@ cmdline_printf(const struct cmdline *cl, const char *fmt, ...) > > > } > > > if (ret >= BUFSIZ) > > > ret = BUFSIZ - 1; > > > - write(cl->s_out, buf, ret); > > > + ret = write(cl->s_out, buf, ret); > > > + (void)ret; > > > > That is an ugly way to fix the warning. > > If write fails, the user has probably logged out. > > Here, we are writing on stdout. > I don't think it's worst than calling printf() without checking the > return value. > > By the way, it looks strange to this code is compiled, because > -D _GNU_SOURCE is passed to the compiler, and the code is: > > #ifdef _GNU_SOURCE > ... > #else > ... > write() > #endif > > It does not mean we shouldn't fix it, but maybe it hides something > else. Bruce, I bet you are testing your new build framework? > > Olivier Yep, and meson has the -Wunused-result flag on by default, and on Ubuntu write is marked as needing the result check. I don't like disabling warnings, so I'd rather fix it this way, for the sake of on extra line of ugliness. Open to better options though (other than not using Ubuntu, which is fine with me, but some others seem to object to that :-) )