diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-10-30 16:13:21 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-10-30 16:13:43 +0100 |
commit | 5220a6f3a1f5a7324898ecfe7649af254cf561a6 (patch) | |
tree | 6fc5a0e3652feef9a9c0fd8690c8033802a10a58 /src | |
parent | 36f9f99556b2fd90705a9eda2e8f182b1e63a15e (diff) |
general: various cleanups
Diffstat (limited to 'src')
-rw-r--r-- | src/analyze/analyze.c | 6 | ||||
-rw-r--r-- | src/fsck/fsck.c | 13 | ||||
-rw-r--r-- | src/login/inhibit.c | 17 |
3 files changed, 12 insertions, 24 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 967258d447..35778ea897 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1295,8 +1295,8 @@ static int parse_argv(int argc, char *argv[]) { } int main(int argc, char *argv[]) { - int r; _cleanup_bus_unref_ sd_bus *bus = NULL; + int r; setlocale(LC_ALL, ""); setlocale(LC_NUMERIC, "C"); /* we want to format/parse floats in C style */ @@ -1308,9 +1308,9 @@ int main(int argc, char *argv[]) { goto finish; if (arg_scope == UNIT_FILE_SYSTEM) - r = sd_bus_open_system(&bus); + r = sd_bus_open_system(&bus); else - r = sd_bus_open_user(&bus); + r = sd_bus_open_user(&bus); if (r < 0) { log_error("Failed to connect to bus: %s", strerror(-r)); diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 3164d6899c..10c968678b 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -44,8 +44,8 @@ static bool arg_force = false; static bool arg_show_progress = false; static void start_target(const char *target) { - _cleanup_bus_unref_ sd_bus *bus = NULL; _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_bus_unref_ sd_bus *bus = NULL; int r; assert(target); @@ -67,15 +67,10 @@ static void start_target(const char *target) { &error, NULL, "sss", "basic.target", target, "replace"); - if (r < 0) { - - /* Don't print a warning if we aren't called during - * startup */ - if (!sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_JOB)) - log_error("Failed to start unit: %s", bus_error_message(&error, -r)); - } - return; + /* Don't print a warning if we aren't called during startup */ + if (r < 0 && !sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_JOB)) + log_error("Failed to start unit: %s", bus_error_message(&error, -r)); } static int parse_proc_cmdline(void) { diff --git a/src/login/inhibit.c b/src/login/inhibit.c index 208a0ce49b..3ab86ac90c 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -98,7 +98,6 @@ static int print_inhibitors(sd_bus *bus, sd_bus_error *error) { while ((r = sd_bus_message_read(reply, "(ssssuu)", &what, &who, &why, &mode, &uid, &pid)) > 0) { _cleanup_free_ char *comm = NULL, *u = NULL; - get_process_comm(pid, &comm); u = uid_to_name(uid); @@ -221,10 +220,9 @@ static int parse_argv(int argc, char *argv[]) { } int main(int argc, char *argv[]) { - int r; - _cleanup_bus_unref_ sd_bus *bus = NULL; _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; - int fd = -1; + _cleanup_bus_unref_ sd_bus *bus = NULL; + int r; log_parse_environment(); log_open(); @@ -248,15 +246,14 @@ int main(int argc, char *argv[]) { } } else { - char *w = NULL; + _cleanup_close_ int fd = -1; + _cleanup_free_ char *w = NULL; pid_t pid; if (!arg_who) arg_who = w = strv_join(argv + optind, " "); fd = inhibit(bus, &error); - free(w); - if (fd < 0) { log_error("Failed to inhibit: %s", bus_error_message(&error, -r)); return EXIT_FAILURE; @@ -279,11 +276,7 @@ int main(int argc, char *argv[]) { } r = wait_for_terminate_and_warn(argv[optind], pid); - close(fd); - if (r < 0) - return EXIT_FAILURE; - else - return r; + return r < 0 ? EXIT_FAILURE : r; } return 0; |