summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@intel.com>2018-10-31 13:38:03 -0700
committerAlexander Amelkin <mocbuhtig@amelkin.msk.ru>2018-11-11 14:55:43 +0300
commitf2780c5d8611c428b8ce21a0986a5caf2346fd16 (patch)
tree3aea60882342783da138105901f9ba2eaef4aa63 /lib
parentdc9b4ebfc9a5b29d6f88ec8916acc454f9eba662 (diff)
downloadipmitool-f2780c5d8611c428b8ce21a0986a5caf2346fd16.tar.gz
[compiler-warnings-fixes] ipmi_start_daemon: check return values
Some return values were being ignored in ipmi_start_daemon. This adds checks to the values and changes some hard-coded numbers into named values. Partially resolves ipmitool/ipmitool#13 Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/helper.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/helper.c b/lib/helper.c
index 1d08531..f19fbce 100644
--- a/lib/helper.c
+++ b/lib/helper.c
@@ -823,6 +823,7 @@ ipmi_start_daemon(struct ipmi_intf *intf)
{
pid_t pid;
int fd;
+ int ret;
#ifdef SIGHUP
sigset_t sighup;
#endif
@@ -866,7 +867,11 @@ ipmi_start_daemon(struct ipmi_intf *intf)
exit(0);
#endif
- chdir("/");
+ ret = chdir("/");
+ if (ret) {
+ lprintf(LOG_ERR, "chdir failed: %s (%d)", strerror(errno), errno);
+ exit(1);
+ }
umask(0);
for (fd=0; fd<64; fd++) {
@@ -875,9 +880,20 @@ ipmi_start_daemon(struct ipmi_intf *intf)
}
fd = open("/dev/null", O_RDWR);
- assert(0 == fd);
- dup(fd);
- dup(fd);
+ if (fd != STDIN_FILENO) {
+ lprintf(LOG_ERR, "failed to reset stdin: %s (%d)", strerror(errno), errno);
+ exit(1);
+ }
+ ret = dup(fd);
+ if (ret != STDOUT_FILENO) {
+ lprintf(LOG_ERR, "failed to reset stdout: %s (%d)", strerror(errno), errno);
+ exit(1);
+ }
+ ret = dup(fd);
+ if (ret != STDOUT_FILENO) {
+ lprintf(LOG_ERR, "failed to reset stderr: %s (%d)", strerror(errno), errno);
+ exit(1);
+ }
}
/* eval_ccode - evaluate return value of _ipmi_* functions and print error error