Fix GCC warnings for unhandled return value

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-18 12:24:32 +02:00
parent 23a13fe1b6
commit be5ec94fdf
2 changed files with 16 additions and 8 deletions
+6 -3
View File
@@ -462,7 +462,8 @@ int mksubsys(const char *dir, mode_t mode, char *user, char *group)
gid = 0;
rc = makedir(dir, mode);
(void)chown(dir, uid, gid);
if (chown(dir, uid, gid))
_pe("Failed chown(%s, %d, %d)", dir, uid, gid);
}
umask(omask);
@@ -498,8 +499,10 @@ void set_hostname(char **hostname)
}
done:
if (*hostname)
(void)sethostname(*hostname, strlen(*hostname));
if (*hostname) {
if (sethostname(*hostname, strlen(*hostname)))
_pe("Failed sethostnaem(%s)", *hostname);
}
}
/*
+10 -5
View File
@@ -402,19 +402,24 @@ static pid_t service_fork(svc_t *svc)
}
/* Set desired user+group */
if (gid >= 0)
(void)setgid(gid);
if (gid >= 0) {
if (setgid(gid))
_pe("%s: failed setgid(%d)", svc->cmd, gid);
}
if (uid >= 0) {
(void)setuid(uid);
if (setuid(uid))
_pe("%s: failed setuid(%d)", svc->cmd, uid);
/* Set default path for regular users */
if (uid > 0)
setenv("PATH", _PATH_DEFPATH, 1);
if (home) {
setenv("HOME", home, 1);
if (chdir(home))
(void)chdir("/");
if (chdir(home)) {
if (chdir("/"))
_pe("%s: failed chdir(%s) and chdir(/)", svc->cmd, home);
}
}
}