]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
service: use parse_errno() for parsing error numbers
authorLennart Poettering <lennart@poettering.net>
Mon, 27 Nov 2017 15:53:03 +0000 (16:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 27 Nov 2017 16:04:57 +0000 (17:04 +0100)
Let's always use the same logic when parsing error numbers, i.e. use
parse_errno() here too, to unify some code, and tighten the checks a
bit.

This also allows clients to pass errors as symbolic names. Probably
nothing we want to advertise too eagerly (since new daemons generating
this on old service managers won't understand), but still pretty
useful I think, in particular in scripting languages and such, where the
numeric error numbers might not be readily available.

src/core/service.c

index bd187a2753344787cec871b53ad55b6f7b0bdbbb..e7e65d4270a5e8c3d51775beacf71923f6f7c08f 100644 (file)
@@ -3458,13 +3458,13 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags, FDSet *fds)
         if (e) {
                 int status_errno;
 
-                if (safe_atoi(e, &status_errno) < 0 || status_errno < 0)
-                        log_unit_warning(u, "Failed to parse ERRNO= field in notification message: %s", e);
-                else {
-                        if (s->status_errno != status_errno) {
-                                s->status_errno = status_errno;
-                                notify_dbus = true;
-                        }
+                status_errno = parse_errno(e);
+                if (status_errno < 0)
+                        log_unit_warning_errno(u, status_errno,
+                                               "Failed to parse ERRNO= field in notification message: %s", e);
+                else if (s->status_errno != status_errno) {
+                        s->status_errno = status_errno;
+                        notify_dbus = true;
                 }
         }