Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Unified Diff: data_layout.c

Issue 6368153: Check return code of fwrite in raw image writing code. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cbootimage.git@master
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: data_layout.c
diff --git a/data_layout.c b/data_layout.c
index 3c49f9f20b7d98b4b3277bd8f92726c4792bebf9..1e38b0ff6cd7cc835dd3c90e3710363ac98a0526 100644
--- a/data_layout.c
+++ b/data_layout.c
@@ -1017,9 +1017,12 @@ write_block_raw(build_image_context *context)
data = empty_blk;
}
/* Write the data */
- fwrite(data, 1,
- pages_to_write * context->page_size,
- context->raw_file);
+ {
Micah C 2011/02/08 03:52:46 What is the need for this extra indentation and en
robotboy 2011/02/08 18:48:00 ANSI C doesn't allow for the declaration of a vari
+ size_t bytes = pages_to_write * context->page_size;
Micah C 2011/02/08 03:52:46 The \t after size_t bytes might be replaceable wit
robotboy 2011/02/08 18:48:00 Done.
+
+ if (fwrite(data, 1, bytes, context->raw_file) != bytes)
+ return -1;
Micah C 2011/02/08 03:52:46 Another error exit from this function returns a ne
robotboy 2011/02/08 18:48:00 I believe that the correct thing to do is check bo
+ }
}
free(empty_blk);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698