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

systemd / systemd / 14872145375

06 May 2025 09:07PM UTC coverage: 72.232% (+0.02%) from 72.214%
14872145375

push

github

DaanDeMeyer
string-table: annotate _to_string and _from_string with _const_ and _pure_, respectively

Follow-up for c94f6ab1b

297286 of 411572 relevant lines covered (72.23%)

695615.99 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 "alloc-util.h"
4
#include "daemon-util.h"
5
#include "fd-util.h"
6
#include "log.h"
7
#include "string-util.h"
8
#include "time-util.h"
9

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

13
        assert(name);
1,599✔
14

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

23
        return 0;
24
}
25

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

31
        assert(format);
929✔
32

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

39
        return notify_remove_fd_warn(p);
929✔
40
}
41

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

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

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

52
        assert(fd >= 0);
608✔
53
        assert(name);
608✔
54

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

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

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

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

71
        assert(fd >= 0);
488✔
72
        assert(format);
488✔
73

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

80
        return notify_push_fd(fd, name);
488✔
81
}
82

83
int notify_reloading_full(const char *status) {
326✔
84
        int r;
326✔
85

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

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