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

systemd / systemd / 14939761809

09 May 2025 06:22PM UTC coverage: 72.251% (-0.001%) from 72.252%
14939761809

push

github

web-flow
mount-tool: honor arg_canonicalize for ACTION_UMOUNT path_is_absolute() check too (#37398)

Split out from #36337

4 of 4 new or added lines in 2 files covered. (100.0%)

3591 existing lines in 114 files now uncovered.

297546 of 411820 relevant lines covered (72.25%)

704170.35 hits per line

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

61.43
/src/basic/iovec-wrapper.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <errno.h>
4
#include <limits.h>
5

6
#include "alloc-util.h"
7
#include "iovec-util.h"
8
#include "iovec-wrapper.h"
9
#include "string-util.h"
10

11
struct iovec_wrapper *iovw_new(void) {
22✔
12
        return new0(struct iovec_wrapper, 1);
22✔
13
}
14

15
void iovw_done(struct iovec_wrapper *iovw) {
23,341✔
16
        assert(iovw);
23,341✔
17

18
        iovw->iovec = mfree(iovw->iovec);
23,341✔
19
        iovw->count = 0;
23,341✔
20
}
23,341✔
21

22
void iovw_done_free(struct iovec_wrapper *iovw) {
23✔
23
        assert(iovw);
23✔
24

25
        FOREACH_ARRAY(i, iovw->iovec, iovw->count)
666✔
26
                iovec_done(i);
643✔
27

28
        iovw_done(iovw);
23✔
29
}
23✔
30

31
struct iovec_wrapper *iovw_free_free(struct iovec_wrapper *iovw) {
13✔
32
        if (!iovw)
13✔
33
                return NULL;
34

35
        iovw_done_free(iovw);
13✔
36
        return mfree(iovw);
13✔
37
}
38

UNCOV
39
struct iovec_wrapper *iovw_free(struct iovec_wrapper *iovw) {
×
40
        if (!iovw)
×
41
                return NULL;
42

UNCOV
43
        iovw_done(iovw);
×
UNCOV
44
        return mfree(iovw);
×
45
}
46

47
int iovw_put(struct iovec_wrapper *iovw, void *data, size_t len) {
582,556✔
48
        assert(iovw);
582,556✔
49

50
        if (len == 0)
582,556✔
51
                return 0;
52

53
        assert(data);
582,556✔
54

55
        if (iovw->count >= IOV_MAX)
582,556✔
56
                return -E2BIG;
57

58
        if (!GREEDY_REALLOC(iovw->iovec, iovw->count + 1))
582,556✔
59
                return -ENOMEM;
60

61
        iovw->iovec[iovw->count++] = IOVEC_MAKE(data, len);
582,556✔
62
        return 0;
582,556✔
63
}
64

65
int iovw_put_string_field(struct iovec_wrapper *iovw, const char *field, const char *value) {
360✔
66
        _cleanup_free_ char *x = NULL;
360✔
67
        int r;
360✔
68

69
        assert(iovw);
360✔
70

71
        x = strjoin(field, value);
360✔
72
        if (!x)
360✔
73
                return -ENOMEM;
74

75
        r = iovw_put(iovw, x, strlen(x));
360✔
76
        if (r >= 0)
360✔
77
                TAKE_PTR(x);
360✔
78

79
        return r;
80
}
81

82
int iovw_put_string_field_free(struct iovec_wrapper *iovw, const char *field, char *value) {
205✔
83
        _cleanup_free_ _unused_ char *free_ptr = value;
205✔
84

85
        return iovw_put_string_field(iovw, field, value);
205✔
86
}
87

88
void iovw_rebase(struct iovec_wrapper *iovw, void *old, void *new) {
2,323✔
89
        assert(iovw);
2,323✔
90

91
        FOREACH_ARRAY(i, iovw->iovec, iovw->count) {
24,151✔
92
                assert(i->iov_base >= old);
21,828✔
93
                i->iov_base = (uint8_t*) i->iov_base - (uint8_t*) old + (uint8_t*) new;
21,828✔
94
        }
95
}
2,323✔
96

UNCOV
97
size_t iovw_size(const struct iovec_wrapper *iovw) {
×
98
        if (!iovw)
×
99
                return 0;
100

101
        return iovec_total_size(iovw->iovec, iovw->count);
×
102
}
103

UNCOV
104
int iovw_append(struct iovec_wrapper *target, const struct iovec_wrapper *source) {
×
105
        size_t original_count;
×
UNCOV
106
        int r;
×
107

UNCOV
108
        assert(target);
×
109

110
        /* This duplicates the source and merges it into the target. */
111

112
        if (iovw_isempty(source))
×
113
                return 0;
114

115
        original_count = target->count;
×
116

117
        FOREACH_ARRAY(iovec, source->iovec, source->count) {
×
118
                void *dup;
×
119

120
                dup = memdup(iovec->iov_base, iovec->iov_len);
×
UNCOV
121
                if (!dup) {
×
UNCOV
122
                        r = -ENOMEM;
×
123
                        goto rollback;
×
124
                }
125

UNCOV
126
                r = iovw_consume(target, dup, iovec->iov_len);
×
UNCOV
127
                if (r < 0)
×
UNCOV
128
                        goto rollback;
×
129
        }
130

131
        return 0;
132

UNCOV
133
rollback:
×
134
        for (size_t i = original_count; i < target->count; i++)
×
135
                iovec_done(target->iovec + i);
×
136

UNCOV
137
        target->count = original_count;
×
UNCOV
138
        return r;
×
139
}
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