DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] cmdline: fix warning for unused return value
@ 2017-09-07 13:09 Bruce Richardson
  2017-09-07 13:49 ` Olivier MATZ
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Bruce Richardson @ 2017-09-07 13:09 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

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 <bruce.richardson@intel.com>
---
 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;
 	free(buf);
 #endif
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] cmdline: fix warning for unused return value
  2017-09-07 13:09 [dpdk-dev] [PATCH] cmdline: fix warning for unused return value Bruce Richardson
@ 2017-09-07 13:49 ` Olivier MATZ
  2017-10-05 16:36   ` Thomas Monjalon
  2017-09-07 17:50 ` Stephen Hemminger
  2017-09-15 10:45 ` Van Haaren, Harry
  2 siblings, 1 reply; 7+ messages in thread
From: Olivier MATZ @ 2017-09-07 13:49 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Thu, Sep 07, 2017 at 02:09:23PM +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 <bruce.richardson@intel.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] cmdline: fix warning for unused return value
  2017-09-07 13:09 [dpdk-dev] [PATCH] cmdline: fix warning for unused return value Bruce Richardson
  2017-09-07 13:49 ` Olivier MATZ
@ 2017-09-07 17:50 ` Stephen Hemminger
  2017-09-07 19:46   ` Olivier MATZ
  2017-09-15 10:45 ` Van Haaren, Harry
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2017-09-07 17:50 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Thu,  7 Sep 2017 14:09:23 +0100
Bruce Richardson <bruce.richardson@intel.com> 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 <bruce.richardson@intel.com>
> ---
>  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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] cmdline: fix warning for unused return value
  2017-09-07 17:50 ` Stephen Hemminger
@ 2017-09-07 19:46   ` Olivier MATZ
  2017-09-08  9:01     ` Bruce Richardson
  0 siblings, 1 reply; 7+ messages in thread
From: Olivier MATZ @ 2017-09-07 19:46 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Bruce Richardson, dev

On Thu, Sep 07, 2017 at 10:50:20AM -0700, Stephen Hemminger wrote:
> On Thu,  7 Sep 2017 14:09:23 +0100
> Bruce Richardson <bruce.richardson@intel.com> 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 <bruce.richardson@intel.com>
> > ---
> >  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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] cmdline: fix warning for unused return value
  2017-09-07 19:46   ` Olivier MATZ
@ 2017-09-08  9:01     ` Bruce Richardson
  0 siblings, 0 replies; 7+ messages in thread
From: Bruce Richardson @ 2017-09-08  9:01 UTC (permalink / raw)
  To: Olivier MATZ; +Cc: Stephen Hemminger, dev

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 <bruce.richardson@intel.com> 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 <bruce.richardson@intel.com>
> > > ---
> > >  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 :-) )

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] cmdline: fix warning for unused return value
  2017-09-07 13:09 [dpdk-dev] [PATCH] cmdline: fix warning for unused return value Bruce Richardson
  2017-09-07 13:49 ` Olivier MATZ
  2017-09-07 17:50 ` Stephen Hemminger
@ 2017-09-15 10:45 ` Van Haaren, Harry
  2 siblings, 0 replies; 7+ messages in thread
From: Van Haaren, Harry @ 2017-09-15 10:45 UTC (permalink / raw)
  To: Richardson, Bruce, dev; +Cc: Richardson, Bruce

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson
> Sent: Thursday, September 7, 2017 2:09 PM
> To: dev@dpdk.org
> Cc: Richardson, Bruce <bruce.richardson@intel.com>
> Subject: [dpdk-dev] [PATCH] cmdline: fix warning for unused return value
> 
> 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 <bruce.richardson@intel.com>
> ---

A pragmatic fix for the compile warning at hand;

Acked-by: Harry van Haaren <harry.van.haaren@intel.com>


>  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;
>  	free(buf);
>  #endif
>  }
> --
> 2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] cmdline: fix warning for unused return value
  2017-09-07 13:49 ` Olivier MATZ
@ 2017-10-05 16:36   ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2017-10-05 16:36 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Olivier MATZ

07/09/2017 15:49, Olivier MATZ:
> On Thu, Sep 07, 2017 at 02:09:23PM +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 <bruce.richardson@intel.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-05 16:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-07 13:09 [dpdk-dev] [PATCH] cmdline: fix warning for unused return value Bruce Richardson
2017-09-07 13:49 ` Olivier MATZ
2017-10-05 16:36   ` Thomas Monjalon
2017-09-07 17:50 ` Stephen Hemminger
2017-09-07 19:46   ` Olivier MATZ
2017-09-08  9:01     ` Bruce Richardson
2017-09-15 10:45 ` Van Haaren, Harry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).