Skip to content

Commit 7dcbb48

Browse files
keszybzyuwata
authored andcommitted
various: do not use assert_se as a workaround in non-test code
This partially reverts 5332be6. 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.
1 parent bd4ab24 commit 7dcbb48

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/libsystemd-network/sd-ndisc-router-solicit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ int ndisc_router_solicit_parse(sd_radv *ra, sd_ndisc_router_solicit *rs) {
4848
return log_radv_errno(ra, SYNTHETIC_ERRNO(EBADMSG),
4949
"Too small to be a router solicit, ignoring.");
5050

51-
const struct nd_router_solicit *a = (const struct nd_router_solicit*) rs->packet->raw_packet;
52-
assert_se(a);
53-
assert_se(a->nd_rs_type == ND_ROUTER_SOLICIT);
54-
assert_se(a->nd_rs_code == 0);
51+
_unused_ const struct nd_router_solicit *a = (const struct nd_router_solicit*) rs->packet->raw_packet;
52+
assert(a);
53+
assert(a->nd_rs_type == ND_ROUTER_SOLICIT);
54+
assert(a->nd_rs_code == 0);
5555

5656
r = ndisc_parse_options(rs->packet, &rs->options);
5757
if (r < 0)

src/login/logind-dbus.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,8 @@ static int verify_shutdown_creds(
21792179
sd_bus_error *error) {
21802180

21812181
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
2182-
bool multiple_sessions, blocked, interactive, error_or_denial = false;
2182+
bool multiple_sessions, blocked, interactive;
2183+
_unused_ bool error_or_denial = false;
21832184
Inhibitor *offending = NULL;
21842185
uid_t uid;
21852186
int r;
@@ -2280,7 +2281,7 @@ static int verify_shutdown_creds(
22802281
* to catch. In any case, it also means that the payload guarded by
22812282
* these polkit calls should never be executed, and hence we should
22822283
* never reach this point. */
2283-
assert_se(!error_or_denial);
2284+
assert(!error_or_denial);
22842285

22852286
return 0;
22862287
}
@@ -3775,7 +3776,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
37753776
InhibitMode mm;
37763777
InhibitWhat w;
37773778
uid_t uid;
3778-
bool error_or_denial = false;
3779+
_unused_ bool error_or_denial = false;
37793780
int r;
37803781

37813782
assert(message);
@@ -3841,7 +3842,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
38413842
* to catch. In any case, it also means that the payload guarded by
38423843
* these polkit calls should never be executed, and hence we should
38433844
* never reach this point. */
3844-
assert_se(!error_or_denial);
3845+
assert(!error_or_denial);
38453846

38463847
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID|SD_BUS_CREDS_PID|SD_BUS_CREDS_PIDFD, &creds);
38473848
if (r < 0)

src/shared/tpm2-util.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4723,9 +4723,10 @@ static int tpm2_kdfe(
47234723
if (!info)
47244724
return log_oom_debug();
47254725

4726-
void *end = mempcpy(mempcpy(stpcpy(info, label) + 1, context_u, context_u_size), context_v, context_v_size);
4726+
_unused_ void *end = mempcpy(mempcpy(stpcpy(info, label) + 1, context_u, context_u_size),
4727+
context_v, context_v_size);
47274728
/* assert we copied exactly the right amount that we allocated */
4728-
assert_se(end > info && (uintptr_t) end - (uintptr_t) info == info_len);
4729+
assert(end > info && (uintptr_t) end - (uintptr_t) info == info_len);
47294730

47304731
_cleanup_free_ void *buf = NULL;
47314732
r = kdf_ss_derive(

0 commit comments

Comments
 (0)