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

systemd / systemd / 25409762285

05 May 2026 08:45PM UTC coverage: 72.658% (-0.02%) from 72.674%
25409762285

push

github

web-flow
Couple of coverity fixes (#41951)

0 of 11 new or added lines in 2 files covered. (0.0%)

2705 existing lines in 63 files now uncovered.

326249 of 449021 relevant lines covered (72.66%)

1212712.0 hits per line

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

0.0
/src/report/report-basic.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <sys/utsname.h>
4

5
#include "sd-id128.h"
6
#include "sd-json.h"
7
#include "sd-varlink.h"
8

9
#include "alloc-util.h"
10
#include "architecture.h"
11
#include "hostname-setup.h"
12
#include "metrics.h"
13
#include "report-basic.h"
14
#include "virt.h"
15

16
static int architecture_generate(MetricFamilyContext *context, void *userdata) {
×
17
        assert(context);
×
18

19
        return metric_build_send_string(
×
20
                        context,
21
                        /* object= */ NULL,
22
                        architecture_to_string(uname_architecture()),
23
                        /* fields= */ NULL);
24
}
25

26
static int boot_id_generate(MetricFamilyContext *context, void *userdata) {
×
27
        sd_id128_t id;
×
UNCOV
28
        int r;
×
29

UNCOV
30
        assert(context);
×
31

32
        r = sd_id128_get_boot(&id);
×
33
        if (r < 0)
×
UNCOV
34
                return r;
×
35

UNCOV
36
        return metric_build_send_string(
×
37
                        context,
38
                        /* object= */ NULL,
UNCOV
39
                        SD_ID128_TO_STRING(id),
×
40
                        /* fields= */ NULL);
41
}
42

43
static int hostname_generate(MetricFamilyContext *context, void *userdata) {
×
UNCOV
44
        _cleanup_free_ char *hostname = NULL;
×
45
        int r;
×
46

47
        assert(context);
×
48

UNCOV
49
        r = gethostname_full(GET_HOSTNAME_ALLOW_LOCALHOST | GET_HOSTNAME_FALLBACK_DEFAULT, &hostname);
×
UNCOV
50
        if (r < 0)
×
51
                return r;
52

UNCOV
53
        return metric_build_send_string(
×
54
                        context,
55
                        /* object= */ NULL,
56
                        hostname,
57
                        /* fields= */ NULL);
58
}
59

60
static int kernel_version_generate(MetricFamilyContext *context, void *userdata) {
×
UNCOV
61
        struct utsname u;
×
62

UNCOV
63
        assert(context);
×
64

UNCOV
65
        assert_se(uname(&u) >= 0);
×
66

UNCOV
67
        return metric_build_send_string(
×
68
                        context,
69
                        /* object= */ NULL,
70
                        u.release,
71
                        /* fields= */ NULL);
72
}
73

74
static int machine_id_generate(MetricFamilyContext *context, void *userdata) {
×
UNCOV
75
        sd_id128_t id;
×
76
        int r;
×
77

78
        assert(context);
×
79

80
        r = sd_id128_get_machine(&id);
×
UNCOV
81
        if (r < 0)
×
UNCOV
82
                return r;
×
83

UNCOV
84
        return metric_build_send_string(
×
85
                        context,
86
                        /* object= */ NULL,
87
                        SD_ID128_TO_STRING(id),
×
88
                        /* fields= */ NULL);
89
}
90

91
static int virtualization_generate(MetricFamilyContext *context, void *userdata) {
×
92
        Virtualization v;
×
93

UNCOV
94
        assert(context);
×
95

UNCOV
96
        v = detect_virtualization();
×
UNCOV
97
        if (v < 0)
×
98
                return v;
99

UNCOV
100
        return metric_build_send_string(
×
101
                        context,
102
                        /* object= */ NULL,
103
                        virtualization_to_string(v),
104
                        /* fields= */ NULL);
105
}
106

107
static const MetricFamily metric_family_table[] = {
108
        /* Keep entries ordered alphabetically */
109
        {
110
                .name = METRIC_IO_SYSTEMD_BASIC_PREFIX "Architecture",
111
                .description = "CPU architecture",
112
                .type = METRIC_FAMILY_TYPE_STRING,
113
                .generate = architecture_generate,
114
        },
115
        {
116
                .name = METRIC_IO_SYSTEMD_BASIC_PREFIX "BootID",
117
                .description = "Current boot ID",
118
                .type = METRIC_FAMILY_TYPE_STRING,
119
                .generate = boot_id_generate,
120
        },
121
        {
122
                .name = METRIC_IO_SYSTEMD_BASIC_PREFIX "Hostname",
123
                .description = "System hostname",
124
                .type = METRIC_FAMILY_TYPE_STRING,
125
                .generate = hostname_generate,
126
        },
127
        {
128
                .name = METRIC_IO_SYSTEMD_BASIC_PREFIX "KernelVersion",
129
                .description = "Kernel version",
130
                .type = METRIC_FAMILY_TYPE_STRING,
131
                .generate = kernel_version_generate,
132
        },
133
        {
134
                .name = METRIC_IO_SYSTEMD_BASIC_PREFIX "MachineID",
135
                .description = "Machine ID",
136
                .type = METRIC_FAMILY_TYPE_STRING,
137
                .generate = machine_id_generate,
138
        },
139
        {
140
                .name = METRIC_IO_SYSTEMD_BASIC_PREFIX "Virtualization",
141
                .description = "Virtualization type",
142
                .type = METRIC_FAMILY_TYPE_STRING,
143
                .generate = virtualization_generate,
144
        },
145
        {}
146
};
147

UNCOV
148
int vl_method_describe_metrics(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
×
UNCOV
149
        return metrics_method_describe(metric_family_table, link, parameters, flags, userdata);
×
150
}
151

UNCOV
152
int vl_method_list_metrics(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
×
UNCOV
153
        return metrics_method_list(metric_family_table, link, parameters, flags, userdata);
×
154
}
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