if (!escaped)
return -ENOMEM;
- if (!strextend(&s, escaped, "/", NULL))
+ if (!strextend(&s, escaped, "/"))
return -ENOMEM;
dash = strchr(dash+1, '-');
if (!e)
return -ENOMEM;
- if (!strextend(&s, e, NULL))
+ if (!strextend(&s, e))
return -ENOMEM;
*ret = TAKE_PTR(s);
/* Preserve the trailing slash */
if (flags & CHASE_TRAIL_SLASH)
- if (!strextend(&done, "/", NULL))
+ if (!strextend(&done, "/"))
return -ENOMEM;
break;
if (streq_ptr(done, "/"))
*done = '\0';
- if (!strextend(&done, first, todo, NULL))
+ if (!strextend(&done, first, todo))
return -ENOMEM;
exists = false;
if (streq(done, "/"))
*done = '\0';
- if (!strextend(&done, first, NULL))
+ if (!strextend(&done, first))
return -ENOMEM;
}
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);
if (need_separator)
n += l_separator;
- if (n > ((size_t) -1) - l) {
+ if (n >= SIZE_MAX - l) {
va_end(ap);
return NULL;
}
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 (;;) {
}
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) {
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);
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);
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);
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;
}
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;
}
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")) {
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)
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")) {
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")) {
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;
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;
/* 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;
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;
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;
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;
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);
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;
}
goto finalize;
}
- if (!strextend_with_separator(&j, ", ", s, NULL)) {
+ if (!strextend_with_separator(&j, ", ", s)) {
r = -ENOMEM;
goto finalize;
}
name = prefixed;
}
- if (!strextend_with_separator(&j, ", ", name, NULL))
+ if (!strextend_with_separator(&j, ", ", name))
return -ENOMEM;
}
if (r < 0)
return r;
- if (!strextend_with_separator(&j, ", ", *i, NULL))
+ if (!strextend_with_separator(&j, ", ", *i))
return -ENOMEM;
}
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
return -ENOBUFS;
}
- if (!strextend(&continuation, l, NULL)) {
+ if (!strextend(&continuation, l)) {
if (flags & CONFIG_PARSE_WARN)
log_oom();
return -ENOMEM;
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)) {
}
/* 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;
}
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;
}
* 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
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();
}
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)
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)
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)
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);
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"));
}
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"));
}
if (!j)
return log_oom();
- if (!strextend(&t, "\n\t", j, NULL))
+ if (!strextend(&t, "\n\t", j))
return log_oom();
}
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) {