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:
@@ -200,7 +200,7 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (arg_mode == _MODE_INVALID)
|
||||
|
||||
@@ -3009,7 +3009,7 @@ static int compat_parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (arg_type == 0 && arg_class != 0)
|
||||
@@ -3261,7 +3261,7 @@ static int native_parse_argv(int argc, char *argv[]) {
|
||||
return -EINVAL;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled option");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (arg_type == 0 && arg_class != 0)
|
||||
@@ -3411,7 +3411,7 @@ static int compat_main(int argc, char *argv[], sd_bus *bus) {
|
||||
return translate("revert", arg_ifname, 0, NULL, bus);
|
||||
|
||||
case _MODE_INVALID:
|
||||
assert_not_reached("invalid mode");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -135,7 +135,7 @@ static int reply_query_state(DnsQuery *q) {
|
||||
case DNS_TRANSACTION_VALIDATING:
|
||||
case DNS_TRANSACTION_SUCCESS:
|
||||
default:
|
||||
assert_not_reached("Impossible state");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ int config_parse_dnssd_txt(
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown type of Txt config");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
LIST_INSERT_AFTER(items, txt_data->txt, last, i);
|
||||
|
||||
@@ -1028,7 +1028,7 @@ int dnssec_verify_rrset_search(
|
||||
continue;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unexpected DNSSEC validation result");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ static inline size_t udp_header_size(int af) {
|
||||
case AF_INET6:
|
||||
return UDP6_PACKET_HEADER_SIZE;
|
||||
default:
|
||||
assert_not_reached("Unexpected address family");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -757,7 +757,7 @@ DnsScopeMatch dns_scope_good_domain(
|
||||
}
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown scope protocol");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ int dns_search_domain_new(
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown search domain type");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
d->linked = true;
|
||||
@@ -135,7 +135,7 @@ void dns_search_domain_move_back_and_unmark(DnsSearchDomain *d) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown search domain type");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ int dns_server_new(
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown server type");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
s->linked = true;
|
||||
@@ -158,7 +158,7 @@ void dns_server_unlink(DnsServer *s) {
|
||||
s->manager->n_dns_servers--;
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("Unknown server type");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
s->linked = false;
|
||||
@@ -213,7 +213,7 @@ void dns_server_move_back_and_unmark(DnsServer *s) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unknown server type");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -813,7 +813,7 @@ static void dns_stub_query_complete(DnsQuery *q) {
|
||||
case DNS_TRANSACTION_PENDING:
|
||||
case DNS_TRANSACTION_VALIDATING:
|
||||
default:
|
||||
assert_not_reached("Impossible state");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
dns_query_free(q);
|
||||
|
||||
@@ -1091,7 +1091,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid DNS protocol.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (t->received != p) {
|
||||
@@ -1184,7 +1184,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p, bool encrypt
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid DNS protocol.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (DNS_PACKET_TC(p)) {
|
||||
@@ -1528,7 +1528,7 @@ static int on_transaction_timeout(sd_event_source *s, usec_t usec, void *userdat
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid DNS protocol.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
log_debug("Timeout reached on transaction %" PRIu16 ".", t->id);
|
||||
@@ -1567,7 +1567,7 @@ static usec_t transaction_get_resend_timeout(DnsTransaction *t) {
|
||||
return t->scope->resend_timeout;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid DNS protocol.");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1959,7 +1959,7 @@ int dns_transaction_go(DnsTransaction *t) {
|
||||
accuracy = MDNS_JITTER_RANGE_USEC;
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("bad protocol");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
assert(!t->timeout_event_source);
|
||||
@@ -3530,7 +3530,7 @@ int dns_transaction_validate_dnssec(DnsTransaction *t) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unexpected NSEC result.");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ static int reply_query_state(DnsQuery *q) {
|
||||
case DNS_TRANSACTION_VALIDATING:
|
||||
case DNS_TRANSACTION_SUCCESS:
|
||||
default:
|
||||
assert_not_reached("Impossible state");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user