public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [patch] replace mkimage.c write() calls with full_write()
@ 2014-03-20  3:44 Andrew Cann
  2014-03-20 10:35 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cann @ 2014-03-20  3:44 UTC (permalink / raw)
  To: u-boot

This patch adds a function to mkimage.c called full_write() which calls write()
in a loop until all the data has been written or write errors.

I was getting an error with mkimage running out of space on the device it was
writing to, but instead of printing a useful error message it was printing:

    mkimage: Write error on /tmp/flash.img: Success

Which is kinda confusing. It was printing this because write() was writing as
many bytes as it could and then returning success. It needs to be called a
second time to set errno. Also write(fd, data, count) isn't guranteed to write
the full count bytes in one go anyway, so it needs to be called in a loop (that
or use fwrite instead).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: u-boot-mkimage.patch
Type: text/x-diff
Size: 2454 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140320/f008d933/attachment.patch>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [U-Boot] [patch] replace mkimage.c write() calls with full_write()
  2014-03-20  3:44 [U-Boot] [patch] replace mkimage.c write() calls with full_write() Andrew Cann
@ 2014-03-20 10:35 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2014-03-20 10:35 UTC (permalink / raw)
  To: u-boot

Dear Andrew,

In message <20140320034408.GA20976@canndrew.org> you wrote:
> 
> This patch adds a function to mkimage.c called full_write() which calls write()
> in a loop until all the data has been written or write errors.
> 
> I was getting an error with mkimage running out of space on the device it was
> writing to, but instead of printing a useful error message it was printing:

I think your patch itself it OK, but please see [1] for proper coding
style and other patch submission requirements, like adding a commit
message and a sSigne-off-by: line.  also make sure to run your patch
through checkpatch.pl before submission - as is I get this:

ERROR: open brace '{' following function declarations go on the next line
#114: FILE: tools/mkimage.c:32:
+static ssize_t full_write(int fd, const void *buf, size_t count) {

ERROR: space required before the open parenthesis '('
#116: FILE: tools/mkimage.c:34:
+	for(;;) {

ERROR: space required before the open parenthesis '('
#119: FILE: tools/mkimage.c:37:
+		if(written < 0)

ERROR: space required before the open parenthesis '('
#123: FILE: tools/mkimage.c:41:
+		if(remaining <= 0)

WARNING: line over 80 characters
#147: FILE: tools/mkimage.c:430:
+				bytes_written = full_write(ifd, (char *)&size, sizeof(size));

ERROR: Missing Signed-off-by: line(s)

total: 5 errors, 1 warnings, 70 lines checked


Thanks.


[1] http://www.denx.de/wiki/view/U-Boot/Patches#General_Patch_Submission_Rules


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
"The number  of  Unix  installations  has  grown  to  10,  with  more
expected."    - The Unix Programmer's Manual, 2nd Edition, June, 1972

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-20 10:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-20  3:44 [U-Boot] [patch] replace mkimage.c write() calls with full_write() Andrew Cann
2014-03-20 10:35 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox