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

systemd / systemd / 14554080340

19 Apr 2025 11:46AM UTC coverage: 72.101% (-0.03%) from 72.13%
14554080340

push

github

web-flow
Add two new paragraphs to coding style about header files (#37188)

296880 of 411754 relevant lines covered (72.1%)

687547.52 hits per line

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

61.54
/src/cryptsetup/cryptsetup-keyfile.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "cryptsetup-keyfile.h"
4
#include "fileio.h"
5
#include "log.h"
6
#include "path-util.h"
7
#include "strv.h"
8

9
int find_key_file(const char *key_file, char **search_path, const char *bindname, struct iovec *ret_key) {
24✔
10

11
        int r;
24✔
12

13
        assert(key_file);
24✔
14
        assert(ret_key);
24✔
15

16
        if (strv_isempty(search_path) || path_is_absolute(key_file)) {
72✔
17

18
                r = read_full_file_full(
×
19
                                AT_FDCWD, key_file, UINT64_MAX, SIZE_MAX,
20
                                READ_FULL_FILE_SECURE|READ_FULL_FILE_WARN_WORLD_READABLE|READ_FULL_FILE_CONNECT_SOCKET,
21
                                bindname,
22
                                (char**) &ret_key->iov_base, &ret_key->iov_len);
×
23
                if (r == -E2BIG)
×
24
                        return log_error_errno(r, "Key file '%s' too large.", key_file);
×
25
                if (r < 0)
×
26
                        return log_error_errno(r, "Failed to load key file '%s': %m", key_file);
×
27

28
                return 1;
29
        }
30

31
        STRV_FOREACH(i, search_path) {
71✔
32
                _cleanup_free_ char *joined = NULL;
48✔
33

34
                joined = path_join(*i, key_file);
48✔
35
                if (!joined)
48✔
36
                        return log_oom();
×
37

38
                r = read_full_file_full(
96✔
39
                                AT_FDCWD, joined, UINT64_MAX, SIZE_MAX,
40
                                READ_FULL_FILE_SECURE|READ_FULL_FILE_WARN_WORLD_READABLE|READ_FULL_FILE_CONNECT_SOCKET,
41
                                bindname,
42
                                (char**) &ret_key->iov_base, &ret_key->iov_len);
48✔
43
                if (r >= 0)
48✔
44
                        return 1;
45
                if (r == -E2BIG) {
47✔
46
                        log_warning_errno(r, "Key file '%s' too large, ignoring.", key_file);
×
47
                        continue;
×
48
                }
49
                if (r != -ENOENT)
47✔
50
                        return log_error_errno(r, "Failed to load key file '%s': %m", key_file);
×
51
        }
52

53
        /* Search path supplied, but file not found, report by returning NULL, but not failing */
54
        *ret_key = IOVEC_MAKE(NULL, 0);
23✔
55
        return 0;
23✔
56
}
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