mirror of
https://github.com/systemd/systemd
synced 2024-10-15 04:24:19 +00:00
core/load-fragment: fix error value in log_syntax()
`extract_first_word()` may return positive value on success.
This commit is contained in:
parent
0d6217efc1
commit
6a35d52d78
|
@ -4211,11 +4211,16 @@ int config_parse_io_device_weight(
|
||||||
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
if (r <= 0 || isempty(p)) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||||
"Failed to extract device path and weight from '%s', ignoring.", rvalue);
|
"Failed to extract device path and weight from '%s', ignoring.", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (r == 0 || isempty(p)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
|
"Invalid device path or weight specified in '%s', ignoring.", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
r = unit_path_printf(userdata, path, &resolved);
|
r = unit_path_printf(userdata, path, &resolved);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -4280,11 +4285,16 @@ int config_parse_io_device_latency(
|
||||||
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
if (r <= 0 || isempty(p)) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||||
"Failed to extract device path and latency from '%s', ignoring.", rvalue);
|
"Failed to extract device path and latency from '%s', ignoring.", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (r == 0 || isempty(p)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
|
"Invalid device path or latency specified in '%s', ignoring.", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
r = unit_path_printf(userdata, path, &resolved);
|
r = unit_path_printf(userdata, path, &resolved);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -4350,11 +4360,16 @@ int config_parse_io_limit(
|
||||||
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
if (r <= 0 || isempty(p)) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||||
"Failed to extract device node and bandwidth from '%s', ignoring.", rvalue);
|
"Failed to extract device node and bandwidth from '%s', ignoring.", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (r == 0 || isempty(p)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
|
"Invalid device node or bandwidth specified in '%s', ignoring.", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
r = unit_path_printf(userdata, path, &resolved);
|
r = unit_path_printf(userdata, path, &resolved);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -4435,11 +4450,16 @@ int config_parse_blockio_device_weight(
|
||||||
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
if (r <= 0 || isempty(p)) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||||
"Failed to extract device node and weight from '%s', ignoring.", rvalue);
|
"Failed to extract device node and weight from '%s', ignoring.", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (r == 0 || isempty(p)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
|
"Invalid device node or weight specified in '%s', ignoring.", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
r = unit_path_printf(userdata, path, &resolved);
|
r = unit_path_printf(userdata, path, &resolved);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -4508,11 +4528,16 @@ int config_parse_blockio_bandwidth(
|
||||||
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
if (r <= 0 || isempty(p)) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||||
"Failed to extract device node and bandwidth from '%s', ignoring.", rvalue);
|
"Failed to extract device node and bandwidth from '%s', ignoring.", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (r == 0 || isempty(p)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
|
"Invalid device node or bandwidth specified in '%s', ignoring.", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
r = unit_path_printf(userdata, path, &resolved);
|
r = unit_path_printf(userdata, path, &resolved);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -4728,8 +4753,12 @@ int config_parse_set_credential(
|
||||||
r = extract_first_word(&p, &word, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
|
r = extract_first_word(&p, &word, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
if (r <= 0 || !p) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract credential name, ignoring: %s", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (r == 0 || isempty(p)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid syntax, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5208,7 +5237,7 @@ int config_parse_bind_paths(
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s: %s", lvalue, rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s=, ignoring: %s", lvalue, rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5858,6 +5887,7 @@ int config_parse_bpf_foreign_program(
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
_cleanup_free_ char *resolved = NULL, *word = NULL;
|
_cleanup_free_ char *resolved = NULL, *word = NULL;
|
||||||
CGroupContext *c = data;
|
CGroupContext *c = data;
|
||||||
|
const char *p = rvalue;
|
||||||
Unit *u = userdata;
|
Unit *u = userdata;
|
||||||
int attach_type, r;
|
int attach_type, r;
|
||||||
|
|
||||||
|
@ -5872,13 +5902,17 @@ int config_parse_bpf_foreign_program(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = extract_first_word(&rvalue, &word, ":", 0);
|
r = extract_first_word(&p, &word, ":", 0);
|
||||||
if (r == -ENOMEM)
|
if (r == -ENOMEM)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
if (r <= 0 || isempty(rvalue)) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse foreign BPF program, ignoring: %s", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse foreign BPF program, ignoring: %s", rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (r == 0 || isempty(p)) {
|
||||||
|
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid syntax in %s=, ignoring: %s", lvalue, rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
attach_type = bpf_cgroup_attach_type_from_string(word);
|
attach_type = bpf_cgroup_attach_type_from_string(word);
|
||||||
if (attach_type < 0) {
|
if (attach_type < 0) {
|
||||||
|
@ -5886,9 +5920,9 @@ int config_parse_bpf_foreign_program(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = unit_path_printf(u, rvalue, &resolved);
|
r = unit_path_printf(u, p, &resolved);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %m", rvalue);
|
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to resolve unit specifiers in '%s', ignoring: %s", p, rvalue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue