summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-08-05 11:17:08 +0200
committerLennart Poettering <lennart@poettering.net>2016-08-05 11:18:32 +0200
commit41bf0590cc89438f1d319465190b1c00809c78fe (patch)
tree58d255848f99af24009cea575d4d58ec53d6874d /src/shared
parent1ed1f50f8277df07918e13cba3331a114eaa6fe3 (diff)
util-lib: unify parsing of nice level values
This adds parse_nice() that parses a nice level and ensures it is in the right range, via a new nice_is_valid() helper. It then ports over a number of users to this. No functional changes.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-unit-util.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index 589f9d46e9..c3a5233532 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -366,15 +366,13 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
}
} else if (streq(field, "Nice")) {
- int32_t i;
+ int n;
- r = safe_atoi32(eq, &i);
- if (r < 0) {
- log_error("Failed to parse %s value %s.", field, eq);
- return -EINVAL;
- }
+ r = parse_nice(eq, &n);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse nice value: %s", eq);
- r = sd_bus_message_append(m, "v", "i", i);
+ r = sd_bus_message_append(m, "v", "i", (int32_t) n);
} else if (STR_IN_SET(field, "Environment", "PassEnvironment")) {
const char *p;