From 91da63d3d3fd680c805dd1a1b78df5b8731a8173 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 28 Mar 2015 15:41:58 +0100 Subject: properly handle return codes Signed-off-by: John Crispin --- plug/hotplug.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'plug') 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); -- cgit v1.2.3