diff --git a/src/activate/activate.c b/src/activate/activate.c index 5d796ab38d..bca845ad83 100644 --- a/src/activate/activate.c +++ b/src/activate/activate.c @@ -122,7 +122,6 @@ static int open_sockets(int *epoll_fd, bool accept) { } static int exec_process(const char *name, char **argv, char **env, int start_fd, size_t n_fds) { - _cleanup_strv_free_ char **envp = NULL; _cleanup_free_ char *joined = NULL; size_t n_env = 0, length; @@ -200,7 +199,6 @@ static int exec_process(const char *name, char **argv, char **env, int start_fd, return log_error_errno(errno, "Failed to dup connection: %m"); safe_close(start_fd); - start_fd = SD_LISTEN_FDS_START; } if (asprintf((char **) (envp + n_env++), "LISTEN_FDS=%zu", n_fds) < 0) @@ -215,15 +213,13 @@ static int exec_process(const char *name, char **argv, char **env, int start_fd, char *e; len = strv_length(arg_fdnames); - if (len == 1) { - size_t i; - - for (i = 1; i < n_fds; i++) { + if (len == 1) + for (size_t i = 1; i < n_fds; i++) { r = strv_extend(&arg_fdnames, arg_fdnames[0]); if (r < 0) - return log_error_errno(r, "Failed to extend strv: %m"); + return log_oom(); } - } else if (len != n_fds) + else if (len != n_fds) log_warning("The number of fd names is different than number of fds: %zu vs %zu", len, n_fds); names = strv_join(arg_fdnames, ":"); diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index 682c719f61..9ee2c23683 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -79,7 +79,7 @@ static int find_pci_or_platform_parent(sd_device *device, sd_device **ret) { } else if (streq(subsystem, "pci") && sd_device_get_sysattr_value(parent, "class", &value) >= 0) { - unsigned long class = 0; + unsigned long class; r = safe_atolu(value, &class); if (r < 0) diff --git a/src/core/namespace.h b/src/core/namespace.h index 13cc0e80cb..908e57c42c 100644 --- a/src/core/namespace.h +++ b/src/core/namespace.h @@ -64,15 +64,15 @@ typedef enum ProcSubset { } ProcSubset; struct NamespaceInfo { - bool ignore_protect_paths:1; - bool private_dev:1; - bool private_mounts:1; - bool protect_control_groups:1; - bool protect_kernel_tunables:1; - bool protect_kernel_modules:1; - bool protect_kernel_logs:1; - bool mount_apivfs:1; - bool protect_hostname:1; + bool ignore_protect_paths; + bool private_dev; + bool private_mounts; + bool protect_control_groups; + bool protect_kernel_tunables; + bool protect_kernel_modules; + bool protect_kernel_logs; + bool mount_apivfs; + bool protect_hostname; ProtectHome protect_home; ProtectSystem protect_system; ProtectProc protect_proc; @@ -82,10 +82,10 @@ struct NamespaceInfo { struct BindMount { char *source; char *destination; - bool read_only:1; - bool nosuid:1; - bool recursive:1; - bool ignore_enoent:1; + bool read_only; + bool nosuid; + bool recursive; + bool ignore_enoent; }; struct TemporaryFileSystem { diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c index 6163cf1691..66a25c7dd8 100644 --- a/src/libsystemd-network/sd-radv.c +++ b/src/libsystemd-network/sd-radv.c @@ -689,7 +689,6 @@ _public_ int sd_radv_add_route_prefix(sd_radv *ra, sd_radv_route_prefix *p, int LIST_APPEND(prefix, ra->route_prefixes, p); ra->n_route_prefixes++; - cur = p; if (!dynamic) { log_radv("Added prefix %s/%u", strempty(pretty), p->opt.prefixlen); return 0; diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index 7a35d912de..f67d06ecec 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -70,7 +70,7 @@ static int server_init(sd_bus **_bus) { goto fail; } - r = sd_bus_get_description(bus, &desc); + assert_se(sd_bus_get_description(bus, &desc) >= 0); assert_se(streq(desc, "my bus!")); log_info("Peer ID is " SD_ID128_FORMAT_STR ".", SD_ID128_FORMAT_VAL(id)); diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c index d8baa6f8af..939b2a5df4 100644 --- a/src/libsystemd/sd-login/sd-login.c +++ b/src/libsystemd/sd-login/sd-login.c @@ -997,20 +997,13 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) { if (!good) return -EINVAL; - *m = FD_TO_MONITOR(fd); - fd = -1; - + *m = FD_TO_MONITOR(TAKE_FD(fd)); return 0; } _public_ sd_login_monitor* sd_login_monitor_unref(sd_login_monitor *m) { - int fd; - - if (!m) - return NULL; - - fd = MONITOR_TO_FD(m); - close_nointr(fd); + if (m) + close_nointr(MONITOR_TO_FD(m)); return NULL; } diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c index ff0886d40b..6f283e31ff 100644 --- a/src/libsystemd/sd-netlink/sd-netlink.c +++ b/src/libsystemd/sd-netlink/sd-netlink.c @@ -135,8 +135,7 @@ int netlink_open_family(sd_netlink **ret, int family) { r = sd_netlink_open_fd(ret, fd); if (r < 0) return r; - - fd = -1; + TAKE_FD(fd); return 0; } diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c index ce6ae846c5..832ec1703e 100644 --- a/src/libsystemd/sd-network/sd-network.c +++ b/src/libsystemd/sd-network/sd-network.c @@ -373,19 +373,13 @@ _public_ int sd_network_monitor_new(sd_network_monitor **m, const char *category if (!good) return -EINVAL; - *m = FD_TO_MONITOR(fd); - fd = -1; - + *m = FD_TO_MONITOR(TAKE_FD(fd)); return 0; } _public_ sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m) { - int fd; - - if (m) { - fd = MONITOR_TO_FD(m); - close_nointr(fd); - } + if (m) + close_nointr(MONITOR_TO_FD(m)); return NULL; } diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 9f16b7f565..01ffbb6bad 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -3195,7 +3195,6 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error _cleanup_free_ char *id = NULL; _cleanup_close_ int fifo_fd = -1; Manager *m = userdata; - Inhibitor *i = NULL; InhibitMode mm; InhibitWhat w; pid_t pid; @@ -3278,6 +3277,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error } while (hashmap_get(m->inhibitors, id)); + _cleanup_(inhibitor_freep) Inhibitor *i = NULL; r = manager_add_inhibitor(m, id, &i); if (r < 0) return r; @@ -3289,28 +3289,18 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error i->why = strdup(why); i->who = strdup(who); - if (!i->why || !i->who) { - r = -ENOMEM; - goto fail; - } + if (!i->why || !i->who) + return -ENOMEM; fifo_fd = inhibitor_create_fifo(i); - if (fifo_fd < 0) { - r = fifo_fd; - goto fail; - } + if (fifo_fd < 0) + return fifo_fd; r = inhibitor_start(i); if (r < 0) - goto fail; + return r; return sd_bus_reply_method_return(message, "h", fifo_fd); - -fail: - if (i) - inhibitor_free(i); - - return r; } static const sd_bus_vtable manager_vtable[] = { diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 90f08252ab..02a27e3a88 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -703,7 +703,7 @@ int config_parse_tristate( return 0; } - *t = !!k; + *t = k; return 0; }