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

systemd / systemd / 15837872256

23 Jun 2025 09:28PM UTC coverage: 72.09% (-0.02%) from 72.105%
15837872256

push

github

bluca
test-cpu-set-util: fix check for CPUSet.allocated

The check was simply wrong and meaningless, as it always checked
CPUSet.allocated is greater than or equals to 1, as sizeof(__cpu_mask) is 8.

Let's make the test more strict.

300458 of 416781 relevant lines covered (72.09%)

709101.32 hits per line

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

94.0
/src/basic/glob-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include <dirent.h>
4
#include <sys/stat.h>
5

6
#include "dirent-util.h"
7
#include "errno-util.h"
8
#include "glob-util.h"
9
#include "string-util.h"
10
#include "strv.h"
11

12
DEFINE_TRIVIAL_DESTRUCTOR(closedir_wrapper, void, closedir);
11,322✔
13

14
int safe_glob_full(const char *path, int flags, opendir_t opendir_func, char ***ret) {
43,273✔
15
        _cleanup_(globfree) glob_t g = {
×
16
                .gl_closedir = closedir_wrapper,
17
                .gl_readdir = (struct dirent* (*)(void *)) readdir_no_dot,
18
                .gl_opendir = (void* (*)(const char *)) (opendir_func ?: opendir),
43,273✔
19
                .gl_lstat = lstat,
20
                .gl_stat = stat,
21
        };
22
        int r;
43,273✔
23

24
        assert(path);
43,273✔
25

26
        errno = 0;
43,273✔
27
        r = glob(path, flags | GLOB_ALTDIRFUNC, NULL, &g);
43,273✔
28
        if (r == GLOB_NOMATCH)
43,273✔
29
                return -ENOENT;
30
        if (r == GLOB_NOSPACE)
8,305✔
31
                return -ENOMEM;
32
        if (r != 0)
8,305✔
33
                return errno_or_else(EIO);
×
34

35
        if (strv_isempty(g.gl_pathv))
51,578✔
36
                return -ENOENT;
37

38
        if (ret) {
8,305✔
39
                *ret = g.gl_pathv;
8,305✔
40
                TAKE_STRUCT(g); /* To avoid the result being freed. */
8,305✔
41
        }
42

43
        return 0;
44
}
45

46
int glob_first(const char *path, char **ret) {
12✔
47
        _cleanup_strv_free_ char **v = NULL;
12✔
48
        int r;
12✔
49

50
        assert(path);
12✔
51

52
        r = safe_glob(path, GLOB_NOSORT|GLOB_BRACE, &v);
12✔
53
        if (r == -ENOENT) {
12✔
54
                if (ret)
6✔
55
                        *ret = NULL;
5✔
56
                return false;
6✔
57
        }
58
        if (r < 0)
6✔
59
                return r;
60

61
        assert(!strv_isempty(v));
6✔
62

63
        if (ret) {
6✔
64
                /* Free all results except for the first one. */
65
                STRV_FOREACH(p, strv_skip(v, 1))
3✔
66
                        *p = mfree(*p);
×
67

68
                /* Then, take the first result. */
69
                *ret = TAKE_PTR(*v);
3✔
70
        }
71

72
        return true;
73
}
74

75
int glob_extend(char ***strv, const char *path, int flags) {
4,140✔
76
        char **v;
4,140✔
77
        int r;
4,140✔
78

79
        assert(path);
4,140✔
80

81
        r = safe_glob(path, GLOB_NOSORT|GLOB_BRACE|flags, &v);
4,140✔
82
        if (r < 0)
4,140✔
83
                return r;
4,140✔
84

85
        return strv_extend_strv_consume(strv, v, /* filter_duplicates = */ false);
4,140✔
86
}
87

88
int glob_non_glob_prefix(const char *path, char **ret) {
3,669✔
89
        /* Return the path of the path that has no glob characters. */
90

91
        size_t n = strcspn(path, GLOB_CHARS);
3,669✔
92

93
        if (path[n] != '\0')
3,669✔
94
                while (n > 0 && path[n-1] != '/')
67,105✔
95
                        n--;
96

97
        if (n == 0)
3,669✔
98
                return -ENOENT;
99

100
        char *ans = strndup(path, n);
3,668✔
101
        if (!ans)
3,668✔
102
                return -ENOMEM;
103
        *ret = ans;
3,668✔
104
        return 0;
3,668✔
105
}
106

107
bool string_is_glob(const char *p) {
222,382✔
108
        /* Check if a string contains any glob patterns. */
109
        return !!strpbrk(p, GLOB_CHARS);
222,382✔
110
}
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