replace mkimage.c write() calls with full_write()
PATCH 1/1 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).
-------------- 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>
PATCH 1/1 replace mkimage.c write() calls with full_write()
Dear Andrew,
Quoted 6 lines · In message <[email protected]> you wrote:
This patch adds a function to
mkimage.ccalledfull_write()which callswrite()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
Signature · 5 lines
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: [email protected] "The number of Unix installations has grown to 10, with more expected." - The Unix Programmer's Manual, 2nd Edition, June, 1972