1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00

basic/sigbus: use FOREACH_ELEMENT where appropriate, assert >= 0 for success

This commit is contained in:
Mike Yuan 2024-08-17 19:40:55 +02:00
parent f134a79ff8
commit d71f138156
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3

View File

@ -29,10 +29,10 @@ static void sigbus_push(void *addr) {
assert(addr);
/* Find a free place, increase the number of entries and leave, if we can */
for (size_t u = 0; u < SIGBUS_QUEUE_MAX; u++) {
FOREACH_ELEMENT(u, sigbus_queue) {
/* OK to initialize this here since we haven't started the atomic ops yet */
void *tmp = NULL;
if (__atomic_compare_exchange_n(&sigbus_queue[u], &tmp, addr, false,
if (__atomic_compare_exchange_n(u, &tmp, addr, false,
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
__atomic_fetch_add(&n_sigbus_queue, 1, __ATOMIC_SEQ_CST);
return;
@ -102,7 +102,7 @@ static void sigbus_handler(int sn, siginfo_t *si, void *data) {
assert(si);
if (si->si_code != BUS_ADRERR || !si->si_addr) {
assert_se(sigaction(SIGBUS, &old_sigaction, NULL) == 0);
assert_se(sigaction(SIGBUS, &old_sigaction, NULL) >= 0);
propagate_signal(sn, si);
return;
}
@ -133,7 +133,7 @@ void sigbus_install(void) {
n_installed++;
if (n_installed == 1)
assert_se(sigaction(SIGBUS, &sa, &old_sigaction) == 0);
assert_se(sigaction(SIGBUS, &sa, &old_sigaction) >= 0);
return;
}
@ -146,7 +146,7 @@ void sigbus_reset(void) {
n_installed--;
if (n_installed == 0)
assert_se(sigaction(SIGBUS, &old_sigaction, NULL) == 0);
assert_se(sigaction(SIGBUS, &old_sigaction, NULL) >= 0);
return;
}