mirror of
https://github.com/troglobit/finit.git
synced 2026-10-16 10:39:35 +00:00
Fix GCC warnings with _FORTIFY_SOURCE=2
- Decleare some return values with (void)fn(), for cases where we don't care (dropping table headers), or best effor - Check return value from fgets() and chdir() in some cases that are valid, i.e., continuing execution is pointless Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
774a24cdd8
commit
3ed291789c
5 files changed
+13
-10
No files matched your search
+1
-1
@@ -54,7 +54,7 @@ void cgroup_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Skip first line, header */
|
/* Skip first line, header */
|
||||||
fgets(buf, sizeof(buf), fp);
|
(void)fgets(buf, sizeof(buf), fp);
|
||||||
while (fgets(buf, sizeof(buf), fp)) {
|
while (fgets(buf, sizeof(buf), fp)) {
|
||||||
char *cgroup;
|
char *cgroup;
|
||||||
char rc[80];
|
char rc[80];
|
||||||
|
|||||||
+3
-3
@@ -432,14 +432,14 @@ void set_hostname(char **hostname)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fgets(*hostname, st.st_size, fp);
|
if (fgets(*hostname, st.st_size, fp))
|
||||||
chomp(*hostname);
|
chomp(*hostname);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (*hostname)
|
if (*hostname)
|
||||||
sethostname(*hostname, strlen(*hostname));
|
(void)sethostname(*hostname, strlen(*hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+4
-2
@@ -58,7 +58,9 @@ static void do_list(const char *path)
|
|||||||
glob_t gl;
|
glob_t gl;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
chdir(path);
|
if (chdir(path))
|
||||||
|
return;
|
||||||
|
|
||||||
if (glob("*.conf", 0, NULL, &gl))
|
if (glob("*.conf", 0, NULL, &gl))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -213,7 +215,7 @@ int do_disable(char *arg, int check)
|
|||||||
|
|
||||||
if (chdir(FINIT_RCSD))
|
if (chdir(FINIT_RCSD))
|
||||||
err(1, "failed cd %s", FINIT_RCSD);
|
err(1, "failed cd %s", FINIT_RCSD);
|
||||||
chdir("enabled"); /* System *may* have enabled/ dir. */
|
(void)chdir("enabled"); /* System *may* have enabled/ dir. */
|
||||||
|
|
||||||
if (check && stat(arg, &st))
|
if (check && stat(arg, &st))
|
||||||
errx(1, "%s not (an) enabled (service).", arg);
|
errx(1, "%s not (an) enabled (service).", arg);
|
||||||
|
|||||||
+4
-3
@@ -464,17 +464,18 @@ static int service_start(svc_t *svc)
|
|||||||
|
|
||||||
/* Set desired user+group */
|
/* Set desired user+group */
|
||||||
if (gid >= 0)
|
if (gid >= 0)
|
||||||
setgid(gid);
|
(void)setgid(gid);
|
||||||
|
|
||||||
if (uid >= 0) {
|
if (uid >= 0) {
|
||||||
setuid(uid);
|
(void)setuid(uid);
|
||||||
|
|
||||||
/* Set default path for regular users */
|
/* Set default path for regular users */
|
||||||
if (uid > 0)
|
if (uid > 0)
|
||||||
setenv("PATH", _PATH_DEFPATH, 1);
|
setenv("PATH", _PATH_DEFPATH, 1);
|
||||||
if (home) {
|
if (home) {
|
||||||
setenv("HOME", home, 1);
|
setenv("HOME", home, 1);
|
||||||
chdir(home);
|
if (chdir(home))
|
||||||
|
(void)chdir("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ static int logrotate(char *file, int num, off_t sz)
|
|||||||
(void)rename(file, nfile);
|
(void)rename(file, nfile);
|
||||||
create(file, st.st_mode, st.st_uid, st.st_gid);
|
create(file, st.st_mode, st.st_uid, st.st_gid);
|
||||||
} else {
|
} else {
|
||||||
truncate(file, 0);
|
(void)truncate(file, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user