diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-04-12 11:52:06 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-04-12 16:59:04 -0400 |
commit | e987f2a809c6bab7e7bae4ca8f598ea5bafd5225 (patch) | |
tree | d90205867fb1d45a316f3a1a4930985ecc7d9b03 /src/sysv-generator | |
parent | 1e2fee5f757c0bb3a6fea216b1e10ee7b3c0e12e (diff) |
sysv-generator: always log on oom
This code appears to follow the following convention:
- all errors are logged at point of origin
- oom errors abort execution, non-oom errors are logged but
execution continues.
Make sure all ooms result in a log message, and remove warning which could
not be reached. Downgrade non-fatal errors to warnings.
Diffstat (limited to 'src/sysv-generator')
-rw-r--r-- | src/sysv-generator/sysv-generator.c | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index aa5c98f2c8..ea3216490a 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -330,7 +330,7 @@ static int handle_provides(SysvStub *s, unsigned line, const char *full_text, co n = strndup(word, z); if (!n) - return -ENOMEM; + return log_oom(); r = sysv_translate_facility(n, basename(s->path), &m); if (r < 0) @@ -341,6 +341,10 @@ static int handle_provides(SysvStub *s, unsigned line, const char *full_text, co if (unit_name_to_type(m) == UNIT_SERVICE) { log_debug("Adding Provides: alias '%s' for '%s'", m, s->name); r = add_alias(s->name, m); + if (r < 0) + log_unit_warning_errno(s->name, r, + "[%s:%u] Failed to add LSB Provides name %s, ignoring: %m", + s->path, line, m); } else { /* NB: SysV targets which are provided by a * service are pulled in by the services, as @@ -359,11 +363,6 @@ static int handle_provides(SysvStub *s, unsigned line, const char *full_text, co return log_oom(); } } - - if (r < 0) - log_unit_error(s->name, - "[%s:%u] Failed to add LSB Provides name %s, ignoring: %s", - s->path, line, m, strerror(-r)); } if (!isempty(state_)) log_unit_error(s->name, @@ -383,16 +382,15 @@ static int handle_dependencies(SysvStub *s, unsigned line, const char *full_text n = strndup(word, z); if (!n) - return -ENOMEM; + return log_oom(); r = sysv_translate_facility(n, basename(s->path), &m); if (r < 0) { - log_unit_error(s->name, - "[%s:%u] Failed to translate LSB dependency %s, ignoring: %s", - s->path, line, n, strerror(-r)); + log_unit_warning_errno(s->name, r, + "[%s:%u] Failed to translate LSB dependency %s, ignoring: %m", + s->path, line, n); continue; } - if (r == 0) continue; @@ -404,23 +402,16 @@ static int handle_dependencies(SysvStub *s, unsigned line, const char *full_text if (r < 0) return log_oom(); r = strv_extend(&s->wants, m); - if (r < 0) - return log_oom(); - } else { + } else r = strv_extend(is_before ? &s->before : &s->after, m); - if (r < 0) - return log_oom(); - } if (r < 0) - log_unit_error(s->name, - "[%s:%u] Failed to add dependency on %s, ignoring: %s", - s->path, line, m, strerror(-r)); + return log_oom(); } if (!isempty(state_)) - log_unit_error(s->name, - "[%s:%u] Trailing garbage in %*s, ignoring.", - s->path, line, (int)(strchr(full_text, ':') - full_text), full_text); + log_unit_warning(s->name, + "[%s:%u] Trailing garbage in %*s, ignoring.", + s->path, line, (int)(strchr(full_text, ':') - full_text), full_text); return 0; } @@ -454,10 +445,9 @@ static int load_sysv(SysvStub *s) { if (feof(f)) break; - log_unit_error(s->name, - "Failed to read configuration file '%s': %m", - s->path); - return -errno; + return log_unit_error_errno(s->name, errno, + "Failed to read configuration file '%s': %m", + s->path); } line++; |