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:
@@ -1308,7 +1308,7 @@ static int client_timeout_resend(
|
||||
goto error;
|
||||
|
||||
default:
|
||||
assert_not_reached("Unhandled choice");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
r = event_reset_time(client->event, &client->timeout_resend,
|
||||
@@ -1896,7 +1896,7 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, i
|
||||
r = -EINVAL;
|
||||
goto error;
|
||||
default:
|
||||
assert_not_reached("invalid state");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
error:
|
||||
|
||||
@@ -293,7 +293,7 @@ static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata)
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid state.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -409,7 +409,7 @@ static int ipv4acd_on_packet(
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid state.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -360,7 +360,7 @@ void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata) {
|
||||
break;
|
||||
|
||||
default:
|
||||
assert_not_reached("Invalid IPv4ACD event.");
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -30,7 +30,7 @@ static void acd_handler(sd_ipv4acd *acd, int event, void *userdata) {
|
||||
log_error("the client was stopped");
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("invalid ACD event");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ static be32_t xid;
|
||||
static sd_event_source *test_hangcheck;
|
||||
|
||||
static int test_dhcp_hangcheck(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
assert_not_reached("Test case should have completed in 2 seconds");
|
||||
assert_not_reached();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -560,10 +560,8 @@ static int test_advertise_option(sd_event *e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_hangcheck(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
assert_not_reached("Test case should have completed in 2 seconds");
|
||||
|
||||
return 0;
|
||||
static int test_check_completed_in_2_seconds(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
static void test_client_solicit_cb(sd_dhcp6_client *client, int event,
|
||||
@@ -861,14 +859,8 @@ static int test_client_verify_information_request(DHCP6Message *information_requ
|
||||
break;
|
||||
|
||||
case SD_DHCP6_OPTION_IA_NA:
|
||||
assert_not_reached("IA TA option must not be present");
|
||||
|
||||
break;
|
||||
|
||||
case SD_DHCP6_OPTION_SERVERID:
|
||||
assert_not_reached("Server ID option must not be present");
|
||||
|
||||
break;
|
||||
assert_not_reached();
|
||||
|
||||
case SD_DHCP6_OPTION_ELAPSED_TIME:
|
||||
assert_se(!found_elapsed_time);
|
||||
@@ -965,7 +957,7 @@ static int test_client_solicit(sd_event *e) {
|
||||
|
||||
assert_se(sd_event_add_time_relative(e, &hangcheck, clock_boottime_or_monotonic(),
|
||||
2 * USEC_PER_SEC, 0,
|
||||
test_hangcheck, NULL) >= 0);
|
||||
test_check_completed_in_2_seconds, NULL) >= 0);
|
||||
|
||||
assert_se(sd_dhcp6_client_set_local_address(client, &address) >= 0);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ static void ll_handler(sd_ipv4ll *ll, int event, void *userdata) {
|
||||
log_error("the client was stopped with address %s", strna(address));
|
||||
break;
|
||||
default:
|
||||
assert_not_reached("invalid LL event");
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user