Bug Summary

File:build-scan/../src/test/test-rlimit-util.c
Warning:line 81, column 17
Value stored to 'prefixed' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test-rlimit-util.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fdenormal-fp-math=preserve-sign,preserve-sign -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/12.0.0 -include config.h -I test-rlimit-util.p -I . -I .. -I src/basic -I ../src/basic -I src/shared -I ../src/shared -I src/systemd -I ../src/systemd -I src/journal -I ../src/journal -I src/journal-remote -I ../src/journal-remote -I src/nspawn -I ../src/nspawn -I src/resolve -I ../src/resolve -I src/timesync -I ../src/timesync -I ../src/time-wait-sync -I src/login -I ../src/login -I src/udev -I ../src/udev -I src/libudev -I ../src/libudev -I src/core -I ../src/core -I ../src/libsystemd/sd-bus -I ../src/libsystemd/sd-device -I ../src/libsystemd/sd-hwdb -I ../src/libsystemd/sd-id128 -I ../src/libsystemd/sd-netlink -I ../src/libsystemd/sd-network -I src/libsystemd-network -I ../src/libsystemd-network -D _FILE_OFFSET_BITS=64 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/12.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wwrite-strings -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-error=nonnull -std=gnu99 -fconst-strings -fdebug-compilation-dir /home/mrc0mmand/repos/@redhat-plumbers/systemd-rhel8/build-scan -ferror-limit 19 -fvisibility hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -analyzer-output=html -faddrsig -o /tmp/scan-build-2021-07-16-221226-1465241-1 -x c ../src/test/test-rlimit-util.c
1/* SPDX-License-Identifier: LGPL-2.1+ */
2
3#include <sys/resource.h>
4
5#include "alloc-util.h"
6#include "capability-util.h"
7#include "macro.h"
8#include "rlimit-util.h"
9#include "string-util.h"
10#include "util.h"
11
12static void test_rlimit_parse_format(int resource, const char *string, rlim_t soft, rlim_t hard, int ret, const char *formatted) {
13 _cleanup_free___attribute__((cleanup(freep))) char *f = NULL((void*)0);
14 struct rlimit rl = {
15 .rlim_cur = 4711,
16 .rlim_max = 4712,
17 }, rl2 = {
18 .rlim_cur = 4713,
19 .rlim_max = 4714
20 };
21
22 assert_se(rlimit_parse(resource, string, &rl) == ret)do { if ((__builtin_expect(!!(!(rlimit_parse(resource, string
, &rl) == ret)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("rlimit_parse(resource, string, &rl) == ret"), "../src/test/test-rlimit-util.c"
, 22, __PRETTY_FUNCTION__); } while (0)
;
23 if (ret < 0)
24 return;
25
26 assert_se(rl.rlim_cur == soft)do { if ((__builtin_expect(!!(!(rl.rlim_cur == soft)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rl.rlim_cur == soft"), "../src/test/test-rlimit-util.c"
, 26, __PRETTY_FUNCTION__); } while (0)
;
27 assert_se(rl.rlim_max == hard)do { if ((__builtin_expect(!!(!(rl.rlim_max == hard)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("rl.rlim_max == hard"), "../src/test/test-rlimit-util.c"
, 27, __PRETTY_FUNCTION__); } while (0)
;
28
29 assert_se(rlimit_format(&rl, &f) >= 0)do { if ((__builtin_expect(!!(!(rlimit_format(&rl, &f
) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"rlimit_format(&rl, &f) >= 0"), "../src/test/test-rlimit-util.c"
, 29, __PRETTY_FUNCTION__); } while (0)
;
30 assert_se(streq(formatted, f))do { if ((__builtin_expect(!!(!((strcmp((formatted),(f)) == 0
))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("streq(formatted, f)"
), "../src/test/test-rlimit-util.c", 30, __PRETTY_FUNCTION__)
; } while (0)
;
31
32 assert_se(rlimit_parse(resource, formatted, &rl2) >= 0)do { if ((__builtin_expect(!!(!(rlimit_parse(resource, formatted
, &rl2) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("rlimit_parse(resource, formatted, &rl2) >= 0"), "../src/test/test-rlimit-util.c"
, 32, __PRETTY_FUNCTION__); } while (0)
;
33 assert_se(memcmp(&rl, &rl2, sizeof(struct rlimit)) == 0)do { if ((__builtin_expect(!!(!(memcmp(&rl, &rl2, sizeof
(struct rlimit)) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("memcmp(&rl, &rl2, sizeof(struct rlimit)) == 0"), "../src/test/test-rlimit-util.c"
, 33, __PRETTY_FUNCTION__); } while (0)
;
34}
35
36int main(int argc, char *argv[]) {
37 struct rlimit old, new, high;
38 struct rlimit err = {
39 .rlim_cur = 10,
40 .rlim_max = 5,
41 };
42 int i;
43
44 log_parse_environment()log_parse_environment_realm(LOG_REALM_SYSTEMD);
45 log_open();
46
47 assert_se(drop_capability(CAP_SYS_RESOURCE) == 0)do { if ((__builtin_expect(!!(!(drop_capability(24) == 0)),0)
)) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("drop_capability(CAP_SYS_RESOURCE) == 0"
), "../src/test/test-rlimit-util.c", 47, __PRETTY_FUNCTION__)
; } while (0)
;
48
49 assert_se(getrlimit(RLIMIT_NOFILE, &old) == 0)do { if ((__builtin_expect(!!(!(getrlimit(RLIMIT_NOFILE, &
old) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"getrlimit(RLIMIT_NOFILE, &old) == 0"), "../src/test/test-rlimit-util.c"
, 49, __PRETTY_FUNCTION__); } while (0)
;
50 new.rlim_cur = MIN(5U, old.rlim_max)__extension__ ({ const typeof((5U)) __unique_prefix_A2 = ((5U
)); const typeof((old.rlim_max)) __unique_prefix_B3 = ((old.rlim_max
)); __unique_prefix_A2 < __unique_prefix_B3 ? __unique_prefix_A2
: __unique_prefix_B3; })
;
51 new.rlim_max = old.rlim_max;
52 assert_se(setrlimit(RLIMIT_NOFILE, &new) >= 0)do { if ((__builtin_expect(!!(!(setrlimit(RLIMIT_NOFILE, &
new) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("setrlimit(RLIMIT_NOFILE, &new) >= 0"), "../src/test/test-rlimit-util.c"
, 52, __PRETTY_FUNCTION__); } while (0)
;
53
54 assert_se(rlimit_from_string("NOFILE") == RLIMIT_NOFILE)do { if ((__builtin_expect(!!(!(rlimit_from_string("NOFILE") ==
RLIMIT_NOFILE)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("rlimit_from_string(\"NOFILE\") == RLIMIT_NOFILE"), "../src/test/test-rlimit-util.c"
, 54, __PRETTY_FUNCTION__); } while (0)
;
55 assert_se(rlimit_from_string("LimitNOFILE") == -1)do { if ((__builtin_expect(!!(!(rlimit_from_string("LimitNOFILE"
) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string(\"LimitNOFILE\") == -1"
), "../src/test/test-rlimit-util.c", 55, __PRETTY_FUNCTION__)
; } while (0)
;
56 assert_se(rlimit_from_string("RLIMIT_NOFILE") == -1)do { if ((__builtin_expect(!!(!(rlimit_from_string("RLIMIT_NOFILE"
) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string(\"RLIMIT_NOFILE\") == -1"
), "../src/test/test-rlimit-util.c", 56, __PRETTY_FUNCTION__)
; } while (0)
;
57 assert_se(rlimit_from_string("xxxNOFILE") == -1)do { if ((__builtin_expect(!!(!(rlimit_from_string("xxxNOFILE"
) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string(\"xxxNOFILE\") == -1"
), "../src/test/test-rlimit-util.c", 57, __PRETTY_FUNCTION__)
; } while (0)
;
58 assert_se(rlimit_from_string("DefaultLimitNOFILE") == -1)do { if ((__builtin_expect(!!(!(rlimit_from_string("DefaultLimitNOFILE"
) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string(\"DefaultLimitNOFILE\") == -1"
), "../src/test/test-rlimit-util.c", 58, __PRETTY_FUNCTION__)
; } while (0)
;
59
60 assert_se(rlimit_from_string_harder("NOFILE") == RLIMIT_NOFILE)do { if ((__builtin_expect(!!(!(rlimit_from_string_harder("NOFILE"
) == RLIMIT_NOFILE)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("rlimit_from_string_harder(\"NOFILE\") == RLIMIT_NOFILE"),
"../src/test/test-rlimit-util.c", 60, __PRETTY_FUNCTION__); }
while (0)
;
61 assert_se(rlimit_from_string_harder("LimitNOFILE") == RLIMIT_NOFILE)do { if ((__builtin_expect(!!(!(rlimit_from_string_harder("LimitNOFILE"
) == RLIMIT_NOFILE)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("rlimit_from_string_harder(\"LimitNOFILE\") == RLIMIT_NOFILE"
), "../src/test/test-rlimit-util.c", 61, __PRETTY_FUNCTION__)
; } while (0)
;
62 assert_se(rlimit_from_string_harder("RLIMIT_NOFILE") == RLIMIT_NOFILE)do { if ((__builtin_expect(!!(!(rlimit_from_string_harder("RLIMIT_NOFILE"
) == RLIMIT_NOFILE)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("rlimit_from_string_harder(\"RLIMIT_NOFILE\") == RLIMIT_NOFILE"
), "../src/test/test-rlimit-util.c", 62, __PRETTY_FUNCTION__)
; } while (0)
;
63 assert_se(rlimit_from_string_harder("xxxNOFILE") == -1)do { if ((__builtin_expect(!!(!(rlimit_from_string_harder("xxxNOFILE"
) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string_harder(\"xxxNOFILE\") == -1"
), "../src/test/test-rlimit-util.c", 63, __PRETTY_FUNCTION__)
; } while (0)
;
64 assert_se(rlimit_from_string_harder("DefaultLimitNOFILE") == -1)do { if ((__builtin_expect(!!(!(rlimit_from_string_harder("DefaultLimitNOFILE"
) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string_harder(\"DefaultLimitNOFILE\") == -1"
), "../src/test/test-rlimit-util.c", 64, __PRETTY_FUNCTION__)
; } while (0)
;
65
66 for (i = 0; i < _RLIMIT_MAX(__RLIMIT_RTTIME+1 > __RLIMIT_NLIMITS ? __RLIMIT_RTTIME+1 :
__RLIMIT_NLIMITS)
; i++) {
67 _cleanup_free___attribute__((cleanup(freep))) char *prefixed = NULL((void*)0);
68 const char *p;
69
70 assert_se(p = rlimit_to_string(i))do { if ((__builtin_expect(!!(!(p = rlimit_to_string(i))),0))
) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("p = rlimit_to_string(i)"
), "../src/test/test-rlimit-util.c", 70, __PRETTY_FUNCTION__)
; } while (0)
;
71 log_info("%i = %s", i, p)({ int _level = (((6))), _e = ((0)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/test/test-rlimit-util.c", 71, __func__, "%i = %s", i
, p) : -abs(_e); })
;
72
73 assert_se(rlimit_from_string(p) == i)do { if ((__builtin_expect(!!(!(rlimit_from_string(p) == i)),
0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string(p) == i"
), "../src/test/test-rlimit-util.c", 73, __PRETTY_FUNCTION__)
; } while (0)
;
74 assert_se(rlimit_from_string_harder(p) == i)do { if ((__builtin_expect(!!(!(rlimit_from_string_harder(p) ==
i)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string_harder(p) == i"
), "../src/test/test-rlimit-util.c", 74, __PRETTY_FUNCTION__)
; } while (0)
;
75
76 assert_se(prefixed = strjoin("Limit", p))do { if ((__builtin_expect(!!(!(prefixed = strjoin_real(("Limit"
), p, ((void*)0)))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("prefixed = strjoin(\"Limit\", p)"), "../src/test/test-rlimit-util.c"
, 76, __PRETTY_FUNCTION__); } while (0)
;
77
78 assert_se(rlimit_from_string(prefixed) < 0)do { if ((__builtin_expect(!!(!(rlimit_from_string(prefixed) <
0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string(prefixed) < 0"
), "../src/test/test-rlimit-util.c", 78, __PRETTY_FUNCTION__)
; } while (0)
;
79 assert_se(rlimit_from_string_harder(prefixed) == i)do { if ((__builtin_expect(!!(!(rlimit_from_string_harder(prefixed
) == i)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string_harder(prefixed) == i"
), "../src/test/test-rlimit-util.c", 79, __PRETTY_FUNCTION__)
; } while (0)
;
80
81 prefixed = mfree(prefixed);
Value stored to 'prefixed' is never read
82 assert_se(prefixed = strjoin("RLIMIT_", p))do { if ((__builtin_expect(!!(!(prefixed = strjoin_real(("RLIMIT_"
), p, ((void*)0)))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("prefixed = strjoin(\"RLIMIT_\", p)"), "../src/test/test-rlimit-util.c"
, 82, __PRETTY_FUNCTION__); } while (0)
;
83
84 assert_se(rlimit_from_string(prefixed) < 0)do { if ((__builtin_expect(!!(!(rlimit_from_string(prefixed) <
0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string(prefixed) < 0"
), "../src/test/test-rlimit-util.c", 84, __PRETTY_FUNCTION__)
; } while (0)
;
85 assert_se(rlimit_from_string_harder(prefixed) == i)do { if ((__builtin_expect(!!(!(rlimit_from_string_harder(prefixed
) == i)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_from_string_harder(prefixed) == i"
), "../src/test/test-rlimit-util.c", 85, __PRETTY_FUNCTION__)
; } while (0)
;
86 }
87
88 assert_se(streq_ptr(rlimit_to_string(RLIMIT_NOFILE), "NOFILE"))do { if ((__builtin_expect(!!(!(streq_ptr(rlimit_to_string(RLIMIT_NOFILE
), "NOFILE"))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("streq_ptr(rlimit_to_string(RLIMIT_NOFILE), \"NOFILE\")"),
"../src/test/test-rlimit-util.c", 88, __PRETTY_FUNCTION__); }
while (0)
;
89 assert_se(rlimit_to_string(-1) == NULL)do { if ((__builtin_expect(!!(!(rlimit_to_string(-1) == ((void
*)0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("rlimit_to_string(-1) == NULL"
), "../src/test/test-rlimit-util.c", 89, __PRETTY_FUNCTION__)
; } while (0)
;
90
91 assert_se(getrlimit(RLIMIT_NOFILE, &old) == 0)do { if ((__builtin_expect(!!(!(getrlimit(RLIMIT_NOFILE, &
old) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"getrlimit(RLIMIT_NOFILE, &old) == 0"), "../src/test/test-rlimit-util.c"
, 91, __PRETTY_FUNCTION__); } while (0)
;
92 assert_se(setrlimit_closest(RLIMIT_NOFILE, &old) == 0)do { if ((__builtin_expect(!!(!(setrlimit_closest(RLIMIT_NOFILE
, &old) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("setrlimit_closest(RLIMIT_NOFILE, &old) == 0"), "../src/test/test-rlimit-util.c"
, 92, __PRETTY_FUNCTION__); } while (0)
;
93 assert_se(getrlimit(RLIMIT_NOFILE, &new) == 0)do { if ((__builtin_expect(!!(!(getrlimit(RLIMIT_NOFILE, &
new) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"getrlimit(RLIMIT_NOFILE, &new) == 0"), "../src/test/test-rlimit-util.c"
, 93, __PRETTY_FUNCTION__); } while (0)
;
94 assert_se(old.rlim_cur == new.rlim_cur)do { if ((__builtin_expect(!!(!(old.rlim_cur == new.rlim_cur)
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("old.rlim_cur == new.rlim_cur"
), "../src/test/test-rlimit-util.c", 94, __PRETTY_FUNCTION__)
; } while (0)
;
95 assert_se(old.rlim_max == new.rlim_max)do { if ((__builtin_expect(!!(!(old.rlim_max == new.rlim_max)
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("old.rlim_max == new.rlim_max"
), "../src/test/test-rlimit-util.c", 95, __PRETTY_FUNCTION__)
; } while (0)
;
96
97 assert_se(getrlimit(RLIMIT_NOFILE, &old) == 0)do { if ((__builtin_expect(!!(!(getrlimit(RLIMIT_NOFILE, &
old) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"getrlimit(RLIMIT_NOFILE, &old) == 0"), "../src/test/test-rlimit-util.c"
, 97, __PRETTY_FUNCTION__); } while (0)
;
98 high = RLIMIT_MAKE_CONST(old.rlim_max == RLIM_INFINITY ? old.rlim_max : old.rlim_max + 1)((struct rlimit) { old.rlim_max == 0xffffffffffffffffuLL ? old
.rlim_max : old.rlim_max + 1, old.rlim_max == 0xffffffffffffffffuLL
? old.rlim_max : old.rlim_max + 1 })
;
99 assert_se(setrlimit_closest(RLIMIT_NOFILE, &high) == 0)do { if ((__builtin_expect(!!(!(setrlimit_closest(RLIMIT_NOFILE
, &high) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("setrlimit_closest(RLIMIT_NOFILE, &high) == 0"), "../src/test/test-rlimit-util.c"
, 99, __PRETTY_FUNCTION__); } while (0)
;
100 assert_se(getrlimit(RLIMIT_NOFILE, &new) == 0)do { if ((__builtin_expect(!!(!(getrlimit(RLIMIT_NOFILE, &
new) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"getrlimit(RLIMIT_NOFILE, &new) == 0"), "../src/test/test-rlimit-util.c"
, 100, __PRETTY_FUNCTION__); } while (0)
;
101 assert_se(new.rlim_max == old.rlim_max)do { if ((__builtin_expect(!!(!(new.rlim_max == old.rlim_max)
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("new.rlim_max == old.rlim_max"
), "../src/test/test-rlimit-util.c", 101, __PRETTY_FUNCTION__
); } while (0)
;
102 assert_se(new.rlim_cur == new.rlim_max)do { if ((__builtin_expect(!!(!(new.rlim_cur == new.rlim_max)
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("new.rlim_cur == new.rlim_max"
), "../src/test/test-rlimit-util.c", 102, __PRETTY_FUNCTION__
); } while (0)
;
103
104 assert_se(getrlimit(RLIMIT_NOFILE, &old) == 0)do { if ((__builtin_expect(!!(!(getrlimit(RLIMIT_NOFILE, &
old) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"getrlimit(RLIMIT_NOFILE, &old) == 0"), "../src/test/test-rlimit-util.c"
, 104, __PRETTY_FUNCTION__); } while (0)
;
105 assert_se(setrlimit_closest(RLIMIT_NOFILE, &err) == -EINVAL)do { if ((__builtin_expect(!!(!(setrlimit_closest(RLIMIT_NOFILE
, &err) == -22)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("setrlimit_closest(RLIMIT_NOFILE, &err) == -EINVAL"), "../src/test/test-rlimit-util.c"
, 105, __PRETTY_FUNCTION__); } while (0)
;
106 assert_se(getrlimit(RLIMIT_NOFILE, &new) == 0)do { if ((__builtin_expect(!!(!(getrlimit(RLIMIT_NOFILE, &
new) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"getrlimit(RLIMIT_NOFILE, &new) == 0"), "../src/test/test-rlimit-util.c"
, 106, __PRETTY_FUNCTION__); } while (0)
;
107 assert_se(old.rlim_cur == new.rlim_cur)do { if ((__builtin_expect(!!(!(old.rlim_cur == new.rlim_cur)
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("old.rlim_cur == new.rlim_cur"
), "../src/test/test-rlimit-util.c", 107, __PRETTY_FUNCTION__
); } while (0)
;
108 assert_se(old.rlim_max == new.rlim_max)do { if ((__builtin_expect(!!(!(old.rlim_max == new.rlim_max)
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("old.rlim_max == new.rlim_max"
), "../src/test/test-rlimit-util.c", 108, __PRETTY_FUNCTION__
); } while (0)
;
109
110 test_rlimit_parse_format(RLIMIT_NOFILERLIMIT_NOFILE, "4:5", 4, 5, 0, "4:5");
111 test_rlimit_parse_format(RLIMIT_NOFILERLIMIT_NOFILE, "6", 6, 6, 0, "6");
112 test_rlimit_parse_format(RLIMIT_NOFILERLIMIT_NOFILE, "infinity", RLIM_INFINITY0xffffffffffffffffuLL, RLIM_INFINITY0xffffffffffffffffuLL, 0, "infinity");
113 test_rlimit_parse_format(RLIMIT_NOFILERLIMIT_NOFILE, "infinity:infinity", RLIM_INFINITY0xffffffffffffffffuLL, RLIM_INFINITY0xffffffffffffffffuLL, 0, "infinity");
114 test_rlimit_parse_format(RLIMIT_NOFILERLIMIT_NOFILE, "8:infinity", 8, RLIM_INFINITY0xffffffffffffffffuLL, 0, "8:infinity");
115 test_rlimit_parse_format(RLIMIT_CPURLIMIT_CPU, "25min:13h", (25*USEC_PER_MINUTE((usec_t) (60ULL*((usec_t) 1000000ULL)))) / USEC_PER_SEC((usec_t) 1000000ULL), (13*USEC_PER_HOUR((usec_t) (60ULL*((usec_t) (60ULL*((usec_t) 1000000ULL)))))) / USEC_PER_SEC((usec_t) 1000000ULL), 0, "1500:46800");
116 test_rlimit_parse_format(RLIMIT_NOFILERLIMIT_NOFILE, "", 0, 0, -EINVAL22, NULL((void*)0));
117 test_rlimit_parse_format(RLIMIT_NOFILERLIMIT_NOFILE, "5:4", 0, 0, -EILSEQ84, NULL((void*)0));
118 test_rlimit_parse_format(RLIMIT_NOFILERLIMIT_NOFILE, "5:4:3", 0, 0, -EINVAL22, NULL((void*)0));
119 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "20", 20, 20, 0, "20");
120 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "40", 40, 40, 0, "40");
121 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "41", 41, 41, -ERANGE34, "41");
122 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "0", 0, 0, 0, "0");
123 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "-7", 27, 27, 0, "27");
124 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "-20", 40, 40, 0, "40");
125 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "-21", 41, 41, -ERANGE34, "41");
126 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "-0", 20, 20, 0, "20");
127 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "+7", 13, 13, 0, "13");
128 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "+19", 1, 1, 0, "1");
129 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "+20", 0, 0, -ERANGE34, "0");
130 test_rlimit_parse_format(RLIMIT_NICE__RLIMIT_NICE, "+0", 20, 20, 0, "20");
131
132 return 0;
133}