mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Peter Korsgaard <jacmet@sunsite.dk>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 04/11] memcpy cmd: Do not expect to read/write the whole chunk at once
Date: Fri, 25 Jun 2010 09:17:44 +0200	[thread overview]
Message-ID: <878w634m3r.fsf@macbook.be.48ers.dk> (raw)
In-Reply-To: <1277372356-32370-5-git-send-email-s.hauer@pengutronix.de> (Sascha Hauer's message of "Thu, 24 Jun 2010 11:39:09 +0200")

>>>>> "Sascha" == Sascha Hauer <s.hauer@pengutronix.de> writes:

Hi,

 Sascha> read() does not necessarily return the number of bytes
 Sascha> we want to read, so deal with less bytes.

 Sascha> -		if ((w = write(destfd, rw_buf, r)) < 0) {
 Sascha> -			perror("write");
 Sascha> -			goto out;
 Sascha> -		}
 Sascha> -
 Sascha> -		if (r < now)
 Sascha> +		if (!r)
 Sascha>  			break;
 
 Sascha> -		if (w < r)
 Sascha> -			break;
 Sascha> +		tmp = 0;
 Sascha> +		now = r;
 Sascha> +		while (now) {
 Sascha> +			w = write(destfd, rw_buf + tmp, now);
 Sascha> +			if (w < 0) {
 Sascha> +				perror("write");
 Sascha> +				goto out;
 Sascha> +			}
 Sascha> +	                if (!w)
 Sascha> +			        break;
 
 Sascha> -		count -= now;
 Sascha> +			now -= w;
 Sascha> +			tmp += w;
 Sascha> +		}
 Sascha> +

This is probably not the only place we need this. What about moving this
to a helper function like busybox' full_write()?

-- 
Bye, Peter Korsgaard

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

  reply	other threads:[~2010-06-25  7:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-24  9:39 assorted patches Sascha Hauer
2010-06-24  9:39 ` [PATCH 01/11] i.MX27: merge iomux pim definitions from kernel Sascha Hauer
2010-06-24  9:39 ` [PATCH 02/11] imxfb: Add board specific hook to enable display Sascha Hauer
2010-06-24  9:39 ` [PATCH 03/11] imxfb: do not enable framebuffer on startup Sascha Hauer
2010-06-24  9:39 ` [PATCH 04/11] memcpy cmd: Do not expect to read/write the whole chunk at once Sascha Hauer
2010-06-25  7:17   ` Peter Korsgaard [this message]
2010-06-28  8:37     ` Sascha Hauer
2010-06-24  9:39 ` [PATCH 05/11] armlinux: reorder tag setup Sascha Hauer
2010-06-24  9:39 ` [PATCH 06/11] remove eco920 board support Sascha Hauer
2010-06-24  9:39 ` [PATCH 07/11] usbnet: remove unused dev member in struct usbnet Sascha Hauer
2010-06-24  9:39 ` [PATCH 08/11] i.MX serial: Use readl/writel instead of pointer deref Sascha Hauer
2010-06-24  9:39 ` [PATCH 09/11] i.MX clocksource: " Sascha Hauer
2010-06-24  9:39 ` [PATCH 10/11] i.MX27: Add some missing device base addresses Sascha Hauer
2010-06-24  9:39 ` [PATCH 11/11] fb: add a usage counter to prevent double enable/disable Sascha Hauer
2010-06-24 15:05 ` assorted patches Eric Bénard

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=878w634m3r.fsf@macbook.be.48ers.dk \
    --to=jacmet@sunsite.dk \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@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