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:
@@ -946,7 +946,7 @@ int mount_custom(
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown custom mount type");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (r < 0)
|
||||
|
||||
@@ -180,7 +180,7 @@ int stub_pid1(sd_id128_t uuid) {
|
||||
|
||||
state = STATE_REBOOT;
|
||||
else
|
||||
assert_not_reached("Got unexpected signal");
|
||||
assert_not_reached();
|
||||
|
||||
r = kill_and_sigcont(pid, SIGTERM);
|
||||
|
||||
|
||||
+2
-2
@@ -1675,7 +1675,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (argc > optind) {
|
||||
@@ -2013,7 +2013,7 @@ static int setup_timezone(const char *dest) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("unexpected mode");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
/* Fix permissions of the symlink or file copy we just created */
|
||||
|
||||
Reference in New Issue
Block a user