diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2015-07-01 13:02:58 +0200 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2015-07-01 13:02:58 +0200 |
commit | 0b2ec8a3bfdd6118b3b4958d236ee203ad420f28 (patch) | |
tree | ad7b4a16b93dce13beba34312e6652c4de3ee900 /src/sysv-generator | |
parent | e04658277d531763a5cbbb6e212041a35e0d9ff4 (diff) | |
download | systemd-0b2ec8a3bfdd6118b3b4958d236ee203ad420f28.tar.gz |
sysv-generator: fix coding-style
Fix weird coding-style:
- proper white-space
- no if (func() >= 0) bail-outs
- fix braces
- avoid 'r' for anything but errno
- init _cleanup_ variables unconditionally, even if not needed
Diffstat (limited to 'src/sysv-generator')
-rw-r--r-- | src/sysv-generator/sysv-generator.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 0d246b1835..45b119362c 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -240,22 +240,21 @@ static bool usage_contains_reload(const char *line) { } static char *sysv_translate_name(const char *name) { - char *r; - _cleanup_free_ char *c; + _cleanup_free_ char *c = NULL; + char *res; c = strdup(name); if (!c) - return NULL; + return NULL; - r = endswith(c, ".sh"); - if (r) { - *r = '\0'; - } + res = endswith(c, ".sh"); + if (res) + *res = 0; - if (unit_name_mangle(c, UNIT_NAME_NOGLOB, &r) >= 0) - return r; - else - return NULL; + if (unit_name_mangle(c, UNIT_NAME_NOGLOB, &res) < 0) + return NULL; + + return res; } static int sysv_translate_facility(const char *name, const char *filename, char **_r) { @@ -377,8 +376,7 @@ static int handle_provides(SysvStub *s, unsigned line, const char *full_text, co if (r < 0) return log_oom(); } - } - else if (t == _UNIT_TYPE_INVALID) + } else if (t == _UNIT_TYPE_INVALID) log_warning("Unit name '%s' is invalid", m); else log_warning("Unknown unit type for unit '%s'", m); |