diff options
author | John Crispin <blogic@openwrt.org> | 2015-03-28 15:41:58 +0100 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2015-03-28 18:35:21 +0100 |
commit | 91da63d3d3fd680c805dd1a1b78df5b8731a8173 (patch) | |
tree | ec9a568a398ae536ccf7ac89a23942a60ef25c98 /plug | |
parent | 74d835463e05e5761f6f5271e487f299f29d3f07 (diff) | |
download | unitd-91da63d3d3fd680c805dd1a1b78df5b8731a8173.tar unitd-91da63d3d3fd680c805dd1a1b78df5b8731a8173.zip |
properly handle return codes
Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'plug')
-rw-r--r-- | plug/hotplug.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/plug/hotplug.c b/plug/hotplug.c index 6df7971..1a98e8b 100644 --- a/plug/hotplug.c +++ b/plug/hotplug.c @@ -198,7 +198,10 @@ send_to_kernel: ERROR("Failed to open %s\n", loadpath); exit(-1); } - write(load, "1", 1); + if (write(load, "1", 1) == -1) { + ERROR("Failed to write to %s\n", loadpath); + exit(-1); + } close(load); snprintf(syspath, sizeof(syspath), "/sys/%s/data", dev); @@ -214,7 +217,10 @@ send_to_kernel: if (len <= 0) break; - write(fw, buf, len); + if (write(fw, buf, len) == -1) { + ERROR("failed to write firmware file %s/%s to %s\n", dir, file, dev); + break; + } } if (src >= 0) @@ -222,7 +228,8 @@ send_to_kernel: close(fw); load = open(loadpath, O_WRONLY); - write(load, "0", 1); + if (write(load, "0", 1) == -1) + ERROR("failed to write to %s\n", loadpath); close(load); DEBUG(2, "Done loading %s\n", path); |