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:
+4
-4
@@ -418,7 +418,7 @@ bool unit_may_gc(Unit *u) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown garbage collection mode");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (u->cgroup_path) {
|
||||
@@ -2591,7 +2591,7 @@ static bool unit_process_job(Job *j, UnitActiveState ns, UnitNotifyFlags flags)
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Job type unknown");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return unexpected;
|
||||
@@ -2983,7 +2983,7 @@ bool unit_job_is_applicable(Unit *u, JobType j) {
|
||||
return unit_can_reload(u) && unit_can_start(u);
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid job type");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4459,7 +4459,7 @@ static int operation_to_signal(const KillContext *c, KillOperation k, bool *note
|
||||
return c->watchdog_signal;
|
||||
|
||||
default:
|
||||
assert_not_reached("KillOperation unknown");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user