various: do not use assert_se as a workaround in non-test code

This partially reverts 5332be60d3. I expect that
there is no practical difference, but it seems philosophically wrong to use
assert_se(), i.e. for the generation of the code in non-debug builds, just to
suppress a warning. We have _unused_ for that, use it.

I verified that we don't get warnings with clang and -DNDEBUG=1 with this patch.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-04-29 12:49:54 +02:00
committed by Yu Watanabe
parent bd4ab24f49
commit 7dcbb48e46
3 changed files with 12 additions and 10 deletions

View File

@@ -48,10 +48,10 @@ int ndisc_router_solicit_parse(sd_radv *ra, sd_ndisc_router_solicit *rs) {
return log_radv_errno(ra, SYNTHETIC_ERRNO(EBADMSG),
"Too small to be a router solicit, ignoring.");
const struct nd_router_solicit *a = (const struct nd_router_solicit*) rs->packet->raw_packet;
assert_se(a);
assert_se(a->nd_rs_type == ND_ROUTER_SOLICIT);
assert_se(a->nd_rs_code == 0);
_unused_ const struct nd_router_solicit *a = (const struct nd_router_solicit*) rs->packet->raw_packet;
assert(a);
assert(a->nd_rs_type == ND_ROUTER_SOLICIT);
assert(a->nd_rs_code == 0);
r = ndisc_parse_options(rs->packet, &rs->options);
if (r < 0)

View File

@@ -2179,7 +2179,8 @@ static int verify_shutdown_creds(
sd_bus_error *error) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
bool multiple_sessions, blocked, interactive, error_or_denial = false;
bool multiple_sessions, blocked, interactive;
_unused_ bool error_or_denial = false;
Inhibitor *offending = NULL;
uid_t uid;
int r;
@@ -2280,7 +2281,7 @@ static int verify_shutdown_creds(
* to catch. In any case, it also means that the payload guarded by
* these polkit calls should never be executed, and hence we should
* never reach this point. */
assert_se(!error_or_denial);
assert(!error_or_denial);
return 0;
}
@@ -3775,7 +3776,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
InhibitMode mm;
InhibitWhat w;
uid_t uid;
bool error_or_denial = false;
_unused_ bool error_or_denial = false;
int r;
assert(message);
@@ -3841,7 +3842,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
* to catch. In any case, it also means that the payload guarded by
* these polkit calls should never be executed, and hence we should
* never reach this point. */
assert_se(!error_or_denial);
assert(!error_or_denial);
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID|SD_BUS_CREDS_PID|SD_BUS_CREDS_PIDFD, &creds);
if (r < 0)

View File

@@ -4723,9 +4723,10 @@ static int tpm2_kdfe(
if (!info)
return log_oom_debug();
void *end = mempcpy(mempcpy(stpcpy(info, label) + 1, context_u, context_u_size), context_v, context_v_size);
_unused_ void *end = mempcpy(mempcpy(stpcpy(info, label) + 1, context_u, context_u_size),
context_v, context_v_size);
/* assert we copied exactly the right amount that we allocated */
assert_se(end > info && (uintptr_t) end - (uintptr_t) info == info_len);
assert(end > info && (uintptr_t) end - (uintptr_t) info == info_len);
_cleanup_free_ void *buf = NULL;
r = kdf_ss_derive(