• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

systemd / systemd / 17014398938

16 Aug 2025 10:22PM UTC coverage: 72.237% (+0.06%) from 72.175%
17014398938

push

github

bluca
meson: compile nss-util.c only when at least one nss module is enabled

Follow-up for ea7075347.

302508 of 418772 relevant lines covered (72.24%)

651155.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/basic/assert-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <stdio.h>
4
#include <stdlib.h>
5

6
#include "assert-util.h"
7
#include "env-util.h"
8
#include "errno-util.h"
9
#include "log.h"
10

11
static bool assert_return_is_critical = BUILD_MODE_DEVELOPER;
12

13
/* Akin to glibc's __abort_msg; which is private and we hence cannot
14
 * use here. */
15
static char *log_abort_msg = NULL;
16

17
void log_set_assert_return_is_critical(bool b) {
1,167✔
18
        assert_return_is_critical = b;
1,167✔
19
}
1,167✔
20

21
void log_set_assert_return_is_critical_from_env(void) {
2,335✔
22
        static int cached = INT_MIN;
2,335✔
23
        int r;
2,335✔
24

25
        if (cached == INT_MIN) {
2,335✔
26
                r = secure_getenv_bool("SYSTEMD_ASSERT_RETURN_IS_CRITICAL");
2,335✔
27
                if (r < 0 && r != -ENXIO)
2,335✔
28
                        log_debug_errno(r, "Failed to parse $SYSTEMD_ASSERT_RETURN_IS_CRITICAL, ignoring: %m");
×
29

30
                cached = r;
2,335✔
31
        }
32

33
        if (cached >= 0)
2,335✔
34
                log_set_assert_return_is_critical(cached);
×
35
}
2,335✔
36

37
bool log_get_assert_return_is_critical(void) {
386✔
38
        return assert_return_is_critical;
386✔
39
}
40

41
static void log_assert(
378✔
42
        int level,
43
        const char *text,
44
        const char *file,
45
        int line,
46
        const char *func,
47
        const char *format) {
48

49
        static char buffer[LINE_MAX];
378✔
50

51
        if (_likely_(LOG_PRI(level) > log_get_max_level()))
378✔
52
                return;
53

54
        DISABLE_WARNING_FORMAT_NONLITERAL;
378✔
55
        (void) snprintf(buffer, sizeof buffer, format, text, file, line, func);
378✔
56
        REENABLE_WARNING;
378✔
57

58
        log_abort_msg = buffer;
378✔
59

60
        log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer);
378✔
61
}
62

63
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) {
×
64
        log_assert(LOG_CRIT, text, file, line, func,
×
65
                   "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
66
        abort();
×
67
}
68

69
_noreturn_ void log_assert_failed_unreachable(const char *file, int line, const char *func) {
×
70
        log_assert(LOG_CRIT, "Code should not be reached", file, line, func,
×
71
                   "%s at %s:%u, function %s(). Aborting. 💥");
72
        abort();
×
73
}
74

75
void log_assert_failed_return(const char *text, const char *file, int line, const char *func) {
378✔
76

77
        if (assert_return_is_critical)
378✔
78
                log_assert_failed(text, file, line, func);
×
79

80
        PROTECT_ERRNO;
378✔
81
        log_assert(LOG_DEBUG, text, file, line, func,
378✔
82
                   "Assertion '%s' failed at %s:%u, function %s(), ignoring.");
83
}
378✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc