netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: David Decotigny <ddecotig@gmail.com>, netdev@vger.kernel.org
Cc: Jeff Garzik <jgarzik@pobox.com>, David Miller <davem@redhat.com>,
	Vidya Sagar Ravipati <vidya@cumulusnetworks.com>,
	Joe Perches <joe@perches.com>,
	David Decotigny <decot@googlers.com>
Subject: Re: [ethtool PATCH v3 02/12] ethtool.c: don't ignore fread() return value
Date: Mon, 07 Mar 2016 15:55:44 +0000	[thread overview]
Message-ID: <1457366144.15205.13.camel@decadent.org.uk> (raw)
In-Reply-To: <1457138533-2417-3-git-send-email-ddecotig@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1406 bytes --]

On Fri, 2016-03-04 at 16:42 -0800, David Decotigny wrote:
> From: David Decotigny <decot@googlers.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@googlers.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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-03-07 15:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-05  0:42 [ethtool PATCH v3 00/12] add support for new ETHTOOL_xLINKSETTINGS ioctls David Decotigny
2016-03-05  0:42 ` [ethtool PATCH v3 01/12] internal.h: change to new sane powerpc64 kernel headers David Decotigny
2016-03-07 15:53   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 02/12] ethtool.c: don't ignore fread() return value David Decotigny
2016-03-07 15:55   ` Ben Hutchings [this message]
2016-03-05  0:42 ` [ethtool PATCH v3 03/12] ethtool.c: fix dump_regs heap corruption David Decotigny
2016-03-07 16:02   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 04/12] ethtool.c: do_seeprom checks for params & stdin sanity David Decotigny
2016-03-07 16:05   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 05/12] marvell.c: fix strict alias warnings David Decotigny
2016-03-07 16:06   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 06/12] test-common.c: fix test_realloc(NULL, ...) David Decotigny
2016-03-07 16:07   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 07/12] test-features.c: add braces around array initialization David Decotigny
2016-03-07 16:08   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 08/12] ethtool-copy.h: sync with net-next David Decotigny
2016-03-07 16:10   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 09/12] internal.h: fix build for latest ethtool-copy.h David Decotigny
2016-03-07 16:11   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 10/12] internal.h: TRUE/FALSE macros David Decotigny
2016-03-07 16:12   ` Ben Hutchings
2016-03-05  0:42 ` [ethtool PATCH v3 11/12] ethtool.c: add support for ETHTOOL_xLINKSETTINGS ioctls David Decotigny
2016-03-05  0:42 ` [ethtool PATCH v3 12/12] ethtool.c: use v6 socket when v4 is not available David Decotigny
2016-03-07 16:13   ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457366144.15205.13.camel@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=davem@redhat.com \
    --cc=ddecotig@gmail.com \
    --cc=decot@googlers.com \
    --cc=jgarzik@pobox.com \
    --cc=joe@perches.com \
    --cc=netdev@vger.kernel.org \
    --cc=vidya@cumulusnetworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).