From: Lennart Poettering Date: Mon, 27 Nov 2017 15:53:03 +0000 (+0100) Subject: service: use parse_errno() for parsing error numbers X-Git-Tag: v236~105^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2fa40742a46de176c4424799b0d298cc54b0b9de;p=thirdparty%2Fsystemd.git 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. --- 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; } }