From 7dcbb48e4692f69a1d772cb1596417d73f232a95 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 29 Apr 2025 12:49:54 +0200 Subject: [PATCH] various: do not use assert_se as a workaround in non-test code This partially reverts 5332be60d3897c7b86d28cf7b9d61c5dc6847fd6. 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. --- src/libsystemd-network/sd-ndisc-router-solicit.c | 8 ++++---- src/login/logind-dbus.c | 9 +++++---- src/shared/tpm2-util.c | 5 +++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/libsystemd-network/sd-ndisc-router-solicit.c b/src/libsystemd-network/sd-ndisc-router-solicit.c index ec662acceef..742ec9a1d2a 100644 --- a/src/libsystemd-network/sd-ndisc-router-solicit.c +++ b/src/libsystemd-network/sd-ndisc-router-solicit.c @@ -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) diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 926843e868a..51edb60d047 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -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) diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index c18604b4dc1..f14e9eeae48 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -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( -- 2.47.3