summaryrefslogtreecommitdiff
path: root/flattree.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2008-11-07 11:41:11 +1100
committerJon Loeliger <jdl@jdl.com>2008-11-17 14:04:35 -0600
commit0783d7e705f2d73f7148d9f45c600c2587b3c3ce (patch)
tree407bd4688e82e80376b3bf2a696687945d956880 /flattree.c
parentf99cd158a9f0b67d3935a08a07dab4f36719fc74 (diff)
downloaddtc-0783d7e705f2d73f7148d9f45c600c2587b3c3ce.tar.gz
dtc: Check return value from fwrite()
There's one place in flattree.c where we currently ignore the return value from fwrite(). On some gcc/glibc versions, where fwrite() is declared with attribute warn_unused_result, this causes a warning. This patch fixes the warning, by checking the fwrite() result. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'flattree.c')
-rw-r--r--flattree.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/flattree.c b/flattree.c
index 50190b8..9197511 100644
--- a/flattree.c
+++ b/flattree.c
@@ -413,10 +413,13 @@ void dt_to_blob(FILE *f, struct boot_info *bi, int version)
if (padlen > 0)
blob = data_append_zeroes(blob, padlen);
- fwrite(blob.val, blob.len, 1, f);
-
- if (ferror(f))
- die("Error writing device tree blob: %s\n", strerror(errno));
+ if (fwrite(blob.val, blob.len, 1, f) != 1) {
+ if (ferror(f))
+ die("Error writing device tree blob: %s\n",
+ strerror(errno));
+ else
+ die("Short write on device tree blob\n");
+ }
/*
* data_merge() frees the right-hand element so only the blob