Rename STRV_MAKE_EMPTY to just STRV_EMPTY

Even though this creates a stack allocation, it is not a function macro, so
drop the "make" from the name.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-07-03 10:37:33 +02:00
parent d2a9a2aabf
commit e47fb4abd2
9 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
} while (false)
#define STRV_MAKE(...) ((char**) ((const char*[]) { __VA_ARGS__, NULL }))
#define STRV_MAKE_EMPTY ((char*[1]) { NULL })
#define STRV_EMPTY ((char*[1]) { NULL })
#define STRV_MAKE_CONST(...) ((const char* const*) ((const char*[]) { __VA_ARGS__, NULL }))
/* Pointers range from NULL to POINTER_MAX */
+2 -2
View File
@@ -171,14 +171,14 @@ TEST(config_parse_unsigned) {
}
TEST(config_parse_strv) {
test_config_parse_strv_one("", false, STRV_MAKE_EMPTY);
test_config_parse_strv_one("", false, STRV_EMPTY);
test_config_parse_strv_one("foo", false, STRV_MAKE("foo"));
test_config_parse_strv_one("foo bar foo", false, STRV_MAKE("foo", "bar", "foo"));
test_config_parse_strv_one("\"foo bar\" foo", false, STRV_MAKE("foo bar", "foo"));
test_config_parse_strv_one("\xc3\x80", false, STRV_MAKE("\xc3\x80"));
test_config_parse_strv_one("\xc3\x7f", false, STRV_MAKE("\xc3\x7f"));
test_config_parse_strv_one("", true, STRV_MAKE_EMPTY);
test_config_parse_strv_one("", true, STRV_EMPTY);
test_config_parse_strv_one("foo", true, STRV_MAKE("foo"));
test_config_parse_strv_one("foo bar foo", true, STRV_MAKE("foo", "bar"));
test_config_parse_strv_one("\"foo bar\" foo", true, STRV_MAKE("foo bar", "foo"));
+4 -4
View File
@@ -42,22 +42,22 @@ TEST(strv_parse_nulstr_full) {
STRV_MAKE("hoge", "hoge2", "hoge3", "", "hoge5", "", "xxx"));
strv_parse_nulstr_full_one(((const char[0]) {}), 0,
STRV_MAKE_EMPTY, STRV_MAKE_EMPTY);
STRV_EMPTY, STRV_EMPTY);
strv_parse_nulstr_full_one(((const char[1]) { 0 }), 1,
STRV_MAKE(""), STRV_MAKE_EMPTY);
STRV_MAKE(""), STRV_EMPTY);
strv_parse_nulstr_full_one(((const char[1]) { 'x' }), 1,
STRV_MAKE("x"), STRV_MAKE("x"));
strv_parse_nulstr_full_one(((const char[2]) { 0, 0 }), 2,
STRV_MAKE("", ""), STRV_MAKE_EMPTY);
STRV_MAKE("", ""), STRV_EMPTY);
strv_parse_nulstr_full_one(((const char[2]) { 'x', 0 }), 2,
STRV_MAKE("x"), STRV_MAKE("x"));
strv_parse_nulstr_full_one(((const char[3]) { 0, 0, 0 }), 3,
STRV_MAKE("", "", ""), STRV_MAKE_EMPTY);
STRV_MAKE("", "", ""), STRV_EMPTY);
strv_parse_nulstr_full_one(((const char[3]) { 'x', 0, 0 }), 3,
STRV_MAKE("x", ""), STRV_MAKE("x"));
+1 -1
View File
@@ -244,7 +244,7 @@ TEST(proc_cmdline_key_startswith) {
TEST(proc_cmdline_filter_pid1_args) {
test_proc_cmdline_filter_pid1_args_one("systemd\0",
STRV_MAKE_EMPTY);
STRV_EMPTY);
/* short option */
test_proc_cmdline_filter_pid1_args_one("systemd\0"
+1 -1
View File
@@ -110,7 +110,7 @@ TEST(serialize_strv) {
log_info("/* %s (%s) */", __func__, fn);
assert_se(serialize_strv(f, "strv1", NULL) == 0);
assert_se(serialize_strv(f, "strv2", STRV_MAKE_EMPTY) == 0);
assert_se(serialize_strv(f, "strv2", STRV_EMPTY) == 0);
assert_se(serialize_strv(f, "strv3", strv) == 1);
assert_se(serialize_strv(f, "strv4", STRV_MAKE(long_string)) == -EINVAL);
+1 -1
View File
@@ -139,7 +139,7 @@ int main(int argc, char *argv[]) {
assert_se(test_socket_bind(m, "socket_bind_test.service", netcat_path, "2000", STRV_MAKE("ipv6:2001-2002"), STRV_MAKE("any")) >= 0);
assert_se(test_socket_bind(m, "socket_bind_test.service", netcat_path, "6666", STRV_MAKE("ipv4:6666", "6667"), STRV_MAKE("any")) >= 0);
assert_se(test_socket_bind(m, "socket_bind_test.service", netcat_path, "6666", STRV_MAKE("6667", "6668", ""), STRV_MAKE("any")) >= 0);
assert_se(test_socket_bind(m, "socket_bind_test.service", netcat_path, "7777", STRV_MAKE_EMPTY, STRV_MAKE_EMPTY) >= 0);
assert_se(test_socket_bind(m, "socket_bind_test.service", netcat_path, "7777", STRV_EMPTY, STRV_EMPTY) >= 0);
assert_se(test_socket_bind(m, "socket_bind_test.service", netcat_path, "8888", STRV_MAKE("any"), STRV_MAKE("any")) >= 0);
assert_se(test_socket_bind(m, "socket_bind_test.service", netcat_path, "8888", STRV_MAKE("ipv6:tcp:8888-8889"), STRV_MAKE("any")) >= 0);
assert_se(test_socket_bind(m, "socket_bind_test.service", netcat_path, "10000", STRV_MAKE("ipv6:udp:9999-10000"), STRV_MAKE("any")) >= 0);
+1 -1
View File
@@ -496,7 +496,7 @@ TEST(foreach_word_quoted) {
true);
check("test\\",
STRV_MAKE_EMPTY,
STRV_EMPTY,
true);
}
+5 -5
View File
@@ -224,9 +224,9 @@ static void test_strv_unquote_one(const char *quoted, char **list) {
TEST(strv_unquote) {
test_strv_unquote_one(" foo=bar \"waldo\" zzz ", STRV_MAKE("foo=bar", "waldo", "zzz"));
test_strv_unquote_one("", STRV_MAKE_EMPTY);
test_strv_unquote_one(" ", STRV_MAKE_EMPTY);
test_strv_unquote_one(" ", STRV_MAKE_EMPTY);
test_strv_unquote_one("", STRV_EMPTY);
test_strv_unquote_one(" ", STRV_EMPTY);
test_strv_unquote_one(" ", STRV_EMPTY);
test_strv_unquote_one(" x", STRV_MAKE("x"));
test_strv_unquote_one("x ", STRV_MAKE("x"));
test_strv_unquote_one(" x ", STRV_MAKE("x"));
@@ -774,7 +774,7 @@ TEST(strv_foreach_backwards) {
STRV_FOREACH_BACKWARDS(check, (char**) NULL)
assert_not_reached();
STRV_FOREACH_BACKWARDS(check, STRV_MAKE_EMPTY)
STRV_FOREACH_BACKWARDS(check, STRV_EMPTY)
assert_not_reached();
unsigned count = 0;
@@ -1049,7 +1049,7 @@ TEST(strv_fnmatch) {
_cleanup_strv_free_ char **v = NULL;
size_t pos;
assert_se(!strv_fnmatch(STRV_MAKE_EMPTY, "a"));
assert_se(!strv_fnmatch(STRV_EMPTY, "a"));
v = strv_new("xxx", "*\\*", "yyy");
assert_se(!strv_fnmatch_full(v, "\\", 0, NULL));
+1 -1
View File
@@ -43,7 +43,7 @@ TEST(verbs) {
test_dispatch_one(STRV_MAKE("copy-to", "foo", "bar", "baz", "quux", "qaax"), verbs, -EINVAL);
/* no verb, but a default is set */
test_dispatch_one(STRV_MAKE_EMPTY, verbs, 0);
test_dispatch_one(STRV_EMPTY, verbs, 0);
}
TEST(verbs_no_default) {