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:
+8
-8
@@ -433,7 +433,7 @@ static void peer_address_hash_func(const SocketPeer *s, struct siphash *state) {
|
||||
else if (s->peer.sa.sa_family == AF_VSOCK)
|
||||
siphash24_compress(&s->peer.vm.svm_cid, sizeof(s->peer.vm.svm_cid), state);
|
||||
else
|
||||
assert_not_reached("Unknown address family.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
static int peer_address_compare_func(const SocketPeer *x, const SocketPeer *y) {
|
||||
@@ -451,7 +451,7 @@ static int peer_address_compare_func(const SocketPeer *x, const SocketPeer *y) {
|
||||
case AF_VSOCK:
|
||||
return CMP(x->peer.vm.svm_cid, y->peer.vm.svm_cid);
|
||||
}
|
||||
assert_not_reached("Black sheep in the family!");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
DEFINE_PRIVATE_HASH_OPS(peer_address_hash_ops, SocketPeer, peer_address_hash_func, peer_address_compare_func);
|
||||
@@ -558,7 +558,7 @@ _const_ static const char* listen_lookup(int family, int type) {
|
||||
else if (type == SOCK_SEQPACKET)
|
||||
return "ListenSequentialPacket";
|
||||
|
||||
assert_not_reached("Unknown socket type");
|
||||
assert_not_reached();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -914,7 +914,7 @@ static int instance_from_socket(int fd, unsigned nr, char **instance) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled socket type.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
*instance = r;
|
||||
@@ -1724,7 +1724,7 @@ static int socket_open_fds(Socket *orig_s) {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert_not_reached("Unknown port type");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3071,7 +3071,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
else if (code == CLD_DUMPED)
|
||||
f = SOCKET_FAILURE_CORE_DUMP;
|
||||
else
|
||||
assert_not_reached("Unknown sigchld code");
|
||||
assert_not_reached();
|
||||
|
||||
if (s->control_command) {
|
||||
exec_status_exit(&s->control_command->exec_status, &s->exec_context, pid, code, status);
|
||||
@@ -3149,7 +3149,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Uh, control process died at wrong time.");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3226,7 +3226,7 @@ static int socket_dispatch_timer(sd_event_source *source, usec_t usec, void *use
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Timeout at wrong time.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user