mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 18:47:22 +00:00
[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>
This commit is contained in:
parent
dc9b4ebfc9
commit
f2780c5d86
24
lib/helper.c
24
lib/helper.c
@ -823,6 +823,7 @@ ipmi_start_daemon(struct ipmi_intf *intf)
|
|||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int fd;
|
int fd;
|
||||||
|
int ret;
|
||||||
#ifdef SIGHUP
|
#ifdef SIGHUP
|
||||||
sigset_t sighup;
|
sigset_t sighup;
|
||||||
#endif
|
#endif
|
||||||
@ -866,7 +867,11 @@ ipmi_start_daemon(struct ipmi_intf *intf)
|
|||||||
exit(0);
|
exit(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
chdir("/");
|
ret = chdir("/");
|
||||||
|
if (ret) {
|
||||||
|
lprintf(LOG_ERR, "chdir failed: %s (%d)", strerror(errno), errno);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
umask(0);
|
umask(0);
|
||||||
|
|
||||||
for (fd=0; fd<64; fd++) {
|
for (fd=0; fd<64; fd++) {
|
||||||
@ -875,9 +880,20 @@ ipmi_start_daemon(struct ipmi_intf *intf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fd = open("/dev/null", O_RDWR);
|
fd = open("/dev/null", O_RDWR);
|
||||||
assert(0 == fd);
|
if (fd != STDIN_FILENO) {
|
||||||
dup(fd);
|
lprintf(LOG_ERR, "failed to reset stdin: %s (%d)", strerror(errno), errno);
|
||||||
dup(fd);
|
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
|
/* eval_ccode - evaluate return value of _ipmi_* functions and print error error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user