Drop the text argument from assert_not_reached()
In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
This commit is contained in:
@@ -46,7 +46,7 @@ int main(int argc, const char *argv[]) {
|
||||
bitmap_unset(b, 32);
|
||||
|
||||
BITMAP_FOREACH(n, NULL)
|
||||
assert_not_reached("NULL bitmap");
|
||||
assert_not_reached();
|
||||
|
||||
assert_se(bitmap_set(b, 0) == 0);
|
||||
assert_se(bitmap_set(b, 1) == 0);
|
||||
|
||||
@@ -72,7 +72,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
|
||||
@@ -284,7 +284,7 @@ static void test_linked_units(const char *root) {
|
||||
else if (q && streq(changes[i].path, q))
|
||||
q = NULL;
|
||||
else
|
||||
assert_not_reached("wut?");
|
||||
assert_not_reached();
|
||||
}
|
||||
assert(!p && !q);
|
||||
unit_file_changes_free(changes, n_changes);
|
||||
@@ -305,7 +305,7 @@ static void test_linked_units(const char *root) {
|
||||
else if (q && streq(changes[i].path, q))
|
||||
q = NULL;
|
||||
else
|
||||
assert_not_reached("wut?");
|
||||
assert_not_reached();
|
||||
}
|
||||
assert(!p && !q);
|
||||
unit_file_changes_free(changes, n_changes);
|
||||
@@ -326,7 +326,7 @@ static void test_linked_units(const char *root) {
|
||||
else if (q && streq(changes[i].path, q))
|
||||
q = NULL;
|
||||
else
|
||||
assert_not_reached("wut?");
|
||||
assert_not_reached();
|
||||
}
|
||||
assert(!p && !q);
|
||||
unit_file_changes_free(changes, n_changes);
|
||||
|
||||
@@ -348,7 +348,7 @@ static void test_prefixes(void) {
|
||||
assert_se(values[i] == NULL);
|
||||
|
||||
PATH_FOREACH_PREFIX(s, "////")
|
||||
assert_not_reached("Wut?");
|
||||
assert_not_reached();
|
||||
|
||||
b = false;
|
||||
PATH_FOREACH_PREFIX_MORE(s, "////") {
|
||||
@@ -359,7 +359,7 @@ static void test_prefixes(void) {
|
||||
assert_se(b);
|
||||
|
||||
PATH_FOREACH_PREFIX(s, "")
|
||||
assert_not_reached("wut?");
|
||||
assert_not_reached();
|
||||
|
||||
b = false;
|
||||
PATH_FOREACH_PREFIX_MORE(s, "") {
|
||||
|
||||
@@ -82,7 +82,7 @@ static int parse_item_given(const char *key, const char *value, void *data) {
|
||||
else if (in_initrd() && !*strip && proc_cmdline_key_streq(key, "rd.zumm"))
|
||||
assert_se(!value);
|
||||
else
|
||||
assert_not_reached("Bad key!");
|
||||
assert_not_reached();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -640,10 +640,10 @@ static void test_strv_foreach_backwards(void) {
|
||||
assert_se(streq_ptr(*check, input_table_multiple[i--]));
|
||||
|
||||
STRV_FOREACH_BACKWARDS(check, (char**) NULL)
|
||||
assert_not_reached("Let's see that we check empty strv right, too.");
|
||||
assert_not_reached();
|
||||
|
||||
STRV_FOREACH_BACKWARDS(check, (char**) { NULL })
|
||||
assert_not_reached("Let's see that we check empty strv right, too.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
static void test_strv_foreach_pair(void) {
|
||||
|
||||
@@ -431,7 +431,7 @@ static void test_foreach_pointer(void) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("unexpected index");
|
||||
assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ static void test_foreach_pointer(void) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("unexpected index");
|
||||
assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user