linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Patrick Georgi <patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
Cc: linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 4/5 v2] set: check seek success
Date: Mon, 10 Nov 2014 09:51:03 +0100	[thread overview]
Message-ID: <20141110085102.GA12126@ulmo> (raw)
In-Reply-To: <545E95B1.5030703-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>

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

On Sat, Nov 08, 2014 at 11:14:09PM +0100, Patrick Georgi wrote:
> This could silently fail which leads to surprising behaviour.
> 
> Found-by: Coverity Scan
> Signed-off-by: Patrick Georgi <patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
> ---
>  src/set.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/set.c b/src/set.c
> index ff32b53..907d640 100644
> --- a/src/set.c
> +++ b/src/set.c
> @@ -59,7 +59,11 @@ read_from_image(char	*filename,
>  		return result;
>  	}
>  
> -	fseek(fp, offset, SEEK_SET);
> +	if (fseek(fp, offset, SEEK_SET) == -1) {
> +		printf("Error: Couldn't seek to %s(%d)\n", filename, offset);

offset is unsigned, so the format specifier should be %u. I also wonder
whether it would be good to output errno along with the message (or the
string representation thereof) to increase the information content. But
given that none of the other error messages have that it could be a
separate patch.

With the %d -> %u for the format specifier, this is:

Reviewed-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2014-11-10  8:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02  8:16 [PATCH 1/5] configure.ac: Don't search for c++ compiler Patrick Georgi
     [not found] ` <1412237788-20611-1-git-send-email-patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
2014-10-02  8:16   ` [PATCH 2/5] cbootimage: simplify code Patrick Georgi
2014-10-02  8:16   ` [PATCH 3/5] data_layout: improve memory handling Patrick Georgi
2014-10-02  8:16   ` [PATCH 4/5] set: check seek success Patrick Georgi
     [not found]     ` <1412237788-20611-4-git-send-email-patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
2014-10-02 22:58       ` Stephen Warren
     [not found]         ` <542DD8A7.7040705-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-10-03  6:54           ` Patrick Georgi
     [not found]             ` <542E4817.1000604-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
2014-10-03 15:38               ` Stephen Warren
2014-10-02  8:16   ` [PATCH 5/5] data_layout: fail better on file access errors Patrick Georgi
2014-10-02 23:09   ` [PATCH 1/5] configure.ac: Don't search for c++ compiler Stephen Warren
2014-11-08 22:14   ` [PATCH 4/5 v2] set: check seek success Patrick Georgi
     [not found]     ` <545E95B1.5030703-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org>
2014-11-09  1:04       ` Thierry Reding
     [not found]         ` <14992150720.2771.879d79c6f3490faa837fa11cb97f42bf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-09  7:57           ` Patrick Georgi
2014-11-10  8:51       ` Thierry Reding [this message]
2014-11-10  9:08         ` Thierry Reding
2014-11-10 16:31         ` Stephen Warren
     [not found]           ` <5460E87B.1040209-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-11-17 11:32             ` Thierry Reding

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=20141110085102.GA12126@ulmo \
    --to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=patrick-U1IrdZU7gScKt1dFYRw6Gg@public.gmane.org \
    /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).