diff options
author | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-11-09 14:45:58 +1100 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> | 2015-12-17 14:51:46 +1100 |
commit | eea8cf830616dbbd9024b7d704cf0ccf2dac4767 (patch) | |
tree | a2eae11b0af3de7c71d74d7acac9952b485c6f3e | |
parent | 0dae90626e54e46372c9feddc2f9ac82f046547d (diff) | |
download | petitboot-eea8cf830616dbbd9024b7d704cf0ccf2dac4767.zip petitboot-eea8cf830616dbbd9024b7d704cf0ccf2dac4767.tar.gz |
discover: Properly handle return values
Fixes three unchecked return values, and one missing
initialisation.
Fixes Coverity defects #30450, #30451, #30454, and #30483
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
-rw-r--r-- | discover/device-handler.c | 6 | ||||
-rw-r--r-- | discover/ipmi.c | 3 | ||||
-rw-r--r-- | discover/paths.c | 5 | ||||
-rw-r--r-- | discover/platform-powerpc.c | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c index bfe5fff..3804b34 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -1472,7 +1472,6 @@ mount_ro: void device_release_write(struct discover_device *dev, bool release) { const char *fstype, *device_path; - int rc = 0; if (!release) return; @@ -1495,10 +1494,9 @@ void device_release_write(struct discover_device *dev, bool release) device_path = get_device_path(dev); } - mount(device_path, dev->mount_path, fstype, + if (mount(device_path, dev->mount_path, fstype, MS_RDONLY | MS_SILENT, - fs_parameters(dev, MS_RDONLY)); - if (rc) + fs_parameters(dev, MS_RDONLY))) pb_log("Failed to remount %s read-only: %s\n", device_path, strerror(errno)); else diff --git a/discover/ipmi.c b/discover/ipmi.c index 54d4e06..f59974a 100644 --- a/discover/ipmi.c +++ b/discover/ipmi.c @@ -183,7 +183,8 @@ int ipmi_transaction(struct ipmi *ipmi, uint8_t netfn, uint8_t cmd, out: lock.l_type = F_UNLCK; - fcntl(ipmi->fd, F_SETLKW, &lock); + if (fcntl(ipmi->fd, F_SETLKW, &lock) == -1) + pb_log("IPMI: error unlocking IPMI device: %m\n"); return rc ? -1 : 0; } diff --git a/discover/paths.c b/discover/paths.c index 0d414eb..c25671b 100644 --- a/discover/paths.c +++ b/discover/paths.c @@ -220,15 +220,16 @@ static enum tftp_type check_tftp_type(void *ctx) const char *argv[] = { pb_system_apps.tftp, "-V", NULL }; struct process *process; enum tftp_type type; + int rc; process = process_create(ctx); process->path = pb_system_apps.tftp; process->argv = argv; process->keep_stdout = true; process->add_stderr = true; - process_run_sync(process); + rc = process_run_sync(process); - if (!process->stdout_buf || process->stdout_len == 0) { + if (rc || !process->stdout_buf || process->stdout_len == 0) { pb_log("Can't check TFTP client type!\n"); type = TFTP_TYPE_BROKEN; diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c index 2807934..ce4eb81 100644 --- a/discover/platform-powerpc.c +++ b/discover/platform-powerpc.c @@ -179,7 +179,7 @@ static int write_nvram(struct platform_powerpc *platform) struct process *process; struct param *param; const char *argv[6]; - int rc; + int rc = 0; argv[0] = "nvram"; argv[1] = "--update-config"; |