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

systemd / systemd / 18765396043

23 Oct 2025 01:51PM UTC coverage: 72.284% (-0.01%) from 72.295%
18765396043

push

github

YHNdnzj
core: increment start limit counter only when we can start the unit

Otherwise, e.g. requesting to start a unit that is under stopping may
enter the failed state.

This makes
- rename .can_start() -> .test_startable(), and make it allow to return
  boolean and refuse to start units when it returns false,
- refuse earlier to start units that are in the deactivating state, so
  several redundant conditions in .start() can be dropped,
- move checks for unit states mapped to UNIT_ACTIVATING from .start() to
  .test_startable().

Fixes #39247.

13 of 15 new or added lines in 8 files covered. (86.67%)

6946 existing lines in 72 files now uncovered.

304970 of 421905 relevant lines covered (72.28%)

1105466.04 hits per line

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

65.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 "errno-util.h"
8
#include "log.h"
9

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

14
static void log_assert(
378✔
15
        int level,
16
        const char *text,
17
        const char *file,
18
        int line,
19
        const char *func,
20
        const char *format) {
21

22
        static char buffer[LINE_MAX];
378✔
23

24
        if (_likely_(LOG_PRI(level) > log_get_max_level()))
378✔
25
                return;
26

27
        DISABLE_WARNING_FORMAT_NONLITERAL;
378✔
28
        (void) snprintf(buffer, sizeof buffer, format, text, file, line, func);
378✔
29
        REENABLE_WARNING;
378✔
30

31
        log_abort_msg = buffer;
378✔
32

33
        log_dispatch_internal(level, 0, file, line, func, NULL, NULL, NULL, NULL, buffer);
378✔
34
}
35

UNCOV
36
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) {
×
UNCOV
37
        log_assert(LOG_CRIT, text, file, line, func,
×
38
                   "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
UNCOV
39
        abort();
×
40
}
41

UNCOV
42
_noreturn_ void log_assert_failed_unreachable(const char *file, int line, const char *func) {
×
UNCOV
43
        log_assert(LOG_CRIT, "Code should not be reached", file, line, func,
×
44
                   "%s at %s:%u, function %s(). Aborting. 💥");
UNCOV
45
        abort();
×
46
}
47

48
void log_assert_failed_return(const char *text, const char *file, int line, const char *func) {
378✔
49
        /* log_get_assert_return_is_critical is a weak symbol. It may be NULL. */
50
        if (log_get_assert_return_is_critical && log_get_assert_return_is_critical())
378✔
UNCOV
51
                log_assert_failed(text, file, line, func);
×
52

53
        PROTECT_ERRNO;
378✔
54
        log_assert(LOG_DEBUG, text, file, line, func,
378✔
55
                   "Assertion '%s' failed at %s:%u, function %s(), ignoring.");
56
}
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