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

systemd / systemd / 15079507752

16 May 2025 10:18PM UTC coverage: 72.276% (+0.009%) from 72.267%
15079507752

push

github

YHNdnzj
sd-bus: drop a bunch of 'else'

With the new US taxes on bits and bytes let's reduce our footprint a
bit.

11 of 19 new or added lines in 1 file covered. (57.89%)

4028 existing lines in 76 files now uncovered.

298564 of 413090 relevant lines covered (72.28%)

700985.27 hits per line

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

46.43
/src/integritysetup/integrity-util.c
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2

3
#include "alloc-util.h"
4
#include "cryptsetup-util.h"
5
#include "extract-word.h"
6
#include "integrity-util.h"
7
#include "log.h"
8
#include "percent-util.h"
9
#include "string-util.h"
10
#include "strv.h"
11
#include "time-util.h"
12

13
static int supported_integrity_algorithm(char *user_supplied) {
10✔
14
        if (!STR_IN_SET(user_supplied, "crc32", "crc32c", "xxhash64", "sha1", "sha256", "hmac-sha256"))
10✔
UNCOV
15
                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unsupported integrity algorithm (%s)", user_supplied);
×
16
        return 0;
10✔
17
}
18

19
int parse_integrity_options(
10✔
20
                const char *options,
21
                uint32_t *ret_activate_flags,
22
                int *ret_percent,
23
                usec_t *ret_commit_time,
24
                char **ret_data_device,
25
                char **ret_integrity_alg) {
26
        int r;
25✔
27

28
        for (;;) {
40✔
29
                _cleanup_free_ char *word = NULL;
15✔
30
                char *val;
25✔
31

32
                r = extract_first_word(&options, &word, ",", EXTRACT_DONT_COALESCE_SEPARATORS | EXTRACT_UNESCAPE_SEPARATORS);
25✔
33
                if (r < 0)
25✔
34
                        return log_error_errno(r, "Failed to parse options: %m");
×
35
                if (r == 0)
25✔
36
                        break;
37
                else if (streq(word, "allow-discards")) {
15✔
38
                        if (ret_activate_flags)
×
39
                                *ret_activate_flags |= CRYPT_ACTIVATE_ALLOW_DISCARDS;
×
40
                } else if ((val = startswith(word, "mode="))) {
15✔
41
                        if (streq(val, "journal")) {
×
42
                                if (ret_activate_flags)
×
43
                                        *ret_activate_flags &= ~(CRYPT_ACTIVATE_NO_JOURNAL | CRYPT_ACTIVATE_NO_JOURNAL_BITMAP);
×
UNCOV
44
                        } else if (streq(val, "bitmap")) {
×
45
                                if (ret_activate_flags) {
×
46
                                        *ret_activate_flags &= ~CRYPT_ACTIVATE_NO_JOURNAL;
×
47
                                        *ret_activate_flags |= CRYPT_ACTIVATE_NO_JOURNAL_BITMAP;
×
48
                                }
UNCOV
49
                        } else if (streq(val, "direct")) {
×
UNCOV
50
                                if (ret_activate_flags) {
×
51
                                        *ret_activate_flags |= CRYPT_ACTIVATE_NO_JOURNAL;
×
UNCOV
52
                                        *ret_activate_flags &= ~CRYPT_ACTIVATE_NO_JOURNAL_BITMAP;
×
53
                                }
54
                        } else
55
                                log_warning("Encountered unknown mode option '%s', ignoring.", val);
×
56
                } else if ((val = startswith(word, "journal-watermark="))) {
15✔
57
                        r = parse_percent(val);
×
UNCOV
58
                        if (r < 0)
×
59
                                return log_error_errno(r, "Failed to parse journal-watermark value or value out of range (%s)", val);
×
60
                        if (ret_percent)
×
61
                                *ret_percent = r;
×
62
                } else if ((val = startswith(word, "journal-commit-time="))) {
15✔
63
                        usec_t tmp_commit_time;
×
64
                        r = parse_sec(val, &tmp_commit_time);
×
UNCOV
65
                        if (r < 0)
×
UNCOV
66
                                return log_error_errno(r, "Failed to parse journal-commit-time value (%s)", val);
×
UNCOV
67
                        if (ret_commit_time)
×
UNCOV
68
                                *ret_commit_time = tmp_commit_time;
×
69
                } else if ((val = startswith(word, "data-device="))) {
15✔
70
                        if (ret_data_device) {
5✔
71
                                r = free_and_strdup(ret_data_device, val);
5✔
72
                                if (r < 0)
5✔
UNCOV
73
                                        return log_oom();
×
74
                        }
75
                } else if ((val = startswith(word, "integrity-algorithm="))) {
10✔
76
                        r = supported_integrity_algorithm(val);
10✔
77
                        if (r < 0)
10✔
78
                                return r;
79
                        if (ret_integrity_alg) {
10✔
80
                                r = free_and_strdup(ret_integrity_alg, val);
10✔
81
                                if (r < 0)
10✔
UNCOV
82
                                        return log_oom();
×
83
                        }
84
                } else
UNCOV
85
                        log_warning("Encountered unknown option '%s', ignoring.", word);
×
86
        }
87

88
        return r;
10✔
89
}
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