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:
@@ -34,7 +34,7 @@ int add_dependency(int argc, char *argv[], void *userdata) {
|
||||
else if (streq(verb, "add-requires"))
|
||||
dep = UNIT_REQUIRES;
|
||||
else
|
||||
assert_not_reached("Unknown verb");
|
||||
assert_not_reached();
|
||||
|
||||
if (install_client_side()) {
|
||||
r = unit_file_add_dependency(arg_scope, unit_file_flags_from_args(), arg_root, names, target, dep, &changes, &n_changes);
|
||||
|
||||
@@ -44,7 +44,7 @@ int clean_or_freeze_unit(int argc, char *argv[], void *userdata) {
|
||||
else if (streq(argv[0], "thaw"))
|
||||
method = "ThawUnit";
|
||||
else
|
||||
assert_not_reached("Unhandled method");
|
||||
assert_not_reached();
|
||||
|
||||
STRV_FOREACH(name, names) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
|
||||
@@ -127,7 +127,7 @@ int halt_parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (arg_action == ACTION_REBOOT && (argc == optind || argc == optind + 1)) {
|
||||
|
||||
@@ -55,7 +55,7 @@ int runlevel_parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
|
||||
@@ -112,7 +112,7 @@ int shutdown_parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (argc > optind && arg_action != ACTION_CANCEL_SHUTDOWN) {
|
||||
|
||||
@@ -93,7 +93,7 @@ int telinit_parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (optind >= argc)
|
||||
|
||||
@@ -35,7 +35,7 @@ int daemon_reload(int argc, char *argv[], void *userdata) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unexpected action");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method);
|
||||
|
||||
@@ -124,7 +124,7 @@ int enable_unit(int argc, char *argv[], void *userdata) {
|
||||
else if (streq(verb, "revert"))
|
||||
r = unit_file_revert(arg_scope, arg_root, names, &changes, &n_changes);
|
||||
else
|
||||
assert_not_reached("Unknown verb");
|
||||
assert_not_reached();
|
||||
|
||||
unit_file_dump_changes(r, verb, changes, n_changes, arg_quiet);
|
||||
if (r < 0)
|
||||
@@ -191,7 +191,7 @@ int enable_unit(int argc, char *argv[], void *userdata) {
|
||||
method = "RevertUnitFiles";
|
||||
send_runtime = send_force = false;
|
||||
} else
|
||||
assert_not_reached("Unknown verb");
|
||||
assert_not_reached();
|
||||
|
||||
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, method);
|
||||
if (r < 0)
|
||||
|
||||
@@ -930,6 +930,6 @@ int halt_now(enum action a) {
|
||||
(arg_dry_run ? REBOOT_DRY_RUN : 0));
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown action.");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -922,7 +922,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (arg_transport == BUS_TRANSPORT_REMOTE && arg_scope != UNIT_FILE_SYSTEM)
|
||||
@@ -1184,7 +1184,7 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
case _ACTION_INVALID:
|
||||
default:
|
||||
assert_not_reached("Unknown action");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
finish:
|
||||
|
||||
Reference in New Issue
Block a user