From 2fa40742a46de176c4424799b0d298cc54b0b9de Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 27 Nov 2017 16:53:03 +0100 Subject: [PATCH] service: use parse_errno() for parsing error numbers 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index bd187a27533..e7e65d4270a 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -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; } } -- 2.47.3