mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] memcmp: fix comparison on short read
Date: Thu, 2 Mar 2017 08:40:09 +0100	[thread overview]
Message-ID: <20170302074009.skcah6klu3kxzwqe@pengutronix.de> (raw)
In-Reply-To: <20170301145004.27750-1-u.kleine-koenig@pengutronix.de>

On Wed, Mar 01, 2017 at 03:50:04PM +0100, Uwe Kleine-König wrote:
> read() might return less than $count bytes which is only an upper limit.
> The user is supposed to repeat the command to fill a buffer completely.
> 
> So use the convenience wrapper read_full in memcmp.
> 
> This fixes memcmp on /dev/nand0 on an Armada XP.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  commands/memcmp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/commands/memcmp.c b/commands/memcmp.c
> index ce044df0d935..a00fddbc825f 100644
> --- a/commands/memcmp.c
> +++ b/commands/memcmp.c
> @@ -91,13 +91,13 @@ static int do_memcmp(int argc, char *argv[])
>  
>  		now = min((loff_t)RW_BUF_SIZE, count);
>  
> -		r1 = read(sourcefd, mem_rw_buf,  now);
> +		r1 = read_full(sourcefd, mem_rw_buf, now);
>  		if (r1 < 0) {
>  			perror("read");
>  			goto out;
>  		}
>  
> -		r2 = read(destfd, rw_buf1, now);
> +		r2 = read_full(destfd, rw_buf1, now);
>  		if (r2 < 0) {
>  			perror("read");
>  			goto out;
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2017-03-02  7:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-01 14:50 Uwe Kleine-König
2017-03-02  7:40 ` Sascha Hauer [this message]

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=20170302074009.skcah6klu3kxzwqe@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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