diff --git a/src/core/unit.c b/src/core/unit.c index 1336bcc33a..c8f4c7ce0c 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2207,7 +2207,7 @@ static int unit_log_resources(Unit *u) { /* Format the CPU time for inclusion in the human language message string */ format_timespan(buf, sizeof(buf), nsec / NSEC_PER_USEC, USEC_PER_MSEC); - t = strjoin(n_message_parts > 0 ? "consumed " : "Consumed ", buf, " CPU time"); + t = strjoin("consumed ", buf, " CPU time"); if (!t) { r = log_oom(); goto finish; @@ -2239,18 +2239,14 @@ static int unit_log_resources(Unit *u) { * bytes counters (and not for the packets counters) */ if (m == CGROUP_IP_INGRESS_BYTES) { assert(!igress); - igress = strjoin(n_message_parts > 0 ? "received " : "Received ", - format_bytes(buf, sizeof(buf), value), - " IP traffic"); + igress = strjoin("received ", format_bytes(buf, sizeof(buf), value), " IP traffic"); if (!igress) { r = log_oom(); goto finish; } } else if (m == CGROUP_IP_EGRESS_BYTES) { assert(!egress); - egress = strjoin(igress || n_message_parts > 0 ? "sent " : "Sent ", - format_bytes(buf, sizeof(buf), value), - " IP traffic"); + egress = strjoin("sent ", format_bytes(buf, sizeof(buf), value), " IP traffic"); if (!egress) { r = log_oom(); goto finish; @@ -2266,7 +2262,7 @@ static int unit_log_resources(Unit *u) { } else { char *k; - k = strdup(n_message_parts > 0 ? "no IP traffic" : "No IP traffic"); + k = strdup("no IP traffic"); if (!k) { r = log_oom(); goto finish; @@ -2294,6 +2290,7 @@ static int unit_log_resources(Unit *u) { goto finish; } + joined[0] = ascii_toupper(joined[0]); t = strjoina("MESSAGE=", u->id, ": ", joined, "."); } diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 01d909ff19..68d91be296 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -81,10 +81,10 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent char *l; int k; - r = read_line(f, LONG_LINE_MAX, &line); - if (r < 0) - return log_error_errno(errno, "Failed to read file '%s': %m", path); - if (r == 0) + k = read_line(f, LONG_LINE_MAX, &line); + if (k < 0) + return log_error_errno(k, "Failed to read file '%s': %m", path); + if (k == 0) break; l = strstrip(line); @@ -94,7 +94,7 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent continue; k = module_load_and_warn(ctx, l, true); - if (k < 0 && r == 0) + if (k < 0 && r >= 0) r = k; } diff --git a/src/reply-password/reply-password.c b/src/reply-password/reply-password.c index 5794dfd535..d085da9f08 100644 --- a/src/reply-password/reply-password.c +++ b/src/reply-password/reply-password.c @@ -37,7 +37,7 @@ static int send_on_socket(int fd, const char *socket_name, const void *packet, s int main(int argc, char *argv[]) { _cleanup_free_ char *packet = NULL; _cleanup_close_ int fd = -1; - size_t length; + size_t length = 0; int r; log_set_target(LOG_TARGET_AUTO); diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c index 6c16b6f6b9..1894362828 100644 --- a/src/udev/udevadm-info.c +++ b/src/udev/udevadm-info.c @@ -331,8 +331,8 @@ int info_main(int argc, char *argv[], void *userdata) { break; case 'd': action = ACTION_DEVICE_ID_FILE; - name = strdup(optarg); - if (!name) + r = free_and_strdup(&name, optarg); + if (r < 0) return log_oom(); break; case 'a': diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index 631f69ded4..ae8e06111e 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -200,7 +200,7 @@ static int parse_argv(int argc, char *argv[]) { int monitor_main(int argc, char *argv[], void *userdata) { _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *kernel_monitor = NULL, *udev_monitor = NULL; - _cleanup_(sd_event_unrefp) sd_event *event; + _cleanup_(sd_event_unrefp) sd_event *event = NULL; int r; r = parse_argv(argc, argv);