From: Mike Yuan Date: Tue, 11 Feb 2025 17:13:01 +0000 (+0100) Subject: bus-unit-util: add missing assertions X-Git-Tag: v258-rc1~1343^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85f759baeeab59f25080bd19b2f338ae2d05ad8b;p=thirdparty%2Fsystemd.git bus-unit-util: add missing assertions --- diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index ed739503551..ee09c4f2314 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -148,9 +148,11 @@ static int bus_append_string(sd_bus_message *m, const char *field, const char *e } static int bus_append_strv(sd_bus_message *m, const char *field, const char *eq, const char *separator, ExtractFlags flags) { - const char *p; int r; + assert(m); + assert(field); + r = sd_bus_message_open_container(m, 'r', "sv"); if (r < 0) return bus_log_create_error(r); @@ -167,16 +169,16 @@ static int bus_append_strv(sd_bus_message *m, const char *field, const char *eq, if (r < 0) return bus_log_create_error(r); - for (p = eq;;) { + for (const char *p = eq;;) { _cleanup_free_ char *word = NULL; r = extract_first_word(&p, &word, separator, flags); - if (r == 0) - break; if (r == -ENOMEM) return log_oom(); if (r < 0) return log_error_errno(r, "Invalid syntax: %s", eq); + if (r == 0) + break; r = sd_bus_message_append_basic(m, 's', word); if (r < 0)