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] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 07 Mar 2016 15:55:44 +0000
From:	Ben Hutchings <ben@...adent.org.uk>
To:	David Decotigny <ddecotig@...il.com>, netdev@...r.kernel.org
Cc:	Jeff Garzik <jgarzik@...ox.com>, David Miller <davem@...hat.com>,
	Vidya Sagar Ravipati <vidya@...ulusnetworks.com>,
	Joe Perches <joe@...ches.com>,
	David Decotigny <decot@...glers.com>
Subject: Re: [ethtool PATCH v3 02/12] ethtool.c: don't ignore fread() return
 value

On Fri, 2016-03-04 at 16:42 -0800, David Decotigny wrote:
> From: David Decotigny <decot@...glers.com>
> 
> This addresses:
>   ethtool.c:1116:8: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
> 
> 
> Signed-off-by: David Decotigny <decot@...glers.com>
> ---
>  ethtool.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/ethtool.c b/ethtool.c
> index 92c40b8..8a93dd1 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -1007,6 +1007,7 @@ static int dump_regs(int gregs_dump_raw, int gregs_dump_hex,
>  	if (gregs_dump_file) {
>  		FILE *f = fopen(gregs_dump_file, "r");
>  		struct stat st;
> +		size_t nread;
>  
>  		if (!f || fstat(fileno(f), &st) < 0) {
>  			fprintf(stderr, "Can't open '%s': %s\n",
> @@ -1016,8 +1017,10 @@ static int dump_regs(int gregs_dump_raw, int gregs_dump_hex,
>  
>  		regs = realloc(regs, sizeof(*regs) + st.st_size);
>  		regs->len = st.st_size;
> -		fread(regs->data, regs->len, 1, f);
> +		nread = fread(regs->data, regs->len, 1, f);
>  		fclose(f);
> +		if (1 != nread)

This comparison should be written the other way round, no matter what
your personal preference is.

Ben.

> +			return -1;
>  	}
>  
>  	if (!gregs_dump_hex)
-- 
Ben Hutchings
The most exhausting thing in life is being insincere. - Anne Morrow Lindberg
Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ