diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/cgroup-util.c | 4 | ||||
-rw-r--r-- | src/basic/fs-util.c | 6 | ||||
-rw-r--r-- | src/basic/string-util.c | 20 | ||||
-rw-r--r-- | src/basic/string-util.h | 5 | ||||
-rw-r--r-- | src/busctl/busctl-introspect.c | 6 | ||||
-rw-r--r-- | src/core/device.c | 2 | ||||
-rw-r--r-- | src/core/killall.c | 2 | ||||
-rw-r--r-- | src/fstab-generator/fstab-generator.c | 4 | ||||
-rw-r--r-- | src/hibernate-resume/hibernate-resume-generator.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-message.c | 12 | ||||
-rw-r--r-- | src/machine/machinectl.c | 5 | ||||
-rw-r--r-- | src/portable/portable.c | 4 | ||||
-rw-r--r-- | src/resolve/resolved-link-bus.c | 6 | ||||
-rw-r--r-- | src/shared/bus-unit-util.c | 2 | ||||
-rw-r--r-- | src/shared/conf-parser.c | 2 | ||||
-rw-r--r-- | src/shared/dissect-image.c | 4 | ||||
-rw-r--r-- | src/shared/mount-util.c | 2 | ||||
-rw-r--r-- | src/shared/nsflags.c | 2 | ||||
-rw-r--r-- | src/shutdown/umount.c | 8 | ||||
-rw-r--r-- | src/systemctl/systemctl-show.c | 10 | ||||
-rw-r--r-- | src/test/test-string-util.c | 10 | ||||
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 2 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 2 |
23 files changed, 61 insertions, 63 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index f28bf1866a..375fd1c3be 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -1619,7 +1619,7 @@ int cg_slice_to_path(const char *unit, char **ret) { if (!escaped) return -ENOMEM; - if (!strextend(&s, escaped, "/", NULL)) + if (!strextend(&s, escaped, "/")) return -ENOMEM; dash = strchr(dash+1, '-'); @@ -1629,7 +1629,7 @@ int cg_slice_to_path(const char *unit, char **ret) { if (!e) return -ENOMEM; - if (!strextend(&s, e, NULL)) + if (!strextend(&s, e)) return -ENOMEM; *ret = TAKE_PTR(s); diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index f240f84322..7f44b93726 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -934,7 +934,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, /* Preserve the trailing slash */ if (flags & CHASE_TRAIL_SLASH) - if (!strextend(&done, "/", NULL)) + if (!strextend(&done, "/")) return -ENOMEM; break; @@ -1005,7 +1005,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, if (streq_ptr(done, "/")) *done = '\0'; - if (!strextend(&done, first, todo, NULL)) + if (!strextend(&done, first, todo)) return -ENOMEM; exists = false; @@ -1098,7 +1098,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, if (streq(done, "/")) *done = '\0'; - if (!strextend(&done, first, NULL)) + if (!strextend(&done, first)) return -ENOMEM; } diff --git a/src/basic/string-util.c b/src/basic/string-util.c index 7ab460faa5..105952156d 100644 --- a/src/basic/string-util.c +++ b/src/basic/string-util.c @@ -791,10 +791,10 @@ char *strip_tab_ansi(char **ibuf, size_t *_isz, size_t highlight[2]) { return *ibuf; } -char *strextend_with_separator(char **x, const char *separator, ...) { - bool need_separator; +char *strextend_with_separator_internal(char **x, const char *separator, ...) { size_t f, l, l_separator; - char *r, *p; + bool need_separator; + char *nr, *p; va_list ap; assert(x); @@ -818,7 +818,7 @@ char *strextend_with_separator(char **x, const char *separator, ...) { if (need_separator) n += l_separator; - if (n > ((size_t) -1) - l) { + if (n >= SIZE_MAX - l) { va_end(ap); return NULL; } @@ -830,11 +830,12 @@ char *strextend_with_separator(char **x, const char *separator, ...) { need_separator = !isempty(*x); - r = realloc(*x, l+1); - if (!r) + nr = realloc(*x, l+1); + if (!nr) return NULL; - p = r + f; + *x = nr; + p = nr + f; va_start(ap, separator); for (;;) { @@ -853,12 +854,11 @@ char *strextend_with_separator(char **x, const char *separator, ...) { } va_end(ap); - assert(p == r + l); + assert(p == nr + l); *p = 0; - *x = r; - return r + l; + return p; } char *strrep(const char *s, unsigned n) { diff --git a/src/basic/string-util.h b/src/basic/string-util.h index fdd3ce7363..593cf04ae1 100644 --- a/src/basic/string-util.h +++ b/src/basic/string-util.h @@ -189,9 +189,10 @@ char *strreplace(const char *text, const char *old_string, const char *new_strin char *strip_tab_ansi(char **ibuf, size_t *_isz, size_t highlight[2]); -char *strextend_with_separator(char **x, const char *separator, ...) _sentinel_; +char *strextend_with_separator_internal(char **x, const char *separator, ...) _sentinel_; -#define strextend(x, ...) strextend_with_separator(x, NULL, __VA_ARGS__) +#define strextend_with_separator(x, separator, ...) strextend_with_separator_internal(x, separator, __VA_ARGS__, NULL) +#define strextend(x, ...) strextend_with_separator_internal(x, NULL, __VA_ARGS__, NULL) char *strrep(const char *s, unsigned n); diff --git a/src/busctl/busctl-introspect.c b/src/busctl/busctl-introspect.c index 7a5d57f8c8..89b32f4c73 100644 --- a/src/busctl/busctl-introspect.c +++ b/src/busctl/busctl-introspect.c @@ -406,10 +406,10 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth if (argument_type) { if (!argument_direction || streq(argument_direction, "in")) { - if (!strextend(&context->member_signature, argument_type, NULL)) + if (!strextend(&context->member_signature, argument_type)) return log_oom(); } else if (streq(argument_direction, "out")) { - if (!strextend(&context->member_result, argument_type, NULL)) + if (!strextend(&context->member_result, argument_type)) return log_oom(); } else log_error("Unexpected method <arg> direction value '%s'.", argument_direction); @@ -541,7 +541,7 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth if (argument_type) { if (!argument_direction || streq(argument_direction, "out")) { - if (!strextend(&context->member_signature, argument_type, NULL)) + if (!strextend(&context->member_signature, argument_type)) return log_oom(); } else log_error("Unexpected signal <arg> direction value '%s'.", argument_direction); diff --git a/src/core/device.c b/src/core/device.c index 6440c59e26..cbfb87a808 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -201,7 +201,7 @@ static int device_found_to_string_many(DeviceFound flags, char **ret) { if (!FLAGS_SET(flags, device_found_map[i].flag)) continue; - if (!strextend_with_separator(&s, ",", device_found_map[i].name, NULL)) + if (!strextend_with_separator(&s, ",", device_found_map[i].name)) return -ENOMEM; } diff --git a/src/core/killall.c b/src/core/killall.c index 6f60f09c4e..d9fcfc21a9 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -87,7 +87,7 @@ static void log_children_no_yet_killed(Set *pids) { if (get_process_comm(PTR_TO_PID(p), &s) < 0) (void) asprintf(&s, PID_FMT, PTR_TO_PID(p)); - if (!strextend(&lst_child, ", ", s, NULL)) { + if (!strextend(&lst_child, ", ", s)) { log_oom(); return; } diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 15f5892228..2318b65b0e 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -843,7 +843,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (proc_cmdline_value_missing(key, value)) return 0; - if (!strextend_with_separator(&arg_root_options, ",", value, NULL)) + if (!strextend_with_separator(&arg_root_options, ",", value)) return log_oom(); } else if (streq(key, "roothash")) { @@ -875,7 +875,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (proc_cmdline_value_missing(key, value)) return 0; - if (!strextend_with_separator(&arg_usr_options, ",", value, NULL)) + if (!strextend_with_separator(&arg_usr_options, ",", value)) return log_oom(); } else if (streq(key, "rw") && !value) diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index 04a28c9053..b1e5452bb0 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -45,7 +45,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (proc_cmdline_value_missing(key, value)) return 0; - if (!strextend_with_separator(&arg_resume_options, ",", value, NULL)) + if (!strextend_with_separator(&arg_resume_options, ",", value)) return log_oom(); } else if (streq(key, "rootflags")) { @@ -53,7 +53,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (proc_cmdline_value_missing(key, value)) return 0; - if (!strextend_with_separator(&arg_root_options, ",", value, NULL)) + if (!strextend_with_separator(&arg_root_options, ",", value)) return log_oom(); } else if (streq(key, "noresume")) { diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c index 86ff5bdfa2..99b1704aee 100644 --- a/src/libsystemd/sd-bus/bus-message.c +++ b/src/libsystemd/sd-bus/bus-message.c @@ -1471,7 +1471,7 @@ int message_append_basic(sd_bus_message *m, char type, const void *p, const void if (c->enclosing != 0) return -ENXIO; - e = strextend(&c->signature, CHAR_TO_STR(type), NULL); + e = strextend(&c->signature, CHAR_TO_STR(type)); if (!e) { m->poisoned = true; return -ENOMEM; @@ -1664,7 +1664,7 @@ _public_ int sd_bus_message_append_string_space( if (c->enclosing != 0) return -ENXIO; - e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_STRING), NULL); + e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_STRING)); if (!e) { m->poisoned = true; return -ENOMEM; @@ -1768,7 +1768,7 @@ static int bus_message_open_array( /* Extend the existing signature */ - e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_ARRAY), contents, NULL); + e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_ARRAY), contents); if (!e) { m->poisoned = true; return -ENOMEM; @@ -1853,7 +1853,7 @@ static int bus_message_open_variant( if (c->enclosing != 0) return -ENXIO; - e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_VARIANT), NULL); + e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_VARIANT)); if (!e) { m->poisoned = true; return -ENOMEM; @@ -1921,7 +1921,7 @@ static int bus_message_open_struct( if (c->enclosing != 0) return -ENXIO; - e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_STRUCT_BEGIN), contents, CHAR_TO_STR(SD_BUS_TYPE_STRUCT_END), NULL); + e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_STRUCT_BEGIN), contents, CHAR_TO_STR(SD_BUS_TYPE_STRUCT_END)); if (!e) { m->poisoned = true; return -ENOMEM; @@ -2776,7 +2776,7 @@ _public_ int sd_bus_message_append_string_memfd( if (c->enclosing != 0) return -ENXIO; - e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_STRING), NULL); + e = strextend(&c->signature, CHAR_TO_STR(SD_BUS_TYPE_STRING)); if (!e) { m->poisoned = true; return -ENOMEM; diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 3c839455b6..6eb6cbb35a 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -206,7 +206,10 @@ static int call_get_addresses( else strcpy(buf_ifi, ""); - if (!strextend(&addresses, prefix, inet_ntop(family, a, buffer, sizeof(buffer)), buf_ifi, NULL)) + if (!strextend(&addresses, + prefix, + inet_ntop(family, a, buffer, sizeof(buffer)), + buf_ifi)) return log_oom(); r = sd_bus_message_exit_container(reply); diff --git a/src/portable/portable.c b/src/portable/portable.c index ed7eac0291..a96a944ad1 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -710,9 +710,7 @@ static int install_chroot_dropin( IN_SET(type, IMAGE_DIRECTORY, IMAGE_SUBVOLUME) ? "RootDirectory=" : "RootImage=", image_path, "\n" "Environment=PORTABLE=", basename(image_path), "\n" "BindReadOnlyPaths=", os_release_source, ":/run/host/os-release\n" - "LogExtraFields=PORTABLE=", basename(image_path), "\n", - NULL)) - + "LogExtraFields=PORTABLE=", basename(image_path), "\n")) return -ENOMEM; } diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c index d27d46b11f..e435fd3a80 100644 --- a/src/resolve/resolved-link-bus.c +++ b/src/resolve/resolved-link-bus.c @@ -290,7 +290,7 @@ static int bus_link_method_set_dns_servers_internal(sd_bus_message *message, voi goto finalize; } - if (!strextend_with_separator(&j, ", ", s, NULL)) { + if (!strextend_with_separator(&j, ", ", s)) { r = -ENOMEM; goto finalize; } @@ -387,7 +387,7 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_ name = prefixed; } - if (!strextend_with_separator(&j, ", ", name, NULL)) + if (!strextend_with_separator(&j, ", ", name)) return -ENOMEM; } @@ -702,7 +702,7 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v if (r < 0) return r; - if (!strextend_with_separator(&j, ", ", *i, NULL)) + if (!strextend_with_separator(&j, ", ", *i)) return -ENOMEM; } diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index 2bab2299fb..bc17b6e1fb 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -1159,7 +1159,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con if (r < 0) return log_error_errno(r, "Failed to unescape text '%s': %m", eq); - if (!strextend(&unescaped, "\n", NULL)) + if (!strextend(&unescaped, "\n")) return log_oom(); /* Note that we don't expand specifiers here, but that should be OK, as this is a programmatic diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index e8b3dc78f9..0a1f2d67d4 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -343,7 +343,7 @@ int config_parse( return -ENOBUFS; } - if (!strextend(&continuation, l, NULL)) { + if (!strextend(&continuation, l)) { if (flags & CONFIG_PARSE_WARN) log_oom(); return -ENOMEM; diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index b1d7d689ea..bfde5cd5a0 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -1340,12 +1340,12 @@ static int mount_partition( if (asprintf(&uid_option, "uid=" UID_FMT ",gid=" GID_FMT, uid_shift, (gid_t) uid_shift) < 0) return -ENOMEM; - if (!strextend_with_separator(&options, ",", uid_option, NULL)) + if (!strextend_with_separator(&options, ",", uid_option)) return -ENOMEM; } if (!isempty(m->mount_options)) - if (!strextend_with_separator(&options, ",", m->mount_options, NULL)) + if (!strextend_with_separator(&options, ",", m->mount_options)) return -ENOMEM; if (FLAGS_SET(flags, DISSECT_IMAGE_MKDIR)) { diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index b19b3849aa..a6480b93a4 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -733,7 +733,7 @@ int mount_option_mangle( } /* If 'word' is not a mount flag, then store it in '*ret_remaining_options'. */ - if (!ent->name && !strextend_with_separator(&ret, ",", word, NULL)) + if (!ent->name && !strextend_with_separator(&ret, ",", word)) return -ENOMEM; } diff --git a/src/shared/nsflags.c b/src/shared/nsflags.c index 2845041cf4..d1c2168dea 100644 --- a/src/shared/nsflags.c +++ b/src/shared/nsflags.c @@ -61,7 +61,7 @@ int namespace_flags_to_string(unsigned long flags, char **ret) { if ((flags & namespace_flag_map[i].flag) != namespace_flag_map[i].flag) continue; - if (!strextend_with_separator(&s, " ", namespace_flag_map[i].name, NULL)) + if (!strextend_with_separator(&s, " ", namespace_flag_map[i].name)) return -ENOMEM; } diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c index 3a72a13e1a..906756292b 100644 --- a/src/shutdown/umount.c +++ b/src/shutdown/umount.c @@ -96,13 +96,9 @@ int mount_points_list_get(const char *mountinfo, MountPoint **head) { * Even if there are duplicates later in mount_option_mangle() * they shouldn't hurt anyways as they override each other. */ - if (!strextend_with_separator(&options, ",", - mnt_fs_get_vfs_options(fs), - NULL)) + if (!strextend_with_separator(&options, ",", mnt_fs_get_vfs_options(fs))) return log_oom(); - if (!strextend_with_separator(&options, ",", - mnt_fs_get_fs_options(fs), - NULL)) + if (!strextend_with_separator(&options, ",", mnt_fs_get_fs_options(fs))) return log_oom(); /* Ignore mount points we can't unmount because they diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index d5efecbe65..db3a3bd40a 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -1476,7 +1476,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m if (in_addr_prefix_to_string(family, (union in_addr_union *) ap, prefixlen, &str) < 0) continue; - if (!strextend_with_separator(&addresses, " ", str, NULL)) + if (!strextend_with_separator(&addresses, " ", str)) return log_oom(); } @@ -1513,7 +1513,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m rbind == MS_REC ? ":rbind" : "") < 0) return log_oom(); - if (!strextend_with_separator(&paths, " ", str, NULL)) + if (!strextend_with_separator(&paths, " ", str)) return log_oom(); } if (r < 0) @@ -1545,7 +1545,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m if (asprintf(&str, "%s%s%s", target, isempty(option) ? "" : ":", strempty(option)) < 0) return log_oom(); - if (!strextend_with_separator(&paths, " ", str, NULL)) + if (!strextend_with_separator(&paths, " ", str)) return log_oom(); } if (r < 0) @@ -1593,7 +1593,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m if (!utf8_is_valid(str)) continue; - if (!strextend_with_separator(&fields, " ", str, NULL)) + if (!strextend_with_separator(&fields, " ", str)) return log_oom(); } if (r < 0) @@ -1670,7 +1670,7 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m if (r < 0) return r; - if (!strextend_with_separator(&paths, " ", str, NULL)) + if (!strextend_with_separator(&paths, " ", str)) return log_oom(); r = sd_bus_message_exit_container(m); diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c index b74eb180f3..67f083ff93 100644 --- a/src/test/test-string-util.c +++ b/src/test/test-string-util.c @@ -244,9 +244,9 @@ static void test_strextend(void) { assert_se(strextend(&str, NULL)); assert_se(streq_ptr(str, "")); - assert_se(strextend(&str, "", "0", "", "", "123", NULL)); + assert_se(strextend(&str, "", "0", "", "", "123")); assert_se(streq_ptr(str, "0123")); - assert_se(strextend(&str, "456", "78", "9", NULL)); + assert_se(strextend(&str, "456", "78", "9")); assert_se(streq_ptr(str, "0123456789")); } @@ -265,13 +265,13 @@ static void test_strextend_with_separator(void) { assert_se(streq_ptr(str, "")); str = mfree(str); - assert_se(strextend_with_separator(&str, "xyz", "a", "bb", "ccc", NULL)); + assert_se(strextend_with_separator(&str, "xyz", "a", "bb", "ccc")); assert_se(streq_ptr(str, "axyzbbxyzccc")); str = mfree(str); - assert_se(strextend_with_separator(&str, ",", "start", "", "1", "234", NULL)); + assert_se(strextend_with_separator(&str, ",", "start", "", "1", "234")); assert_se(streq_ptr(str, "start,,1,234")); - assert_se(strextend_with_separator(&str, ";", "more", "5", "678", NULL)); + assert_se(strextend_with_separator(&str, ";", "more", "5", "678")); assert_se(streq_ptr(str, "start,,1,234;more;5;678")); } diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 6a1215d626..4ebdaddb5b 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -3387,7 +3387,7 @@ static int run(int argc, char *argv[]) { if (!j) return log_oom(); - if (!strextend(&t, "\n\t", j, NULL)) + if (!strextend(&t, "\n\t", j)) return log_oom(); } diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 56d680c12f..06a97d8671 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1241,7 +1241,7 @@ int udev_rules_parse_file(UdevRules *rules, const char *filename) { if (strlen(continuation) + len >= UDEV_LINE_SIZE) ignore_line = true; - if (!strextend(&continuation, line, NULL)) + if (!strextend(&continuation, line)) return log_oom(); if (!ignore_line) { |