lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1374513997.1635.22.camel@bwh-desktop.uk.level5networks.com>
Date:	Mon, 22 Jul 2013 18:26:37 +0100
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
CC:	Christoph Paasch <christoph.paasch@...ouvain.be>,
	Stephen Hemminger <stephen@...workplumber.org>,
	<netdev@...r.kernel.org>
Subject: Re: [PATCH iproute2 1/2] ss: Fix compiler errors of unused
 return-values

On Mon, 2013-07-22 at 08:38 -0700, Eric Dumazet wrote:
> On Sat, 2013-07-20 at 21:58 +0200, Christoph Paasch wrote:
> > Many errors when compiling with gcc 4.7.3 about unused return-values
> > upon the calls to fgets and fscanf:
> >
> 
> > For the calls to fscanf we can't really do anything about it, and just
> > do an empty if-statement to make the compiler happy.
> > 
> > Signed-off-by: Christoph Paasch <christoph.paasch@...ouvain.be>
> > ---
> >  misc/ss.c | 30 +++++++++++++++++++++---------
> >  1 file changed, 21 insertions(+), 9 deletions(-)
> > 
> > diff --git a/misc/ss.c b/misc/ss.c
> > index c0369f1..0f71108 100644
> > --- a/misc/ss.c
> > +++ b/misc/ss.c
> > @@ -302,7 +302,7 @@ static void user_ent_hash_build(void)
> >  
> >  				snprintf(tmp, sizeof(tmp), "%s/%d/stat", root, pid);
> >  				if ((fp = fopen(tmp, "r")) != NULL) {
> > -					fscanf(fp, "%*d (%[^)])", process);
> > +					if (fscanf(fp, "%*d (%[^)])", process) == EOF);
> 
> This is really ugly :(

It is.  And gcc doesn't accept casting to void to suppress the warning.
Maybe add a wrapper fscanf_with_output_already_set_to_default()? ;-)  Or
do what glibc expects and set the defaults only when fscanf() reads less
than we wanted:

	switch (fscanf(p, "...", &foo, &bar, ...)) {
	case EOF:
	case 0: foo = ...;
	case 1: bar = ...;
	...
	}

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ