summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-31 03:38:05 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-31 08:56:03 -0400
commit1e2fd62d70ff1a960551d28fce745847a9dbd3b7 (patch)
tree810ed4124d966e439c4bae8653ea6fae70a252a5 /src
parentb2fadec6048adb3596f2633cb7fe7a49f5937a18 (diff)
core/load-fragment.c: correct argument sign and split up long lines
With everything on one line they are just harder to read.
Diffstat (limited to 'src')
-rw-r--r--src/core/load-fragment.c144
-rw-r--r--src/shared/util.c2
2 files changed, 86 insertions, 60 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index d60e283229..fda27becb5 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -84,7 +84,7 @@ int config_parse_warn_compat(
}
#endif
-int config_parse_unit_deps(const char* unit,
+int config_parse_unit_deps(const char *unit,
const char *filename,
unsigned line,
const char *section,
@@ -1202,7 +1202,8 @@ int config_parse_exec_mount_flags(const char *unit,
else if (streq(word, "private"))
flags = MS_PRIVATE;
else {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse mount flag %s, ignoring: %s", t, rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Failed to parse mount flag %s, ignoring: %s", t, rvalue);
return 0;
}
}
@@ -1252,7 +1253,8 @@ int config_parse_exec_selinux_context(
r = unit_name_printf(u, rvalue, &k);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to resolve specifiers, ignoring: %s", strerror(-r));
+ log_syntax(unit, LOG_ERR, filename, line, -r,
+ "Failed to resolve specifiers, ignoring: %s", strerror(-r));
return 0;
}
@@ -1301,7 +1303,8 @@ int config_parse_exec_apparmor_profile(
r = unit_name_printf(u, rvalue, &k);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to resolve specifiers, ignoring: %s", strerror(-r));
+ log_syntax(unit, LOG_ERR, filename, line, -r,
+ "Failed to resolve specifiers, ignoring: %s", strerror(-r));
return 0;
}
@@ -1523,18 +1526,21 @@ int config_parse_socket_service(const char *unit,
r = unit_name_printf(UNIT(s), rvalue, &p);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to resolve specifiers, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, -r,
+ "Failed to resolve specifiers, ignoring: %s", rvalue);
return 0;
}
if (!endswith(p, ".service")) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Unit must be of type service, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Unit must be of type service, ignoring: %s", rvalue);
return 0;
}
r = manager_load_unit(UNIT(s)->manager, p, NULL, &error, &x);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load unit %s, ignoring: %s", rvalue, bus_error_message(&error, r));
+ log_syntax(unit, LOG_ERR, filename, line, -r,
+ "Failed to load unit %s, ignoring: %s", rvalue, bus_error_message(&error, r));
return 0;
}
@@ -1657,18 +1663,21 @@ int config_parse_busname_service(
r = unit_name_printf(UNIT(n), rvalue, &p);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -r, "Failed to resolve specifiers, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, -r,
+ "Failed to resolve specifiers, ignoring: %s", rvalue);
return 0;
}
if (!endswith(p, ".service")) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Unit must be of type service, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Unit must be of type service, ignoring: %s", rvalue);
return 0;
}
r = manager_load_unit(UNIT(n)->manager, p, NULL, &error, &x);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r, "Failed to load unit %s, ignoring: %s", rvalue, bus_error_message(&error, r));
+ log_syntax(unit, LOG_ERR, filename, line, -r,
+ "Failed to load unit %s, ignoring: %s", rvalue, bus_error_message(&error, r));
return 0;
}
@@ -1718,7 +1727,8 @@ int config_parse_bus_policy(
access_str = strpbrk(id_str, WHITESPACE);
if (!access_str) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Invalid busname policy value '%s'", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Invalid busname policy value '%s'", rvalue);
return 0;
}
@@ -1728,7 +1738,8 @@ int config_parse_bus_policy(
p->access = busname_policy_access_from_string(access_str);
if (p->access < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Invalid busname policy access type '%s'", access_str);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Invalid busname policy access type '%s'", access_str);
return 0;
}
@@ -1772,7 +1783,7 @@ int config_parse_unit_env_file(const char *unit,
r = unit_full_printf(u, rvalue, &n);
if (r < 0)
- log_syntax(unit, LOG_ERR, filename, line, r,
+ log_syntax(unit, LOG_ERR, filename, line, -r,
"Failed to resolve specifiers, ignoring: %s", rvalue);
s = n ?: rvalue;
@@ -2100,7 +2111,7 @@ int config_parse_unit_requires_mounts_for(
r = unit_require_mounts_for(u, n);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, r,
+ log_syntax(unit, LOG_ERR, filename, line, -r,
"Failed to add required mount for, ignoring: %s", rvalue);
continue;
}
@@ -2246,7 +2257,8 @@ int config_parse_syscall_filter(
id = seccomp_syscall_resolve_name(t);
if (id < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse system call, ignoring: %s", t);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Failed to parse system call, ignoring: %s", t);
continue;
}
@@ -2311,7 +2323,8 @@ int config_parse_syscall_archs(
r = seccomp_arch_from_string(t, &a);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse system call architecture, ignoring: %s", t);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Failed to parse system call architecture, ignoring: %s", t);
continue;
}
@@ -2355,7 +2368,8 @@ int config_parse_syscall_errno(
e = errno_from_name(rvalue);
if (e < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse error number, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Failed to parse error number, ignoring: %s", rvalue);
return 0;
}
@@ -2418,7 +2432,8 @@ int config_parse_address_families(
af = af_from_name(t);
if (af <= 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse address family, ignoring: %s", t);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Failed to parse address family, ignoring: %s", t);
continue;
}
@@ -2518,7 +2533,8 @@ int config_parse_cpu_shares(
r = safe_atolu(rvalue, &lu);
if (r < 0 || lu <= 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU shares '%s' invalid. Ignoring.", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "CPU shares '%s' invalid. Ignoring.", rvalue);
return 0;
}
@@ -2552,12 +2568,14 @@ int config_parse_cpu_quota(
if (!endswith(rvalue, "%")) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' not ending in '%%'. Ignoring.", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "CPU quota '%s' not ending in '%%'. Ignoring.", rvalue);
return 0;
}
if (sscanf(rvalue, "%lf%%", &percent) != 1 || percent <= 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "CPU quota '%s' invalid. Ignoring.", rvalue);
return 0;
}
@@ -2591,7 +2609,8 @@ int config_parse_memory_limit(
r = parse_size(rvalue, 1024, &bytes);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Memory limit '%s' invalid. Ignoring.", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Memory limit '%s' invalid. Ignoring.", rvalue);
return 0;
}
@@ -2632,7 +2651,8 @@ int config_parse_device_allow(
if (!startswith(path, "/dev/") &&
!startswith(path, "block-") &&
!startswith(path, "char-")) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Invalid device node path '%s'. Ignoring.", path);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Invalid device node path '%s'. Ignoring.", path);
return 0;
}
@@ -2641,7 +2661,8 @@ int config_parse_device_allow(
m = "rwm";
if (!in_charset(m, "rwm")) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Invalid device rights '%s'. Ignoring.", m);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Invalid device rights '%s'. Ignoring.", m);
return 0;
}
@@ -2685,7 +2706,8 @@ int config_parse_blockio_weight(
r = safe_atolu(rvalue, &lu);
if (r < 0 || lu < 10 || lu > 1000) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Block IO weight '%s' invalid. Ignoring.", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Block IO weight '%s' invalid. Ignoring.", rvalue);
return 0;
}
@@ -2727,7 +2749,8 @@ int config_parse_blockio_device_weight(
n = strcspn(rvalue, WHITESPACE);
weight = rvalue + n;
if (!*weight) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Expected block device and device weight. Ignoring.");
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Expected block device and device weight. Ignoring.");
return 0;
}
@@ -2736,14 +2759,16 @@ int config_parse_blockio_device_weight(
return log_oom();
if (!path_startswith(path, "/dev")) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Invalid device node path '%s'. Ignoring.", path);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Invalid device node path '%s'. Ignoring.", path);
return 0;
}
weight += strspn(weight, WHITESPACE);
r = safe_atolu(weight, &lu);
if (r < 0 || lu < 10 || lu > 1000) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Block IO weight '%s' invalid. Ignoring.", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Block IO weight '%s' invalid. Ignoring.", rvalue);
return 0;
}
@@ -2819,7 +2844,8 @@ int config_parse_blockio_bandwidth(
r = parse_size(bandwidth, 1000, &bytes);
if (r < 0 || bytes <= 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Block IO Bandwidth '%s' invalid. Ignoring.", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Block IO Bandwidth '%s' invalid. Ignoring.", rvalue);
return 0;
}
@@ -2860,7 +2886,8 @@ int config_parse_job_mode_isolate(
r = parse_boolean(rvalue);
if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Failed to parse boolean, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Failed to parse boolean, ignoring: %s", rvalue);
return 0;
}
@@ -2935,7 +2962,8 @@ int config_parse_runtime_directory(
return log_oom();
if (!filename_is_safe(n)) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Runtime directory is not valid, ignoring assignment: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Runtime directory is not valid, ignoring assignment: %s", rvalue);
continue;
}
@@ -2992,35 +3020,29 @@ int config_parse_set_status(
if (r < 0) {
val = signal_from_string_try_harder(temp);
- if (val > 0) {
- r = set_ensure_allocated(&status_set->signal, NULL, NULL);
- if (r < 0)
- return log_oom();
-
- r = set_put(status_set->signal, INT_TO_PTR(val));
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -r, "Unable to store: %s", word);
- return r;
- }
- } else {
- log_syntax(unit, LOG_ERR, filename, line, -val, "Failed to parse value, ignoring: %s", word);
+ if (val <= 0) {
+ log_syntax(unit, LOG_ERR, filename, line, -val,
+ "Failed to parse value, ignoring: %s", word);
return 0;
}
} else {
- if (val < 0 || val > 255)
- log_syntax(unit, LOG_ERR, filename, line, ERANGE, "Value %d is outside range 0-255, ignoring", val);
- else {
- r = set_ensure_allocated(&status_set->status, NULL, NULL);
- if (r < 0)
- return log_oom();
-
- r = set_put(status_set->status, INT_TO_PTR(val));
- if (r < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -r, "Unable to store: %s", word);
- return r;
- }
+ if (val < 0 || val > 255) {
+ log_syntax(unit, LOG_ERR, filename, line, ERANGE,
+ "Value %d is outside range 0-255, ignoring", val);
+ continue;
}
}
+
+ r = set_ensure_allocated(&status_set->status, NULL, NULL);
+ if (r < 0)
+ return log_oom();
+
+ r = set_put(status_set->status, INT_TO_PTR(val));
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, -r,
+ "Unable to store: %s", word);
+ return r;
+ }
}
if (!isempty(state))
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
@@ -3073,7 +3095,8 @@ int config_parse_namespace_path_strv(
offset = n[0] == '-';
if (!path_is_absolute(n + offset)) {
- log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Not an absolute path, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Not an absolute path, ignoring: %s", rvalue);
continue;
}
@@ -3114,7 +3137,8 @@ int config_parse_no_new_privileges(
k = parse_boolean(rvalue);
if (k < 0) {
- log_syntax(unit, LOG_ERR, filename, line, -k, "Failed to parse boolean value, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, -k,
+ "Failed to parse boolean value, ignoring: %s", rvalue);
return 0;
}
@@ -3157,7 +3181,8 @@ int config_parse_protect_home(
h = protect_home_from_string(rvalue);
if (h < 0){
- log_syntax(unit, LOG_ERR, filename, line, -h, "Failed to parse protect home value, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, -h,
+ "Failed to parse protect home value, ignoring: %s", rvalue);
return 0;
}
@@ -3200,7 +3225,8 @@ int config_parse_protect_system(
s = protect_system_from_string(rvalue);
if (s < 0){
- log_syntax(unit, LOG_ERR, filename, line, -s, "Failed to parse protect system value, ignoring: %s", rvalue);
+ log_syntax(unit, LOG_ERR, filename, line, -s,
+ "Failed to parse protect system value, ignoring: %s", rvalue);
return 0;
}
diff --git a/src/shared/util.c b/src/shared/util.c
index 76cee19261..4c30a98318 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1230,7 +1230,7 @@ char *cunescape_length_with_prefix(const char *s, size_t length, const char *pre
r = new(char, pl+length+1);
if (!r)
- return r;
+ return NULL;
if (prefix)
memcpy(r, prefix, pl);