continue work with error messages, log_oom()
Adds messages for formally silent errors: new "Failed on cmdline argument %s: %s". Removes some specific error messages for -ENOMEM in mount-setup.c. A few specific ones have been left in other binaries.
This commit is contained in:
parent
8230e26dc9
commit
1421211924
2
TODO
2
TODO
|
@ -479,7 +479,7 @@ Regularly:
|
||||||
|
|
||||||
* Use PR_SET_PROCTITLE_AREA if it becomes available in the kernel
|
* Use PR_SET_PROCTITLE_AREA if it becomes available in the kernel
|
||||||
|
|
||||||
* %m in printf() instead of strerror();
|
* %m in printf() instead of strerror(errno);
|
||||||
|
|
||||||
* pahole
|
* pahole
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ static int delete_rule(const char *rule) {
|
||||||
assert(rule[0]);
|
assert(rule[0]);
|
||||||
|
|
||||||
if (!(x = strdup(rule)))
|
if (!(x = strdup(rule)))
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
e = strchrnul(x+1, x[0]);
|
e = strchrnul(x+1, x[0]);
|
||||||
*e = 0;
|
*e = 0;
|
||||||
|
@ -49,7 +49,7 @@ static int delete_rule(const char *rule) {
|
||||||
free(x);
|
free(x);
|
||||||
|
|
||||||
if (!fn)
|
if (!fn)
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
r = write_one_line_file(fn, "-1");
|
r = write_one_line_file(fn, "-1");
|
||||||
free(fn);
|
free(fn);
|
||||||
|
|
|
@ -782,5 +782,10 @@ finish:
|
||||||
group_hashmap_free(a);
|
group_hashmap_free(a);
|
||||||
group_hashmap_free(b);
|
group_hashmap_free(b);
|
||||||
|
|
||||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
if (r < 0) {
|
||||||
|
log_error("Exiting with failure: %s", strerror(-r));
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,12 +168,12 @@ _noreturn_ static void crash(int sig) {
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
log_error("Failed to fork off crash shell: %s", strerror(errno));
|
log_error("Failed to fork off crash shell: %m");
|
||||||
else if (pid == 0) {
|
else if (pid == 0) {
|
||||||
make_console_stdio();
|
make_console_stdio();
|
||||||
execl("/bin/sh", "/bin/sh", NULL);
|
execl("/bin/sh", "/bin/sh", NULL);
|
||||||
|
|
||||||
log_error("execl() failed: %s", strerror(errno));
|
log_error("execl() failed: %m");
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,12 +350,12 @@ static int parse_proc_cmdline_word(const char *word) {
|
||||||
if (!eq) {
|
if (!eq) {
|
||||||
r = unsetenv(cenv);
|
r = unsetenv(cenv);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_warning("unsetenv failed %s. Ignoring.", strerror(errno));
|
log_warning("unsetenv failed %m. Ignoring.");
|
||||||
} else {
|
} else {
|
||||||
*eq = 0;
|
*eq = 0;
|
||||||
r = setenv(cenv, eq + 1, 1);
|
r = setenv(cenv, eq + 1, 1);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_warning("setenv failed %s. Ignoring.", strerror(errno));
|
log_warning("setenv failed %m. Ignoring.");
|
||||||
}
|
}
|
||||||
free(cenv);
|
free(cenv);
|
||||||
|
|
||||||
|
@ -495,14 +495,14 @@ static int config_parse_cpu_affinity2(
|
||||||
unsigned cpu;
|
unsigned cpu;
|
||||||
|
|
||||||
if (!(t = strndup(w, l)))
|
if (!(t = strndup(w, l)))
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
r = safe_atou(t, &cpu);
|
r = safe_atou(t, &cpu);
|
||||||
free(t);
|
free(t);
|
||||||
|
|
||||||
if (!c)
|
if (!c)
|
||||||
if (!(c = cpu_set_malloc(&ncpus)))
|
if (!(c = cpu_set_malloc(&ncpus)))
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
if (r < 0 || cpu >= ncpus) {
|
if (r < 0 || cpu >= ncpus) {
|
||||||
log_error("[%s:%u] Failed to parse CPU affinity: %s", filename, line, rvalue);
|
log_error("[%s:%u] Failed to parse CPU affinity: %s", filename, line, rvalue);
|
||||||
|
@ -568,7 +568,7 @@ static int config_parse_join_controllers(
|
||||||
|
|
||||||
s = strndup(w, length);
|
s = strndup(w, length);
|
||||||
if (!s)
|
if (!s)
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
|
|
||||||
l = strv_split(s, ",");
|
l = strv_split(s, ",");
|
||||||
free(s);
|
free(s);
|
||||||
|
@ -584,7 +584,7 @@ static int config_parse_join_controllers(
|
||||||
arg_join_controllers = new(char**, 2);
|
arg_join_controllers = new(char**, 2);
|
||||||
if (!arg_join_controllers) {
|
if (!arg_join_controllers) {
|
||||||
strv_free(l);
|
strv_free(l);
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_join_controllers[0] = l;
|
arg_join_controllers[0] = l;
|
||||||
|
@ -598,7 +598,7 @@ static int config_parse_join_controllers(
|
||||||
t = new0(char**, n+2);
|
t = new0(char**, n+2);
|
||||||
if (!t) {
|
if (!t) {
|
||||||
strv_free(l);
|
strv_free(l);
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
}
|
}
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
|
@ -612,7 +612,7 @@ static int config_parse_join_controllers(
|
||||||
if (!c) {
|
if (!c) {
|
||||||
strv_free(l);
|
strv_free(l);
|
||||||
strv_free_free(t);
|
strv_free_free(t);
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
}
|
}
|
||||||
|
|
||||||
strv_free(l);
|
strv_free(l);
|
||||||
|
@ -624,7 +624,7 @@ static int config_parse_join_controllers(
|
||||||
if (!c) {
|
if (!c) {
|
||||||
strv_free(l);
|
strv_free(l);
|
||||||
strv_free_free(t);
|
strv_free_free(t);
|
||||||
return -ENOMEM;
|
return log_oom();
|
||||||
}
|
}
|
||||||
|
|
||||||
t[n++] = c;
|
t[n++] = c;
|
||||||
|
@ -729,8 +729,10 @@ static int parse_proc_cmdline(void) {
|
||||||
r = parse_proc_cmdline_word(word);
|
r = parse_proc_cmdline_word(word);
|
||||||
free(word);
|
free(word);
|
||||||
|
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
|
log_error("Failed on cmdline argument %s: %s", word, strerror(-r));
|
||||||
goto finish;
|
goto finish;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
|
@ -1017,8 +1019,10 @@ static int parse_argv(int argc, char *argv[]) {
|
||||||
* instead. */
|
* instead. */
|
||||||
|
|
||||||
for (a = argv; a < argv + argc; a++)
|
for (a = argv; a < argv + argc; a++)
|
||||||
if ((r = parse_proc_cmdline_word(*a)) < 0)
|
if ((r = parse_proc_cmdline_word(*a)) < 0) {
|
||||||
|
log_error("Failed on cmdline argument %s: %s", *a, strerror(-r));
|
||||||
return r;
|
return r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1293,8 +1297,10 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize default unit */
|
/* Initialize default unit */
|
||||||
if (set_default_unit(SPECIAL_DEFAULT_TARGET) < 0)
|
if (r == set_default_unit(SPECIAL_DEFAULT_TARGET) < 0) {
|
||||||
|
log_error("Failed to set default unit %s: %s", SPECIAL_DEFAULT_TARGET, strerror(-r));
|
||||||
goto finish;
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
/* By default, mount "cpu" and "cpuacct" together */
|
/* By default, mount "cpu" and "cpuacct" together */
|
||||||
arg_join_controllers = new(char**, 2);
|
arg_join_controllers = new(char**, 2);
|
||||||
|
|
|
@ -190,8 +190,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
|
||||||
|
|
||||||
controllers = set_new(string_hash_func, string_compare_func);
|
controllers = set_new(string_hash_func, string_compare_func);
|
||||||
if (!controllers) {
|
if (!controllers) {
|
||||||
r = -ENOMEM;
|
r = log_oom();
|
||||||
log_error("Failed to allocate controller set.");
|
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,9 +261,8 @@ int mount_cgroup_controllers(char ***join_controllers) {
|
||||||
|
|
||||||
options = strv_join(*k, ",");
|
options = strv_join(*k, ",");
|
||||||
if (!options) {
|
if (!options) {
|
||||||
log_error("Failed to join options");
|
|
||||||
free(controller);
|
free(controller);
|
||||||
r = -ENOMEM;
|
r = log_oom();
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,9 +273,8 @@ int mount_cgroup_controllers(char ***join_controllers) {
|
||||||
|
|
||||||
where = strappend("/sys/fs/cgroup/", options);
|
where = strappend("/sys/fs/cgroup/", options);
|
||||||
if (!where) {
|
if (!where) {
|
||||||
log_error("Failed to build path");
|
|
||||||
free(options);
|
free(options);
|
||||||
r = -ENOMEM;
|
r = log_oom();
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,8 +303,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
|
||||||
|
|
||||||
t = strappend("/sys/fs/cgroup/", *i);
|
t = strappend("/sys/fs/cgroup/", *i);
|
||||||
if (!t) {
|
if (!t) {
|
||||||
log_error("Failed to build path");
|
r = log_oom();
|
||||||
r = -ENOMEM;
|
|
||||||
free(options);
|
free(options);
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue