chiark / gitweb /
Prep v232: Apply missing updates from upstream
[elogind.git] / src / basic / parse-util.c
index 757e5b4127041f0de12136b0600702878eb32b35..bfdf483229045c18eef1835825798cfd24a8e25a 100644 (file)
@@ -558,10 +558,25 @@ int parse_percent_unbounded(const char *p) {
 }
 
 int parse_percent(const char *p) {
-        int v = parse_percent_unbounded(p);
+        int v;
 
+        v = parse_percent_unbounded(p);
         if (v > 100)
                 return -ERANGE;
 
         return v;
 }
+
+int parse_nice(const char *p, int *ret) {
+        int n, r;
+
+        r = safe_atoi(p, &n);
+        if (r < 0)
+                return r;
+
+        if (!nice_is_valid(n))
+                return -ERANGE;
+
+        *ret = n;
+        return 0;
+}