[U-Boot] [patch] replace mkimage.c write() calls with full_write()

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).

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
participants (2)
-
Andrew Cann
-
Wolfgang Denk