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

systemd / systemd / 23966986054

03 Apr 2026 09:22PM UTC coverage: 72.107% (-0.3%) from 72.362%
23966986054

push

github

daandemeyer
fd-util: Add missing assert()

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

7891 existing lines in 120 files now uncovered.

318256 of 441368 relevant lines covered (72.11%)

1186882.96 hits per line

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

96.49
/src/basic/ordered-set.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <stdio.h>
4
#include <stdlib.h>
5
#include <string.h>
6

7
#include "fileio.h"
8
#include "ordered-set.h"
9
#include "strv.h"
10

11
int ordered_set_ensure_allocated(OrderedSet **s, const struct hash_ops *ops) {
116,420✔
12
        assert(s);
116,420✔
13

14
        if (*s)
116,420✔
15
                return 0;
16

17
        *s = ordered_set_new(ops);
38,672✔
18
        if (!*s)
38,672✔
UNCOV
19
                return -ENOMEM;
×
20

21
        return 0;
22
}
23

24
int ordered_set_ensure_put(OrderedSet **s, const struct hash_ops *ops, void *p) {
94,808✔
25
        int r;
94,808✔
26

27
        assert(s);
94,808✔
28

29
        r = ordered_set_ensure_allocated(s, ops);
94,808✔
30
        if (r < 0)
94,808✔
31
                return r;
32

33
        return ordered_set_put(*s, p);
94,808✔
34
}
35

36
int ordered_set_consume(OrderedSet *s, void *p) {
4,497✔
37
        int r;
4,497✔
38

39
        r = ordered_set_put(s, p);
4,497✔
40
        if (r <= 0)
4,497✔
41
                free(p);
36✔
42

43
        return r;
4,497✔
44
}
45

46
int ordered_set_put_strdup_full(OrderedSet **s, const struct hash_ops *hash_ops, const char *p) {
1,694✔
47
        char *c;
1,694✔
48
        int r;
1,694✔
49

50
        assert(s);
1,694✔
51
        assert(p);
1,694✔
52

53
        r = ordered_set_ensure_allocated(s, hash_ops);
1,694✔
54
        if (r < 0)
1,694✔
55
                return r;
56

57
        if (ordered_set_contains(*s, p))
1,694✔
58
                return 0;
59

60
        c = strdup(p);
1,636✔
61
        if (!c)
1,636✔
62
                return -ENOMEM;
63

64
        return ordered_set_consume(*s, c);
1,636✔
65
}
66

67
int ordered_set_put_strdupv_full(OrderedSet **s, const struct hash_ops *hash_ops, char **l) {
14,092✔
68
        int r, ret = 0;
14,092✔
69

70
        assert(s);
14,092✔
71

72
        STRV_FOREACH(i, l) {
14,182✔
73
                r = ordered_set_put_strdup_full(s, hash_ops, *i);
90✔
74
                if (r < 0)
90✔
75
                        return r;
76

77
                ret = ret || r > 0;
90✔
78
        }
79

80
        return ret;
81
}
82

83
int ordered_set_put_string_set_full(OrderedSet **s, const struct hash_ops *hash_ops, OrderedSet *l) {
28,124✔
84
        int r, ret = 0;
28,124✔
85
        char *p;
28,124✔
86

87
        assert(s);
28,124✔
88

89
        /* Like ordered_set_put_strv, but for an OrderedSet of strings */
90

91
        ORDERED_SET_FOREACH(p, l) {
28,308✔
92
                r = ordered_set_put_strdup_full(s, hash_ops, p);
184✔
93
                if (r < 0)
184✔
UNCOV
94
                        return r;
×
95

96
                ret = ret || r > 0;
184✔
97
        }
98

99
        return ret;
28,124✔
100
}
101

102
void ordered_set_print(FILE *f, const char *field, OrderedSet *s) {
49,269✔
103
        bool space = false;
49,269✔
104
        char *p;
49,269✔
105

106
        assert(f);
49,269✔
107
        assert(field);
49,269✔
108

109
        if (ordered_set_isempty(s))
49,269✔
110
                return;
48,318✔
111

112
        fputs(field, f);
951✔
113

114
        ORDERED_SET_FOREACH(p, s)
2,575✔
115
                fputs_with_separator(f, p, NULL, &space);
1,624✔
116

117
        fputc('\n', f);
951✔
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc