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:
@@ -58,7 +58,7 @@ static int netdev_fill_fou_tunnel_message(NetDev *netdev, sd_netlink_message **r
|
||||
encap_type = FOU_ENCAP_GUE;
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("invalid encap type");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
r = sd_netlink_message_append_u8(m, FOU_ATTR_TYPE, encap_type);
|
||||
@@ -243,7 +243,7 @@ static int netdev_fou_tunnel_verify(NetDev *netdev, const char *filename) {
|
||||
filename);
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("Invalid fou encap type");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
if (t->peer_family == AF_UNSPEC && t->peer_port > 0)
|
||||
|
||||
@@ -528,7 +528,7 @@ int netdev_join(NetDev *netdev, Link *link, link_netlink_message_handler_t callb
|
||||
return r;
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("Cannot join independent netdev");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -128,7 +128,7 @@ static int netdev_gre_erspan_fill_message_create(NetDev *netdev, Link *link, sd_
|
||||
t = GRETAP(netdev);
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("invalid netdev kind");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
assert(t);
|
||||
@@ -457,7 +457,7 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
|
||||
t = ERSPAN(netdev);
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("Invalid tunnel kind");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
assert(t);
|
||||
@@ -722,7 +722,7 @@ static void ipip_sit_init(NetDev *n) {
|
||||
t = SIT(n);
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("invalid netdev kind");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
assert(t);
|
||||
@@ -763,7 +763,7 @@ static void gre_erspan_init(NetDev *n) {
|
||||
t = GRETAP(n);
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("invalid netdev kind");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
assert(t);
|
||||
|
||||
Reference in New Issue
Block a user