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

systemd / systemd / 15263807472

26 May 2025 08:53PM UTC coverage: 72.046% (-0.002%) from 72.048%
15263807472

push

github

yuwata
src/core/manager.c: log preset activity on first boot

This gives us a little more information about what units were enabled
or disabled on that first boot and will be useful for OS developers
tracking down the source of unit state.

An example with this enabled looks like:

```
NET: Registered PF_VSOCK protocol family
systemd[1]: Applying preset policy.
systemd[1]: Unit /etc/systemd/system/dnsmasq.service is masked, ignoring.
systemd[1]: Unit /etc/systemd/system/systemd-repart.service is masked, ignoring.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket'.
systemd[1]: Removed '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir.mount' → '/etc/systemd/system/var-mnt-workdir.mount'.
systemd[1]: Created symlink '/etc/systemd/system/multi-user.target.wants/var-mnt-workdir\x2dtmp.mount' → '/etc/systemd/system/var-mnt-workdir\x2dtmp.mount'.
systemd[1]: Created symlink '/etc/systemd/system/afterburn-sshkeys.target.requires/afterburn-sshkeys@core.service' → '/usr/lib/systemd/system/afterburn-sshkeys@.service'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-varlink.socket' → '/usr/lib/systemd/system/systemd-resolved-varlink.socket'.
systemd[1]: Created symlink '/etc/systemd/system/sockets.target.wants/systemd-resolved-monitor.socket' → '/usr/lib/systemd/system/systemd-resolved-monitor.socket'.
systemd[1]: Populated /etc with preset unit settings.
```

Considering it only happens on first boot and not on every boot I think
the extra information is worth the extra verbosity in the logs just for
that boot.

5 of 6 new or added lines in 1 file covered. (83.33%)

5463 existing lines in 165 files now uncovered.

299151 of 415222 relevant lines covered (72.05%)

702386.45 hits per line

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

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

3
#include <malloc.h>
4

5
#include "alloc-util.h"
6

7
void* memdup(const void *p, size_t l) {
555,951✔
8
        void *ret;
555,951✔
9

10
        assert(l == 0 || p);
555,951✔
11

12
        ret = malloc(l ?: 1);
555,951✔
13
        if (!ret)
555,951✔
14
                return NULL;
15

16
        return memcpy_safe(ret, p, l);
555,951✔
17
}
18

19
void* memdup_suffix0(const void *p, size_t l) {
2,820,761✔
20
        void *ret;
2,820,761✔
21

22
        assert(l == 0 || p);
2,820,761✔
23

24
        /* The same as memdup() but place a safety NUL byte after the allocated memory */
25

26
        if (_unlikely_(l == SIZE_MAX)) /* prevent overflow */
2,820,761✔
27
                return NULL;
28

29
        ret = malloc(l + 1);
2,820,761✔
30
        if (!ret)
2,820,761✔
31
                return NULL;
32

33
        ((uint8_t*) ret)[l] = 0;
2,820,761✔
34
        return memcpy_safe(ret, p, l);
2,820,761✔
35
}
36

37
void* greedy_realloc(
564,476,097✔
38
                void **p,
39
                size_t need,
40
                size_t size) {
41

42
        size_t newalloc;
564,476,097✔
43
        void *q;
564,476,097✔
44

45
        assert(p);
564,476,097✔
46

47
        /* We use malloc_usable_size() for determining the current allocated size. On all systems we care
48
         * about this should be safe to rely on. Should there ever arise the need to avoid relying on this we
49
         * can instead locally fall back to realloc() on every call, rounded up to the next exponent of 2 or
50
         * so. */
51

52
        if (*p && (size == 0 || (MALLOC_SIZEOF_SAFE(*p) / size >= need)))
564,476,097✔
53
                return *p;
532,672,651✔
54

55
        if (_unlikely_(need > SIZE_MAX/2)) /* Overflow check */
31,803,446✔
56
                return NULL;
57
        newalloc = need * 2;
31,803,446✔
58

59
        if (!MUL_ASSIGN_SAFE(&newalloc, size))
31,803,446✔
60
                return NULL;
61

62
        if (newalloc < 64) /* Allocate at least 64 bytes */
31,803,446✔
63
                newalloc = 64;
26,854,480✔
64

65
        q = realloc(*p, newalloc);
31,803,446✔
66
        if (!q)
31,803,446✔
67
                return NULL;
68

69
        return *p = q;
31,803,446✔
70
}
71

72
void* greedy_realloc0(
4,051,777✔
73
                void **p,
74
                size_t need,
75
                size_t size) {
76

77
        size_t before, after;
4,051,777✔
78
        uint8_t *q;
4,051,777✔
79

80
        assert(p);
4,051,777✔
81

82
        before = MALLOC_SIZEOF_SAFE(*p); /* malloc_usable_size() will return 0 on NULL input, as per docs */
4,051,777✔
83

84
        q = greedy_realloc(p, need, size);
4,051,777✔
85
        if (!q)
4,051,777✔
86
                return NULL;
4,051,777✔
87

88
        after = MALLOC_SIZEOF_SAFE(q);
4,051,777✔
89

90
        if (size == 0) /* avoid division by zero */
4,051,777✔
91
                before = 0;
92
        else
93
                before = (before / size) * size; /* Round down */
4,051,777✔
94

95
        if (after > before)
4,051,777✔
96
                memzero(q + before, after - before);
2,025,759✔
97

98
        return q;
4,051,777✔
99
}
100

101
void* greedy_realloc_append(
11,894✔
102
                void **p,
103
                size_t *n_p,
104
                const void *from,
105
                size_t n_from,
106
                size_t size) {
107

108
        uint8_t *q;
11,894✔
109

110
        assert(p);
11,894✔
111
        assert(n_p);
11,894✔
112
        assert(from || n_from == 0);
11,894✔
113

114
        if (n_from > SIZE_MAX - *n_p)
11,894✔
115
                return NULL;
116

117
        q = greedy_realloc(p, *n_p + n_from, size);
11,894✔
118
        if (!q)
11,894✔
119
                return NULL;
120

121
        memcpy_safe(q + *n_p * size, from, n_from * size);
11,894✔
122

123
        *n_p += n_from;
11,894✔
124

125
        return q;
11,894✔
126
}
127

128
void *expand_to_usable(void *ptr, size_t newsize _unused_) {
552,664,171✔
129
        return ptr;
552,664,171✔
130
}
131

132
size_t malloc_sizeof_safe(void **xp) {
551,930,087✔
133
        if (_unlikely_(!xp || !*xp))
551,930,087✔
134
                return 0;
135

136
        size_t sz = malloc_usable_size(*xp);
551,529,349✔
137
        *xp = expand_to_usable(*xp, sz);
551,529,349✔
138
        /* GCC doesn't see the _returns_nonnull_ when built with ubsan, so yet another hint to make it doubly
139
         * clear that expand_to_usable won't return NULL.
140
         * See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79265 */
141
        if (!*xp)
551,529,349✔
UNCOV
142
                assert_not_reached();
×
143
        return sz;
144
}
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