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

systemd / systemd / 14554080340

19 Apr 2025 11:46AM UTC coverage: 72.101% (-0.03%) from 72.13%
14554080340

push

github

web-flow
Add two new paragraphs to coding style about header files (#37188)

296880 of 411754 relevant lines covered (72.1%)

687547.52 hits per line

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

95.56
/src/shared/daemon-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "daemon-util.h"
4
#include "fd-util.h"
5
#include "log.h"
6
#include "string-util.h"
7
#include "time-util.h"
8

9
int notify_remove_fd_warn(const char *name) {
1,499✔
10
        int r;
1,499✔
11

12
        assert(name);
1,499✔
13

14
        r = sd_notifyf(/* unset_environment = */ false,
1,499✔
15
                       "FDSTOREREMOVE=1\n"
16
                       "FDNAME=%s", name);
17
        if (r < 0)
1,499✔
18
                return log_warning_errno(r,
3✔
19
                                         "Failed to remove file descriptor \"%s\" from the store, ignoring: %m",
20
                                         name);
21

22
        return 0;
23
}
24

25
int notify_remove_fd_warnf(const char *format, ...) {
903✔
26
        _cleanup_free_ char *p = NULL;
903✔
27
        va_list ap;
903✔
28
        int r;
903✔
29

30
        assert(format);
903✔
31

32
        va_start(ap, format);
903✔
33
        r = vasprintf(&p, format, ap);
903✔
34
        va_end(ap);
903✔
35
        if (r < 0)
903✔
36
                return log_oom();
×
37

38
        return notify_remove_fd_warn(p);
903✔
39
}
40

41
int close_and_notify_warn(int fd, const char *name) {
6✔
42
        if (name)
6✔
43
                (void) notify_remove_fd_warn(name);
6✔
44

45
        return safe_close(fd);
6✔
46
}
47

48
int notify_push_fd(int fd, const char *name) {
590✔
49
        _cleanup_free_ char *state = NULL;
590✔
50

51
        assert(fd >= 0);
590✔
52
        assert(name);
590✔
53

54
        state = strjoin("FDSTORE=1\n"
590✔
55
                        "FDNAME=", name);
56
        if (!state)
590✔
57
                return -ENOMEM;
58

59
        /* Remove existing fds with the same name in fdstore. */
60
        (void) notify_remove_fd_warn(name);
590✔
61

62
        return sd_pid_notify_with_fds(0, /* unset_environment = */ false, state, &fd, 1);
590✔
63
}
64

65
int notify_push_fdf(int fd, const char *format, ...) {
475✔
66
        _cleanup_free_ char *name = NULL;
475✔
67
        va_list ap;
475✔
68
        int r;
475✔
69

70
        assert(fd >= 0);
475✔
71
        assert(format);
475✔
72

73
        va_start(ap, format);
475✔
74
        r = vasprintf(&name, format, ap);
475✔
75
        va_end(ap);
475✔
76
        if (r < 0)
475✔
77
                return -ENOMEM;
78

79
        return notify_push_fd(fd, name);
475✔
80
}
81

82
int notify_reloading_full(const char *status) {
317✔
83
        int r;
317✔
84

85
        r = sd_notifyf(/* unset_environment = */ false,
317✔
86
                       "RELOADING=1\n"
87
                       "MONOTONIC_USEC=" USEC_FMT
88
                       "%s%s",
89
                       now(CLOCK_MONOTONIC),
90
                       status ? "\nSTATUS=" : "", strempty(status));
91
        if (r < 0)
317✔
92
                return log_debug_errno(r, "Failed to notify service manager for reloading status: %m");
×
93

94
        return 0;
95
}
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