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

systemd / systemd / 14895667988

07 May 2025 08:57PM UTC coverage: 72.225% (-0.007%) from 72.232%
14895667988

push

github

yuwata
network: log_link_message_debug_errno() automatically append %m if necessary

Follow-up for d28746ef5.
Fixes CID#1609753.

0 of 1 new or added line in 1 file covered. (0.0%)

20297 existing lines in 338 files now uncovered.

297407 of 411780 relevant lines covered (72.22%)

695716.85 hits per line

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

88.24
/src/shared/install-printf.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <errno.h>
4
#include <stdio.h>
5
#include <unistd.h>
6

7
#include "alloc-util.h"
8
#include "format-util.h"
9
#include "install.h"
10
#include "install-printf.h"
11
#include "macro.h"
12
#include "specifier.h"
13
#include "string-util.h"
14
#include "unit-name.h"
15
#include "user-util.h"
16

17
static int specifier_prefix_and_instance(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
2✔
18
        const InstallInfo *i = ASSERT_PTR(userdata);
2✔
19
        _cleanup_free_ char *prefix = NULL;
2✔
20
        int r;
2✔
21

22
        r = unit_name_to_prefix_and_instance(i->name, &prefix);
2✔
23
        if (r < 0)
2✔
24
                return r;
25

26
        if (endswith(prefix, "@") && i->default_instance) {
2✔
UNCOV
27
                char *ans;
×
28

29
                ans = strjoin(prefix, i->default_instance);
×
UNCOV
30
                if (!ans)
×
31
                        return -ENOMEM;
UNCOV
32
                *ret = ans;
×
33
        } else
34
                *ret = TAKE_PTR(prefix);
2✔
35

36
        return 0;
37
}
38

39
static int specifier_name(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
2✔
40
        const InstallInfo *i = ASSERT_PTR(userdata);
2✔
41

42
        if (unit_name_is_valid(i->name, UNIT_NAME_TEMPLATE) && i->default_instance)
2✔
UNCOV
43
                return unit_name_replace_instance(i->name, i->default_instance, ret);
×
44

45
        return strdup_to(ret, i->name);
2✔
46
}
47

48
static int specifier_prefix(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
3✔
49
        const InstallInfo *i = ASSERT_PTR(userdata);
3✔
50

51
        return unit_name_to_prefix(i->name, ret);
3✔
52
}
53

54
static int specifier_instance(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
1✔
55
        const InstallInfo *i = ASSERT_PTR(userdata);
1✔
56
        char *instance;
1✔
57
        int r;
1✔
58

59
        r = unit_name_to_instance(i->name, &instance);
1✔
60
        if (r < 0)
1✔
61
                return r;
1✔
62

63
        if (isempty(instance)) {
1✔
64
                r = free_and_strdup(&instance, strempty(i->default_instance));
2✔
65
                if (r < 0)
1✔
66
                        return r;
67
        }
68

69
        *ret = instance;
1✔
70
        return 0;
1✔
71
}
72

73
static int specifier_last_component(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
1✔
74
        _cleanup_free_ char *prefix = NULL;
1✔
75
        char *dash;
1✔
76
        int r;
1✔
77

78
        assert(ret);
1✔
79

80
        r = specifier_prefix(specifier, data, root, userdata, &prefix);
1✔
81
        if (r < 0)
1✔
82
                return r;
83

84
        dash = strrchr(prefix, '-');
1✔
85
        if (dash)
1✔
UNCOV
86
                return strdup_to(ret, dash + 1);
×
87

88
        *ret = TAKE_PTR(prefix);
1✔
89
        return 0;
1✔
90
}
91

92
int install_name_printf(
896✔
93
                RuntimeScope scope,
94
                const InstallInfo *info,
95
                const char *format,
96
                char **ret) {
97
        /* This is similar to unit_name_printf() */
98

99
        const Specifier table[] = {
896✔
100
                { 'i', specifier_instance,            NULL },
101
                { 'j', specifier_last_component,      NULL },
102
                { 'n', specifier_name,                NULL },
103
                { 'N', specifier_prefix_and_instance, NULL },
104
                { 'p', specifier_prefix,              NULL },
105

106
                COMMON_SYSTEM_SPECIFIERS,
107

108
                COMMON_CREDS_SPECIFIERS(scope),
896✔
109
                {}
110
        };
111

112
        assert(info);
896✔
113
        assert(format);
896✔
114
        assert(ret);
896✔
115

116
        return specifier_printf(format, UNIT_NAME_MAX, table, info->root, info, ret);
896✔
117
}
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