From 5152b8459afc6570efa537605d3bbf47c067661e Mon Sep 17 00:00:00 2001 From: Ivan Kruglov Date: Mon, 8 Apr 2024 17:12:48 +0200 Subject: [PATCH] ASSERT_NULL/ASSERT_NOT_NULL --- src/test/test-cgroup-util.c | 4 +- src/test/test-cgroup.c | 4 +- src/test/test-conf-parser.c | 2 +- src/test/test-core-unit.c | 2 +- src/test/test-creds.c | 12 ++--- src/test/test-env-file.c | 12 ++--- src/test/test-env-util.c | 4 +- src/test/test-extract-word.c | 24 +++++----- src/test/test-fileio.c | 10 ++--- src/test/test-glob-util.c | 4 +- src/test/test-hashmap-plain.c | 24 +++++----- src/test/test-hashmap.c | 6 +-- src/test/test-json.c | 4 +- src/test/test-list.c | 80 +++++++++++++++++----------------- src/test/test-load-fragment.c | 28 ++++++------ src/test/test-loop-block.c | 2 +- src/test/test-macro.c | 12 ++--- src/test/test-mount-util.c | 6 +-- src/test/test-netlink-manual.c | 6 +-- src/test/test-openssl.c | 2 +- src/test/test-parse-argument.c | 2 +- src/test/test-path-util.c | 4 +- src/test/test-prioq.c | 10 ++--- src/test/test-process-util.c | 2 +- src/test/test-rlimit-util.c | 2 +- src/test/test-secure-bits.c | 2 +- src/test/test-socket-bind.c | 2 +- src/test/test-strbuf.c | 4 +- src/test/test-string-util.c | 6 +-- src/test/test-strv.c | 18 ++++---- src/test/test-tpm2.c | 2 +- src/test/test-watch-pid.c | 6 +-- 32 files changed, 154 insertions(+), 154 deletions(-) diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c index 13e0dde4b4c7d..1e09b9e1856a7 100644 --- a/src/test/test-cgroup-util.c +++ b/src/test/test-cgroup-util.c @@ -402,7 +402,7 @@ TEST(cg_get_keyed_attribute) { } assert_se(r == -ENOENT); - assert_se(val == NULL); + ASSERT_NULL(val); if (access("/sys/fs/cgroup/init.scope/cpu.stat", R_OK) < 0) { log_info_errno(errno, "Skipping most of %s, /init.scope/cpu.stat not accessible: %m", __func__); @@ -411,7 +411,7 @@ TEST(cg_get_keyed_attribute) { assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("no_such_attr"), &val) == -ENXIO); assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("no_such_attr"), &val) == 0); - assert_se(val == NULL); + ASSERT_NULL(val); assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec"), &val) == 0); val = mfree(val); diff --git a/src/test/test-cgroup.c b/src/test/test-cgroup.c index 06cf886729654..703c8f6c0368f 100644 --- a/src/test/test-cgroup.c +++ b/src/test/test-cgroup.c @@ -31,13 +31,13 @@ TEST(cg_split_spec) { assert_se(cg_split_spec("fo/obar:/", &c, &p) < 0); assert_se(cg_split_spec("/", &c, &p) >= 0); - assert_se(c == NULL); + ASSERT_NULL(c); assert_se(streq(p, "/")); p = mfree(p); assert_se(cg_split_spec("foo", &c, &p) >= 0); assert_se(streq(c, "foo")); - assert_se(p == NULL); + ASSERT_NULL(p); c = mfree(c); } diff --git a/src/test/test-conf-parser.c b/src/test/test-conf-parser.c index d0d7419eaaf54..ab54107655aea 100644 --- a/src/test/test-conf-parser.c +++ b/src/test/test-conf-parser.c @@ -377,7 +377,7 @@ static void test_config_parse_one(unsigned i, const char *s) { case 15 ... 16: assert_se(r == -ENOBUFS); - assert_se(setting1 == NULL); + ASSERT_NULL(setting1); break; case 17: diff --git a/src/test/test-core-unit.c b/src/test/test-core-unit.c index dc108cc2efef4..f72a67c60c814 100644 --- a/src/test/test-core-unit.c +++ b/src/test/test-core-unit.c @@ -26,7 +26,7 @@ static void test_unit_escape_setting_one( assert_se(t = unit_escape_setting(s, 0, &a)); assert_se(a_esc = cescape(t)); log_debug("%s: [%s] → [%s]", __func__, s_esc, a_esc); - assert_se(a == NULL); + ASSERT_NULL(a); assert_se(t == s); assert_se(t = unit_escape_setting(s, UNIT_ESCAPE_EXEC_SYNTAX_ENV, &b)); diff --git a/src/test/test-creds.c b/src/test/test-creds.c index b4beafc31d627..128788c43711f 100644 --- a/src/test/test-creds.c +++ b/src/test/test-creds.c @@ -23,28 +23,28 @@ TEST(read_credential_strings) { assert_se(saved = strdup(e)); assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0); - assert_se(x == NULL); - assert_se(y == NULL); + ASSERT_NULL(x); + ASSERT_NULL(y); assert_se(mkdtemp_malloc(NULL, &tmp) >= 0); assert_se(setenv("CREDENTIALS_DIRECTORY", tmp, /* override= */ true) >= 0); assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0); - assert_se(x == NULL); - assert_se(y == NULL); + ASSERT_NULL(x); + ASSERT_NULL(y); assert_se(p = path_join(tmp, "bar")); assert_se(write_string_file(p, "piff", WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_AVOID_NEWLINE) >= 0); assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0); - assert_se(x == NULL); + ASSERT_NULL(x); assert_se(streq(y, "piff")); assert_se(write_string_file(p, "paff", WRITE_STRING_FILE_TRUNCATE|WRITE_STRING_FILE_AVOID_NEWLINE) >= 0); assert_se(read_credential_strings_many("foo", &x, "bar", &y) == 0); - assert_se(x == NULL); + ASSERT_NULL(x); assert_se(streq(y, "paff")); p = mfree(p); diff --git a/src/test/test-env-file.c b/src/test/test-env-file.c index 3fc6d623fdd46..e2fce7f53d1b2 100644 --- a/src/test/test-env-file.c +++ b/src/test/test-env-file.c @@ -71,7 +71,7 @@ TEST(load_env_file_1) { assert_se(streq(data[3], "g=g ")); assert_se(streq(data[4], "h=ąęół śćńźżμ")); assert_se(streq(data[5], "i=i")); - assert_se(data[6] == NULL); + ASSERT_NULL(data[6]); } TEST(load_env_file_2) { @@ -81,7 +81,7 @@ TEST(load_env_file_2) { _cleanup_strv_free_ char **data = NULL; assert_se(load_env_file(NULL, name, &data) == 0); assert_se(streq(data[0], "a=a")); - assert_se(data[1] == NULL); + ASSERT_NULL(data[1]); } TEST(load_env_file_3) { @@ -92,7 +92,7 @@ TEST(load_env_file_3) { assert_se(load_env_file(NULL, name, &data) == 0); assert_se(streq(data[0], "normal1=line111")); assert_se(streq(data[1], "normal2=line222")); - assert_se(data[2] == NULL); + ASSERT_NULL(data[2]); } TEST(load_env_file_4) { @@ -104,7 +104,7 @@ TEST(load_env_file_4) { assert_se(streq(data[0], "HWMON_MODULES=coretemp f71882fg")); assert_se(streq(data[1], "MODULE_0=coretemp")); assert_se(streq(data[2], "MODULE_1=f71882fg")); - assert_se(data[3] == NULL); + ASSERT_NULL(data[3]); } TEST(load_env_file_5) { @@ -115,7 +115,7 @@ TEST(load_env_file_5) { assert_se(load_env_file(NULL, name, &data) == 0); assert_se(streq(data[0], "a=")); assert_se(streq(data[1], "b=")); - assert_se(data[2] == NULL); + ASSERT_NULL(data[2]); } TEST(load_env_file_6) { @@ -128,7 +128,7 @@ TEST(load_env_file_6) { assert_se(streq(data[1], "b=$'")); assert_se(streq(data[2], "c= \\n\\t\\$\\`\\\\\n")); assert_se(streq(data[3], "d= \\n\\t$`\\\n")); - assert_se(data[4] == NULL); + ASSERT_NULL(data[4]); } TEST(load_env_file_invalid_utf8) { diff --git a/src/test/test-env-util.c b/src/test/test-env-util.c index c267c2e341891..6b7520bfb0bda 100644 --- a/src/test/test-env-util.c +++ b/src/test/test-env-util.c @@ -401,7 +401,7 @@ TEST(env_clean) { assert_se(streq(e[5], "another=final one")); assert_se(streq(e[6], "CRLF=\r\n")); assert_se(streq(e[7], "LESS_TERMCAP_mb=\x1b[01;31m")); - assert_se(e[8] == NULL); + ASSERT_NULL(e[8]); } TEST(env_name_is_valid) { @@ -576,7 +576,7 @@ TEST(getenv_path_list) { assert_se(streq(path_list[2], "/hello/world")); assert_se(streq(path_list[3], "/path with spaces")); assert_se(streq(path_list[4], "/final")); - assert_se(path_list[5] == NULL); + ASSERT_NULL(path_list[5]); assert_se(unsetenv("TEST_GETENV_PATH_LIST") >= 0); } diff --git a/src/test/test-extract-word.c b/src/test/test-extract-word.c index 0f10fe7e6f5aa..beb8f5db2207b 100644 --- a/src/test/test-extract-word.c +++ b/src/test/test-extract-word.c @@ -325,7 +325,7 @@ TEST(extract_first_word) { assert_se(extract_first_word(&p, &t, ":", EXTRACT_DONT_COALESCE_SEPARATORS) == 1); assert_se(streq(t, "")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); assert_se(extract_first_word(&p, &t, ":", EXTRACT_DONT_COALESCE_SEPARATORS) == 0); assert_se(!t); @@ -335,25 +335,25 @@ TEST(extract_first_word) { assert_se(extract_first_word(&p, &t, NULL, 0) > 0); assert_se(streq(t, "fooxbar")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "foo\\xbar"; assert_se(extract_first_word(&p, &t, NULL, EXTRACT_RETAIN_ESCAPE) > 0); assert_se(streq(t, "foo\\xbar")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "\\:"; assert_se(extract_first_word(&p, &t, ":", EXTRACT_UNESCAPE_SEPARATORS) == 1); assert_se(streq(t, ":")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "a\\:b"; assert_se(extract_first_word(&p, &t, ":", EXTRACT_UNESCAPE_SEPARATORS) == 1); assert_se(streq(t, "a:b")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "a\\ b:c"; assert_se(extract_first_word(&p, &t, WHITESPACE ":", EXTRACT_UNESCAPE_SEPARATORS) == 1); @@ -362,7 +362,7 @@ TEST(extract_first_word) { assert_se(extract_first_word(&p, &t, WHITESPACE ":", EXTRACT_UNESCAPE_SEPARATORS) == 1); assert_se(streq(t, "c")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "a\\ b:c\\x"; assert_se(extract_first_word(&p, &t, ":", EXTRACT_UNESCAPE_SEPARATORS) == -EINVAL); @@ -374,19 +374,19 @@ TEST(extract_first_word) { assert_se(extract_first_word(&p, &t, ":", EXTRACT_UNESCAPE_SEPARATORS) == 1); assert_se(streq(t, "c\\x")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "\\:"; assert_se(extract_first_word(&p, &t, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS) == 1); assert_se(streq(t, ":")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "a\\:b"; assert_se(extract_first_word(&p, &t, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS) == 1); assert_se(streq(t, "a:b")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "a\\ b:c"; assert_se(extract_first_word(&p, &t, WHITESPACE ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS) == 1); @@ -395,7 +395,7 @@ TEST(extract_first_word) { assert_se(extract_first_word(&p, &t, WHITESPACE ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS) == 1); assert_se(streq(t, "c")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "a\\ b:c\\x"; assert_se(extract_first_word(&p, &t, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS) == -EINVAL); @@ -407,7 +407,7 @@ TEST(extract_first_word) { assert_se(extract_first_word(&p, &t, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS) == 1); assert_se(streq(t, "c\\x")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = "\\:"; assert_se(extract_first_word(&p, &t, ":", EXTRACT_CUNESCAPE) == -EINVAL); @@ -426,7 +426,7 @@ TEST(extract_first_word) { assert_se(extract_first_word(&p, &t, WHITESPACE ":", EXTRACT_CUNESCAPE) == 1); assert_se(streq(t, "c")); free(t); - assert_se(p == NULL); + ASSERT_NULL(p); p = original = "foobar=\"waldo\"maldo, baldo"; assert_se(extract_first_word(&p, &t, "=\", ", 0) > 0); diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c index ad98a920601d6..67437ea9d9f00 100644 --- a/src/test/test-fileio.c +++ b/src/test/test-fileio.c @@ -84,7 +84,7 @@ TEST(parse_env_file) { assert_se(streq_ptr(a[10], "eleven=value")); assert_se(streq_ptr(a[11], "twelve=\\value")); assert_se(streq_ptr(a[12], "thirteen=\\value")); - assert_se(a[13] == NULL); + ASSERT_NULL(a[13]); strv_env_clean(a); @@ -134,7 +134,7 @@ TEST(parse_env_file) { assert_se(streq(seven, "sevenval#nocomment")); assert_se(streq(eight, "eightval #nocomment")); assert_se(streq(nine, "nineval")); - assert_se(ten == NULL); + ASSERT_NULL(ten); assert_se(streq(eleven, "value")); assert_se(streq(twelve, "\\value")); assert_se(streq(thirteen, "\\value")); @@ -201,7 +201,7 @@ TEST(parse_multiline_env_file) { assert_se(streq_ptr(a[0], "one=BAR VAR\tGAR")); assert_se(streq_ptr(a[1], "two=bar var\tgar")); assert_se(streq_ptr(a[2], "tri=bar var \tgar ")); - assert_se(a[3] == NULL); + ASSERT_NULL(a[3]); { _cleanup_close_ int fd = mkostemp_safe(p); @@ -256,7 +256,7 @@ TEST(merge_env_file) { assert_se(streq(a[7], "zzz=replacement")); assert_se(streq(a[8], "zzzz=")); assert_se(streq(a[9], "zzzzz=")); - assert_se(a[10] == NULL); + ASSERT_NULL(a[10]); r = merge_env_file(&a, NULL, t); assert_se(r >= 0); @@ -275,7 +275,7 @@ TEST(merge_env_file) { assert_se(streq(a[7], "zzz=replacement")); assert_se(streq(a[8], "zzzz=")); assert_se(streq(a[9], "zzzzz=")); - assert_se(a[10] == NULL); + ASSERT_NULL(a[10]); } TEST(merge_env_file_invalid) { diff --git a/src/test/test-glob-util.c b/src/test/test-glob-util.c index 9b3e73cce0172..4fa47498c3ae0 100644 --- a/src/test/test-glob-util.c +++ b/src/test/test-glob-util.c @@ -31,7 +31,7 @@ TEST(glob_first) { assert_se(r == 0); r = glob_first("/tmp/test-glob_first*", &first); assert_se(r == 0); - assert_se(first == NULL); + ASSERT_NULL(first); } TEST(glob_exists) { @@ -110,7 +110,7 @@ TEST(safe_glob) { assert_se(r == 0); assert_se(g.gl_pathc == 1); assert_se(streq(g.gl_pathv[0], fname)); - assert_se(g.gl_pathv[1] == NULL); + ASSERT_NULL(g.gl_pathv[1]); (void) rm_rf(template, REMOVE_ROOT|REMOVE_PHYSICAL); } diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c index 0d1f84579442f..75195887ff797 100644 --- a/src/test/test-hashmap-plain.c +++ b/src/test/test-hashmap-plain.c @@ -231,13 +231,13 @@ TEST(hashmap_remove1) { char *r; r = hashmap_remove(NULL, "key 1"); - assert_se(r == NULL); + ASSERT_NULL(r); m = hashmap_new(&string_hash_ops); assert_se(m); r = hashmap_remove(m, "no such key"); - assert_se(r == NULL); + ASSERT_NULL(r); hashmap_put(m, "key 1", (void*) "val 1"); hashmap_put(m, "key 2", (void*) "val 2"); @@ -259,13 +259,13 @@ TEST(hashmap_remove2) { void *r, *r2; r = hashmap_remove2(NULL, "key 1", &r2); - assert_se(r == NULL); + ASSERT_NULL(r); m = hashmap_new(&string_hash_ops); assert_se(m); r = hashmap_remove2(m, "no such key", &r2); - assert_se(r == NULL); + ASSERT_NULL(r); hashmap_put(m, strdup(key1), strdup(val1)); hashmap_put(m, strdup(key2), strdup(val2)); @@ -289,13 +289,13 @@ TEST(hashmap_remove_value) { char val2[] = "val 2"; r = hashmap_remove_value(NULL, "key 1", val1); - assert_se(r == NULL); + ASSERT_NULL(r); m = hashmap_new(&string_hash_ops); assert_se(m); r = hashmap_remove_value(m, "key 1", val1); - assert_se(r == NULL); + ASSERT_NULL(r); hashmap_put(m, "key 1", val1); hashmap_put(m, "key 2", val2); @@ -308,7 +308,7 @@ TEST(hashmap_remove_value) { assert_se(!hashmap_get(m, "key 1")); r = hashmap_remove_value(m, "key 2", val1); - assert_se(r == NULL); + ASSERT_NULL(r); r = hashmap_get(m, "key 2"); assert_se(streq(r, "val 2")); @@ -599,7 +599,7 @@ TEST(hashmap_get) { assert_se(val); r = hashmap_get(NULL, "Key 1"); - assert_se(r == NULL); + ASSERT_NULL(r); m = hashmap_new(&string_hash_ops); @@ -609,7 +609,7 @@ TEST(hashmap_get) { assert_se(streq(r, val)); r = hashmap_get(m, "no such key"); - assert_se(r == NULL); + ASSERT_NULL(r); assert_se(m); } @@ -628,7 +628,7 @@ TEST(hashmap_get2) { assert_se(key_copy); r = hashmap_get2(NULL, key_orig, &key_copy); - assert_se(r == NULL); + ASSERT_NULL(r); m = hashmap_new(&string_hash_ops); @@ -641,7 +641,7 @@ TEST(hashmap_get2) { assert_se(streq(key_orig, key_copy)); r = hashmap_get2(m, "no such key", NULL); - assert_se(r == NULL); + ASSERT_NULL(r); assert_se(m); } @@ -801,7 +801,7 @@ TEST(hashmap_first_key) { assert_se(hashmap_put(m, "key 2", NULL) == 1); #ifdef ORDERED assert_se(streq(hashmap_first_key(m), "key 1")); - assert_se(hashmap_remove(m, "key 1") == NULL); + ASSERT_NULL(hashmap_remove(m, "key 1")); assert_se(streq(hashmap_first_key(m), "key 2")); #endif } diff --git a/src/test/test-hashmap.c b/src/test/test-hashmap.c index cf4fca27e3f7a..7ff270c3e08ef 100644 --- a/src/test/test-hashmap.c +++ b/src/test/test-hashmap.c @@ -98,8 +98,8 @@ TEST(iterated_cache) { hashmap_clear(m); compare_cache(m, c); - assert_se(hashmap_free(m) == NULL); - assert_se(iterated_cache_free(c) == NULL); + ASSERT_NULL(hashmap_free(m)); + ASSERT_NULL(iterated_cache_free(c)); } TEST(hashmap_put_strdup) { @@ -147,7 +147,7 @@ TEST(hashmap_put_strdup_null) { assert_se(hashmap_contains(m, "xxx")); s = hashmap_get(m, "xxx"); - assert_se(s == NULL); + ASSERT_NULL(s); } /* This file tests in test-hashmap-plain.c, and tests in test-hashmap-ordered.c, which is generated diff --git a/src/test/test-json.c b/src/test/test-json.c index cb0adc2643774..2762ca64a5c94 100644 --- a/src/test/test-json.c +++ b/src/test/test-json.c @@ -362,7 +362,7 @@ TEST(json_parse_file_empty) { assert_se(fopen_unlocked("/dev/null", "re", &f) >= 0); assert_se(json_parse_file(f, "waldo", 0, &v, NULL, NULL) == -ENODATA); - assert_se(v == NULL); + ASSERT_NULL(v); } TEST(json_parse_file_invalid) { @@ -371,7 +371,7 @@ TEST(json_parse_file_invalid) { assert_se(f = fmemopen_unlocked((void*) "kookoo", 6, "r")); assert_se(json_parse_file(f, "waldo", 0, &v, NULL, NULL) == -EINVAL); - assert_se(v == NULL); + ASSERT_NULL(v); } TEST(source) { diff --git a/src/test/test-list.c b/src/test/test-list.c index 87f7c7b3d466f..6c6407028468b 100644 --- a/src/test/test-list.c +++ b/src/test/test-list.c @@ -17,8 +17,8 @@ int main(int argc, const char *argv[]) { LIST_HEAD_INIT(head); LIST_HEAD_INIT(head2); - assert_se(head == NULL); - assert_se(head2 == NULL); + ASSERT_NULL(head); + ASSERT_NULL(head2); for (i = 0; i < ELEMENTSOF(items); i++) { LIST_INIT(item_list, &items[i]); @@ -49,7 +49,7 @@ int main(int argc, const char *argv[]) { assert_se(!LIST_JUST_US(item_list, head)); - assert_se(items[0].item_list_next == NULL); + ASSERT_NULL(items[0].item_list_next); assert_se(items[1].item_list_next == &items[0]); assert_se(items[2].item_list_next == &items[1]); assert_se(items[3].item_list_next == &items[2]); @@ -57,7 +57,7 @@ int main(int argc, const char *argv[]) { assert_se(items[0].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[2]); assert_se(items[2].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); list_item *cursor = LIST_FIND_HEAD(item_list, &items[0]); assert_se(cursor == &items[3]); @@ -68,16 +68,16 @@ int main(int argc, const char *argv[]) { assert_se(LIST_REMOVE(item_list, head, &items[1]) == &items[1]); assert_se(LIST_JUST_US(item_list, &items[1])); - assert_se(items[0].item_list_next == NULL); + ASSERT_NULL(items[0].item_list_next); assert_se(items[2].item_list_next == &items[0]); assert_se(items[3].item_list_next == &items[2]); assert_se(items[0].item_list_prev == &items[2]); assert_se(items[2].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_INSERT_AFTER(item_list, head, &items[3], &items[1]) == &items[1]); - assert_se(items[0].item_list_next == NULL); + ASSERT_NULL(items[0].item_list_next); assert_se(items[2].item_list_next == &items[0]); assert_se(items[1].item_list_next == &items[2]); assert_se(items[3].item_list_next == &items[1]); @@ -85,21 +85,21 @@ int main(int argc, const char *argv[]) { assert_se(items[0].item_list_prev == &items[2]); assert_se(items[2].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_REMOVE(item_list, head, &items[1]) == &items[1]); assert_se(LIST_JUST_US(item_list, &items[1])); - assert_se(items[0].item_list_next == NULL); + ASSERT_NULL(items[0].item_list_next); assert_se(items[2].item_list_next == &items[0]); assert_se(items[3].item_list_next == &items[2]); assert_se(items[0].item_list_prev == &items[2]); assert_se(items[2].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_INSERT_BEFORE(item_list, head, &items[2], &items[1]) == &items[1]); - assert_se(items[0].item_list_next == NULL); + ASSERT_NULL(items[0].item_list_next); assert_se(items[2].item_list_next == &items[0]); assert_se(items[1].item_list_next == &items[2]); assert_se(items[3].item_list_next == &items[1]); @@ -107,21 +107,21 @@ int main(int argc, const char *argv[]) { assert_se(items[0].item_list_prev == &items[2]); assert_se(items[2].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_REMOVE(item_list, head, &items[0]) == &items[0]); assert_se(LIST_JUST_US(item_list, &items[0])); - assert_se(items[2].item_list_next == NULL); + ASSERT_NULL(items[2].item_list_next); assert_se(items[1].item_list_next == &items[2]); assert_se(items[3].item_list_next == &items[1]); assert_se(items[2].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_INSERT_BEFORE(item_list, head, &items[3], &items[0]) == &items[0]); - assert_se(items[2].item_list_next == NULL); + ASSERT_NULL(items[2].item_list_next); assert_se(items[1].item_list_next == &items[2]); assert_se(items[3].item_list_next == &items[1]); assert_se(items[0].item_list_next == &items[3]); @@ -129,22 +129,22 @@ int main(int argc, const char *argv[]) { assert_se(items[2].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[3]); assert_se(items[3].item_list_prev == &items[0]); - assert_se(items[0].item_list_prev == NULL); + ASSERT_NULL(items[0].item_list_prev); assert_se(head == &items[0]); assert_se(LIST_REMOVE(item_list, head, &items[0]) == &items[0]); assert_se(LIST_JUST_US(item_list, &items[0])); - assert_se(items[2].item_list_next == NULL); + ASSERT_NULL(items[2].item_list_next); assert_se(items[1].item_list_next == &items[2]); assert_se(items[3].item_list_next == &items[1]); assert_se(items[2].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_INSERT_BEFORE(item_list, head, NULL, &items[0]) == &items[0]); - assert_se(items[0].item_list_next == NULL); + ASSERT_NULL(items[0].item_list_next); assert_se(items[2].item_list_next == &items[0]); assert_se(items[1].item_list_next == &items[2]); assert_se(items[3].item_list_next == &items[1]); @@ -152,27 +152,27 @@ int main(int argc, const char *argv[]) { assert_se(items[0].item_list_prev == &items[2]); assert_se(items[2].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_REMOVE(item_list, head, &items[0]) == &items[0]); assert_se(LIST_JUST_US(item_list, &items[0])); - assert_se(items[2].item_list_next == NULL); + ASSERT_NULL(items[2].item_list_next); assert_se(items[1].item_list_next == &items[2]); assert_se(items[3].item_list_next == &items[1]); assert_se(items[2].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_REMOVE(item_list, head, &items[1]) == &items[1]); assert_se(LIST_JUST_US(item_list, &items[1])); - assert_se(items[2].item_list_next == NULL); + ASSERT_NULL(items[2].item_list_next); assert_se(items[3].item_list_next == &items[2]); assert_se(items[2].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_REMOVE(item_list, head, &items[2]) == &items[2]); assert_se(LIST_JUST_US(item_list, &items[2])); @@ -181,7 +181,7 @@ int main(int argc, const char *argv[]) { assert_se(LIST_REMOVE(item_list, head, &items[3]) == &items[3]); assert_se(LIST_JUST_US(item_list, &items[3])); - assert_se(head == NULL); + ASSERT_NULL(head); for (i = 0; i < ELEMENTSOF(items); i++) { assert_se(LIST_JUST_US(item_list, &items[i])); @@ -193,9 +193,9 @@ int main(int argc, const char *argv[]) { assert_se(items[0].item_list_next == &items[1]); assert_se(items[1].item_list_next == &items[2]); assert_se(items[2].item_list_next == &items[3]); - assert_se(items[3].item_list_next == NULL); + ASSERT_NULL(items[3].item_list_next); - assert_se(items[0].item_list_prev == NULL); + ASSERT_NULL(items[0].item_list_prev); assert_se(items[1].item_list_prev == &items[0]); assert_se(items[2].item_list_prev == &items[1]); assert_se(items[3].item_list_prev == &items[2]); @@ -203,7 +203,7 @@ int main(int argc, const char *argv[]) { for (i = 0; i < ELEMENTSOF(items); i++) assert_se(LIST_REMOVE(item_list, head, &items[i]) == &items[i]); - assert_se(head == NULL); + ASSERT_NULL(head); for (i = 0; i < ELEMENTSOF(items) / 2; i++) { LIST_INIT(item_list, &items[i]); @@ -217,20 +217,20 @@ int main(int argc, const char *argv[]) { assert_se(LIST_PREPEND(item_list, head2, &items[i]) == &items[i]); } - assert_se(items[0].item_list_next == NULL); + ASSERT_NULL(items[0].item_list_next); assert_se(items[1].item_list_next == &items[0]); - assert_se(items[2].item_list_next == NULL); + ASSERT_NULL(items[2].item_list_next); assert_se(items[3].item_list_next == &items[2]); assert_se(items[0].item_list_prev == &items[1]); - assert_se(items[1].item_list_prev == NULL); + ASSERT_NULL(items[1].item_list_prev); assert_se(items[2].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_JOIN(item_list, head2, head) == head2); - assert_se(head == NULL); + ASSERT_NULL(head); - assert_se(items[0].item_list_next == NULL); + ASSERT_NULL(items[0].item_list_next); assert_se(items[1].item_list_next == &items[0]); assert_se(items[2].item_list_next == &items[1]); assert_se(items[3].item_list_next == &items[2]); @@ -238,16 +238,16 @@ int main(int argc, const char *argv[]) { assert_se(items[0].item_list_prev == &items[1]); assert_se(items[1].item_list_prev == &items[2]); assert_se(items[2].item_list_prev == &items[3]); - assert_se(items[3].item_list_prev == NULL); + ASSERT_NULL(items[3].item_list_prev); assert_se(LIST_JOIN(item_list, head, head2) == head); - assert_se(head2 == NULL); + ASSERT_NULL(head2); assert_se(head); for (i = 0; i < ELEMENTSOF(items); i++) assert_se(LIST_REMOVE(item_list, head, &items[i]) == &items[i]); - assert_se(head == NULL); + ASSERT_NULL(head); assert_se(LIST_PREPEND(item_list, head, items + 0) == items + 0); assert_se(LIST_PREPEND(item_list, head, items + 1) == items + 1); @@ -256,7 +256,7 @@ int main(int argc, const char *argv[]) { assert_se(LIST_POP(item_list, head) == items + 2); assert_se(LIST_POP(item_list, head) == items + 1); assert_se(LIST_POP(item_list, head) == items + 0); - assert_se(LIST_POP(item_list, head) == NULL); + ASSERT_NULL(LIST_POP(item_list, head)); /* No-op on an empty list */ @@ -269,7 +269,7 @@ int main(int argc, const char *argv[]) { LIST_CLEAR(item_list, head, free); - assert_se(head == NULL); + ASSERT_NULL(head); /* A list can be cleared partially */ @@ -280,7 +280,7 @@ int main(int argc, const char *argv[]) { LIST_CLEAR(item_list, head->item_list_next, free); assert_se(head == items + 0); - assert_se(head->item_list_next == NULL); + ASSERT_NULL(head->item_list_next); return 0; } diff --git a/src/test/test-load-fragment.c b/src/test/test-load-fragment.c index 8d2cec0c01bd6..658aa8878ee8d 100644 --- a/src/test/test-load-fragment.c +++ b/src/test/test-load-fragment.c @@ -139,7 +139,7 @@ TEST(config_parse_exec) { "LValue", 0, "/RValue/ argv0 r1", &c, u); assert_se(r == -ENOEXEC); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* honour_argv0 */"); r = config_parse_exec(NULL, "fake", 3, "section", 1, @@ -154,14 +154,14 @@ TEST(config_parse_exec) { "LValue", 0, "@/RValue", &c, u); assert_se(r == -ENOEXEC); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* no command, whitespace only, reset */"); r = config_parse_exec(NULL, "fake", 3, "section", 1, "LValue", 0, "", &c, u); assert_se(r == 0); - assert_se(c == NULL); + ASSERT_NULL(c); log_info("/* ignore && honour_argv0 */"); r = config_parse_exec(NULL, "fake", 4, "section", 1, @@ -184,14 +184,14 @@ TEST(config_parse_exec) { "LValue", 0, "--/RValue argv0 r1", &c, u); assert_se(r == 0); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* ignore && ignore (2) */"); r = config_parse_exec(NULL, "fake", 4, "section", 1, "LValue", 0, "-@-/RValue argv0 r1", &c, u); assert_se(r == 0); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* semicolon */"); r = config_parse_exec(NULL, "fake", 5, "section", 1, @@ -227,7 +227,7 @@ TEST(config_parse_exec) { c1 = c1->command_next; check_execcommand(c1, "/RValue", "argv0", "r1", NULL, true); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* trailing semicolon, no whitespace */"); r = config_parse_exec(NULL, "fake", 5, "section", 1, @@ -238,7 +238,7 @@ TEST(config_parse_exec) { c1 = c1->command_next; check_execcommand(c1, "/RValue", "argv0", "r1", NULL, true); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* trailing semicolon in single quotes */"); r = config_parse_exec(NULL, "fake", 5, "section", 1, @@ -366,7 +366,7 @@ TEST(config_parse_exec) { "LValue", 0, path, &c, u); assert_se(r == -ENOEXEC); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); } log_info("/* valid character: \\s */"); @@ -392,35 +392,35 @@ TEST(config_parse_exec) { "LValue", 0, "/path\\", &c, u); assert_se(r == -ENOEXEC); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* missing ending ' */"); r = config_parse_exec(NULL, "fake", 4, "section", 1, "LValue", 0, "/path 'foo", &c, u); assert_se(r == -ENOEXEC); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* missing ending ' with trailing backslash */"); r = config_parse_exec(NULL, "fake", 4, "section", 1, "LValue", 0, "/path 'foo\\", &c, u); assert_se(r == -ENOEXEC); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* invalid space between modifiers */"); r = config_parse_exec(NULL, "fake", 4, "section", 1, "LValue", 0, "- /path", &c, u); assert_se(r == 0); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* only modifiers, no path */"); r = config_parse_exec(NULL, "fake", 4, "section", 1, "LValue", 0, "-", &c, u); assert_se(r == 0); - assert_se(c1->command_next == NULL); + ASSERT_NULL(c1->command_next); log_info("/* long arg */"); /* See issue #22957. */ @@ -442,7 +442,7 @@ TEST(config_parse_exec) { "LValue", 0, "", &c, u); assert_se(r == 0); - assert_se(c == NULL); + ASSERT_NULL(c); exec_command_free_list(c); } diff --git a/src/test/test-loop-block.c b/src/test/test-loop-block.c index 1bd00d1af1108..27a41e863d224 100644 --- a/src/test/test-loop-block.c +++ b/src/test/test-loop-block.c @@ -328,7 +328,7 @@ static int run(int argc, char *argv[]) { log_notice("All threads started now."); if (arg_n_threads == 1) - assert_se(thread_func(FD_TO_PTR(fd)) == NULL); + ASSERT_NULL(thread_func(FD_TO_PTR(fd))); else for (unsigned i = 0; i < arg_n_threads; i++) { log_notice("Joining thread #%u.", i); diff --git a/src/test/test-macro.c b/src/test/test-macro.c index 017a20f540ae1..6a6e7a0962f94 100644 --- a/src/test/test-macro.c +++ b/src/test/test-macro.c @@ -500,12 +500,12 @@ TEST(FOREACH_ARGUMENT) { FOREACH_ARGUMENT(p, p_1, NULL, p_2, p_3, NULL, p_4, NULL) { switch (i++) { case 0: assert_se(p == p_1); break; - case 1: assert_se(p == NULL); break; + case 1: ASSERT_NULL(p); break; case 2: assert_se(p == p_2); break; case 3: assert_se(p == p_3); break; - case 4: assert_se(p == NULL); break; + case 4: ASSERT_NULL(p); break; case 5: assert_se(p == p_4); break; - case 6: assert_se(p == NULL); break; + case 6: ASSERT_NULL(p); break; default: assert_se(false); } } @@ -525,20 +525,20 @@ TEST(FOREACH_ARGUMENT) { FOREACH_ARGUMENT(v, v_1, NULL, u32p, v_3, p_2, p_4, v_2, NULL) { switch (i++) { case 0: assert_se(v == v_1); break; - case 1: assert_se(v == NULL); break; + case 1: ASSERT_NULL(v); break; case 2: assert_se(v == u32p); break; case 3: assert_se(v == v_3); break; case 4: assert_se(v == p_2); break; case 5: assert_se(v == p_4); break; case 6: assert_se(v == v_2); break; - case 7: assert_se(v == NULL); break; + case 7: ASSERT_NULL(v); break; default: assert_se(false); } } assert_se(i == 8); i = 0; FOREACH_ARGUMENT(v, NULL) { - assert_se(v == NULL); + ASSERT_NULL(v); assert_se(i++ == 0); } assert_se(i == 1); diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c index 77fce983b912a..9bacc7b511244 100644 --- a/src/test/test-mount-util.c +++ b/src/test/test-mount-util.c @@ -31,15 +31,15 @@ TEST(mount_option_mangle) { assert_se(mount_option_mangle(NULL, MS_RDONLY|MS_NOSUID, &f, &opts) == 0); assert_se(f == (MS_RDONLY|MS_NOSUID)); - assert_se(opts == NULL); + ASSERT_NULL(opts); assert_se(mount_option_mangle("", MS_RDONLY|MS_NOSUID, &f, &opts) == 0); assert_se(f == (MS_RDONLY|MS_NOSUID)); - assert_se(opts == NULL); + ASSERT_NULL(opts); assert_se(mount_option_mangle("ro,nosuid,nodev,noexec", 0, &f, &opts) == 0); assert_se(f == (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC)); - assert_se(opts == NULL); + ASSERT_NULL(opts); assert_se(mount_option_mangle("ro,nosuid,nodev,noexec,mode=0755", 0, &f, &opts) == 0); assert_se(f == (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC)); diff --git a/src/test/test-netlink-manual.c b/src/test/test-netlink-manual.c index f03fcffc62461..8c1b0d407e36c 100644 --- a/src/test/test-netlink-manual.c +++ b/src/test/test-netlink-manual.c @@ -84,7 +84,7 @@ static int test_tunnel_configure(sd_netlink *rtnl) { assert_se(sd_netlink_call(rtnl, m, -1, 0) == 1); - assert_se((m = sd_netlink_message_unref(m)) == NULL); + ASSERT_NULL((m = sd_netlink_message_unref(m))); /* sit */ assert_se(sd_rtnl_message_new_link(rtnl, &n, RTM_NEWLINK, 0) >= 0); @@ -110,7 +110,7 @@ static int test_tunnel_configure(sd_netlink *rtnl) { assert_se(sd_netlink_call(rtnl, n, -1, 0) == 1); - assert_se((n = sd_netlink_message_unref(n)) == NULL); + ASSERT_NULL((n = sd_netlink_message_unref(n))); return EXIT_SUCCESS; } @@ -126,7 +126,7 @@ int main(int argc, char *argv[]) { r = test_tunnel_configure(rtnl); - assert_se((rtnl = sd_netlink_unref(rtnl)) == NULL); + ASSERT_NULL((rtnl = sd_netlink_unref(rtnl))); return r; } diff --git a/src/test/test-openssl.c b/src/test/test-openssl.c index dfdd1ab5b45d4..51dc492e965de 100644 --- a/src/test/test-openssl.c +++ b/src/test/test-openssl.c @@ -95,7 +95,7 @@ TEST(invalid) { DEFINE_HEX_PTR(key, "2d2d2d2d2d424547494e205055424c4943204b45592d2d2d2d2d0a4d466b7b"); assert_se(openssl_pkey_from_pem(key, key_len, &pkey) == -EIO); - assert_se(pkey == NULL); + ASSERT_NULL(pkey); } static const struct { diff --git a/src/test/test-parse-argument.c b/src/test/test-parse-argument.c index cf3d54288abb9..3772a874360e3 100644 --- a/src/test/test-parse-argument.c +++ b/src/test/test-parse-argument.c @@ -26,7 +26,7 @@ TEST(parse_path_argument) { assert_se(streq(path, "/")); assert_se(parse_path_argument("/", true, &path) == 0); - assert_se(path == NULL); + ASSERT_NULL(path); } TEST(parse_signal_argument) { diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c index 5f36ae49f05ff..139bed76c4df3 100644 --- a/src/test/test-path-util.c +++ b/src/test/test-path-util.c @@ -687,7 +687,7 @@ TEST(path_strv_resolve) { _cleanup_strv_free_ char **search_dirs = NULL; _cleanup_strv_free_ char **absolute_dirs = NULL; - assert_se(mkdtemp(tmp_dir) != NULL); + ASSERT_NOT_NULL(mkdtemp(tmp_dir)); search_dirs = strv_new("/dir1", "/dir2", "/dir3"); assert_se(search_dirs); @@ -986,7 +986,7 @@ TEST(path_find_last_component) { } TEST(last_path_component) { - assert_se(last_path_component(NULL) == NULL); + ASSERT_NULL(last_path_component(NULL)); assert_se(streq(last_path_component("a/b/c"), "c")); assert_se(streq(last_path_component("a/b/c/"), "c/")); assert_se(streq(last_path_component("/"), "/")); diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c index d1b1ce9170a39..92c22d3b20d78 100644 --- a/src/test/test-prioq.c +++ b/src/test/test-prioq.c @@ -70,10 +70,10 @@ TEST(struct) { assert_se(q = prioq_new((compare_func_t) test_compare)); assert_se(s = set_new(&test_hash_ops)); - assert_se(prioq_peek(q) == NULL); - assert_se(prioq_peek_by_index(q, 0) == NULL); - assert_se(prioq_peek_by_index(q, 1) == NULL); - assert_se(prioq_peek_by_index(q, UINT_MAX) == NULL); + ASSERT_NULL(prioq_peek(q)); + ASSERT_NULL(prioq_peek_by_index(q, 0)); + ASSERT_NULL(prioq_peek_by_index(q, 1)); + ASSERT_NULL(prioq_peek_by_index(q, UINT_MAX)); for (i = 0; i < SET_SIZE; i++) { assert_se(t = new0(struct test, 1)); @@ -87,7 +87,7 @@ TEST(struct) { for (i = 0; i < SET_SIZE; i++) assert_se(prioq_peek_by_index(q, i)); - assert_se(prioq_peek_by_index(q, SET_SIZE) == NULL); + ASSERT_NULL(prioq_peek_by_index(q, SET_SIZE)); unsigned count = 0; PRIOQ_FOREACH_ITEM(q, t) { diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index 027b2a401eb1d..3b3fa9d12430c 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -651,7 +651,7 @@ TEST(safe_fork) { TEST(pid_to_ptr) { assert_se(PTR_TO_PID(NULL) == 0); - assert_se(PID_TO_PTR(0) == NULL); + ASSERT_NULL(PID_TO_PTR(0)); assert_se(PTR_TO_PID(PID_TO_PTR(1)) == 1); assert_se(PTR_TO_PID(PID_TO_PTR(2)) == 2); diff --git a/src/test/test-rlimit-util.c b/src/test/test-rlimit-util.c index e14f27df7935c..6a68d28090af6 100644 --- a/src/test/test-rlimit-util.c +++ b/src/test/test-rlimit-util.c @@ -119,7 +119,7 @@ TEST(setrlimit) { assert_se(setrlimit(RLIMIT_NOFILE, &new) >= 0); assert_se(streq_ptr(rlimit_to_string(RLIMIT_NOFILE), "NOFILE")); - assert_se(rlimit_to_string(-1) == NULL); + ASSERT_NULL(rlimit_to_string(-1)); assert_se(getrlimit(RLIMIT_NOFILE, &old) == 0); assert_se(setrlimit_closest(RLIMIT_NOFILE, &old) == 0); diff --git a/src/test/test-secure-bits.c b/src/test/test-secure-bits.c index 27e6a20e09d40..21cfe701570dd 100644 --- a/src/test/test-secure-bits.c +++ b/src/test/test-secure-bits.c @@ -61,7 +61,7 @@ TEST(secure_bits_basic) { /* Bits to string with check */ assert_se(secure_bits_to_string_alloc_with_check(INT_MAX, &str) == -EINVAL); - assert_se(str == NULL); + ASSERT_NULL(str); assert_se(secure_bits_to_string_alloc_with_check( (1 << SECURE_KEEP_CAPS) | (1 << SECURE_KEEP_CAPS_LOCKED), &str) >= 0); diff --git a/src/test/test-socket-bind.c b/src/test/test-socket-bind.c index 84a897801a559..fb65573e7a790 100644 --- a/src/test/test-socket-bind.c +++ b/src/test/test-socket-bind.c @@ -66,7 +66,7 @@ static int test_socket_bind( fputc('\n', stderr); exec_start = strjoin("-timeout --preserve-status -sSIGTERM 1s ", netcat_path, " -l ", port, " -vv"); - assert_se(exec_start != NULL); + ASSERT_NOT_NULL(exec_start); r = config_parse_exec(u->id, "filename", 1, "Service", 1, "ExecStart", SERVICE_EXEC_START, exec_start, SERVICE(u)->exec_command, u); diff --git a/src/test/test-strbuf.c b/src/test/test-strbuf.c index 39a7142b5bb64..7198c6734688a 100644 --- a/src/test/test-strbuf.c +++ b/src/test/test-strbuf.c @@ -37,7 +37,7 @@ TEST(strbuf) { assert_se(streq(l[2], "foo")); assert_se(streq(l[3], "bar")); assert_se(streq(l[4], "waldorf")); - assert_se(l[5] == NULL); + ASSERT_NULL(l[5]); assert_se(sb->nodes_count == 5); /* root + 4 non-duplicates */ assert_se(sb->dedup_count == 4); @@ -67,7 +67,7 @@ TEST(strbuf) { assert_se(streq(sb->buf + h, "")); strbuf_complete(sb); - assert_se(sb->root == NULL); + ASSERT_NULL(sb->root); } DEFINE_TEST_MAIN(LOG_INFO); diff --git a/src/test/test-string-util.c b/src/test/test-string-util.c index 67f332db8edb4..a84125d7228d7 100644 --- a/src/test/test-string-util.c +++ b/src/test/test-string-util.c @@ -460,7 +460,7 @@ static void check(const char *test, char** expected, bool trailing) { assert_se(streq(word, expected[i++])); printf("<%s>\n", word); } - assert_se(expected[i] == NULL); + ASSERT_NULL(expected[i]); } TEST(foreach_word_quoted) { @@ -802,7 +802,7 @@ TEST(string_contains_word_strv) { assert_se(streq(w, "a")); assert_se(!string_contains_word_strv("a b cc", NULL, STRV_MAKE("d"), &w)); - assert_se(w == NULL); + ASSERT_NULL(w); assert_se(string_contains_word_strv("a b cc", NULL, STRV_MAKE("b", "a"), &w)); assert_se(streq(w, "a")); @@ -814,7 +814,7 @@ TEST(string_contains_word_strv) { assert_se(streq(w, "b")); assert_se(!string_contains_word_strv("a b cc", NULL, STRV_MAKE(""), &w)); - assert_se(w == NULL); + ASSERT_NULL(w); assert_se(string_contains_word_strv("a b cc", " ", STRV_MAKE(""), &w)); assert_se(streq(w, "")); diff --git a/src/test/test-strv.c b/src/test/test-strv.c index 47ad0eb639c30..63a88c2301329 100644 --- a/src/test/test-strv.c +++ b/src/test/test-strv.c @@ -217,7 +217,7 @@ static void test_strv_unquote_one(const char *quoted, char **list) { STRV_FOREACH(t, s) assert_se(streq(list[i++], *t)); - assert_se(list[i] == NULL); + ASSERT_NULL(list[i]); } TEST(strv_unquote) { @@ -245,7 +245,7 @@ static void test_invalid_unquote_one(const char *quoted) { log_info("/* %s */", __func__); r = strv_split_full(&s, quoted, WHITESPACE, EXTRACT_UNQUOTE); - assert_se(s == NULL); + ASSERT_NULL(s); assert_se(r == -EINVAL); } @@ -601,7 +601,7 @@ TEST(strv_extend_with_size) { assert_se(streq(a[1], "test1")); assert_se(streq(a[2], "test2")); assert_se(streq(a[3], "test3")); - assert_se(a[4] == NULL); + ASSERT_NULL(a[4]); } TEST(strv_extend) { @@ -918,7 +918,7 @@ TEST(strv_extend_n) { assert_se(streq(v[4], "waldo")); assert_se(streq(v[5], "piep")); assert_se(streq(v[6], "piep")); - assert_se(v[7] == NULL); + ASSERT_NULL(v[7]); v = strv_free(v); @@ -926,7 +926,7 @@ TEST(strv_extend_n) { assert_se(strv_extend_n(&v, "bar", 0) >= 0); assert_se(streq(v[0], "foo")); - assert_se(v[1] == NULL); + ASSERT_NULL(v[1]); } TEST(foreach_string) { @@ -1013,10 +1013,10 @@ TEST(strv_copy_n) { TEST(strv_find_first_field) { char **haystack = STRV_MAKE("a", "b", "c", "d", "e", "f", "g", "h", "i", "j"); - assert_se(strv_find_first_field(NULL, NULL) == NULL); - assert_se(strv_find_first_field(NULL, haystack) == NULL); - assert_se(strv_find_first_field(STRV_MAKE("k", "l", "m", "d", "b"), NULL) == NULL); - assert_se(strv_find_first_field(STRV_MAKE("k", "l", "m", "d", "b"), haystack) == NULL); + ASSERT_NULL(strv_find_first_field(NULL, NULL)); + ASSERT_NULL(strv_find_first_field(NULL, haystack)); + ASSERT_NULL(strv_find_first_field(STRV_MAKE("k", "l", "m", "d", "b"), NULL)); + ASSERT_NULL(strv_find_first_field(STRV_MAKE("k", "l", "m", "d", "b"), haystack)); assert_se(streq_ptr(strv_find_first_field(STRV_MAKE("k", "l", "m", "d", "a", "c"), haystack), "b")); assert_se(streq_ptr(strv_find_first_field(STRV_MAKE("k", "l", "m", "d", "c", "a"), haystack), "d")); assert_se(streq_ptr(strv_find_first_field(STRV_MAKE("i", "k", "l", "m", "d", "c", "a", "b"), haystack), "j")); diff --git a/src/test/test-tpm2.c b/src/test/test-tpm2.c index 254c4c5e8bc22..0d42df9d9fce7 100644 --- a/src/test/test-tpm2.c +++ b/src/test/test-tpm2.c @@ -678,7 +678,7 @@ TEST(parse_pcr_argument) { assert_se(tpm2_parse_pcr_argument("1,2=123456abc", &v, &n_v) < 0); assert_se(tpm2_parse_pcr_argument("1,2:invalid", &v, &n_v) < 0); assert_se(tpm2_parse_pcr_argument("1:sha1=invalid", &v, &n_v) < 0); - assert_se(v == NULL); + ASSERT_NULL(v); assert_se(n_v == 0); check_parse_pcr_argument_to_mask("", 0x0); diff --git a/src/test/test-watch-pid.c b/src/test/test-watch-pid.c index 271af24c8040a..423a9be380259 100644 --- a/src/test/test-watch-pid.c +++ b/src/test/test-watch-pid.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) { assert_se(pid >= 0); assert_se(hashmap_isempty(m->watch_pids)); - assert_se(manager_get_unit_by_pid(m, pid) == NULL); + ASSERT_NULL(manager_get_unit_by_pid(m, pid)); assert_se(unit_watch_pid(a, pid, false) >= 0); assert_se(manager_get_unit_by_pid(m, pid) == a); @@ -93,10 +93,10 @@ int main(int argc, char *argv[]) { assert_se(manager_get_unit_by_pid(m, pid) == c); unit_unwatch_pid(c, pid); - assert_se(manager_get_unit_by_pid(m, pid) == NULL); + ASSERT_NULL(manager_get_unit_by_pid(m, pid)); unit_unwatch_pid(c, pid); - assert_se(manager_get_unit_by_pid(m, pid) == NULL); + ASSERT_NULL(manager_get_unit_by_pid(m, pid)); return 0; }