Bug Summary

File:build-scan/../src/libsystemd/sd-login/test-login.c
Warning:line 119, column 17
The right operand of '==' is a garbage value

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-login.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-login.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/libsystemd/sd-login/test-login.c
1/* SPDX-License-Identifier: LGPL-2.1+ */
2/***
3***/
4
5#include <poll.h>
6#include <string.h>
7
8#include "sd-login.h"
9
10#include "alloc-util.h"
11#include "fd-util.h"
12#include "format-util.h"
13#include "log.h"
14#include "string-util.h"
15#include "strv.h"
16#include "util.h"
17
18static char* format_uids(char **buf, uid_t* uids, int count) {
19 int pos = 0, k, inc;
20 size_t size = (DECIMAL_STR_MAX(uid_t)(2+(sizeof(uid_t) <= 1 ? 3 : sizeof(uid_t) <= 2 ? 5 : sizeof
(uid_t) <= 4 ? 10 : sizeof(uid_t) <= 8 ? 20 : sizeof(int
[-2*(sizeof(uid_t) > 8)])))
+ 1) * count + 1;
21
22 assert_se(*buf = malloc(size))do { if ((__builtin_expect(!!(!(*buf = malloc(size))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("*buf = malloc(size)"), "../src/libsystemd/sd-login/test-login.c"
, 22, __PRETTY_FUNCTION__); } while (0)
;
23
24 for (k = 0; k < count; k++) {
25 sprintf(*buf + pos, "%s"UID_FMT"%" "u""%n", k > 0 ? " " : "", uids[k], &inc);
26 pos += inc;
27 }
28
29 assert_se(pos < (ssize_t)size)do { if ((__builtin_expect(!!(!(pos < (ssize_t)size)),0)))
log_assert_failed_realm(LOG_REALM_SYSTEMD, ("pos < (ssize_t)size"
), "../src/libsystemd/sd-login/test-login.c", 29, __PRETTY_FUNCTION__
); } while (0)
;
30 (*buf)[pos] = '\0';
31
32 return *buf;
33}
34
35static void test_login(void) {
36 _cleanup_close_pair___attribute__((cleanup(close_pairp))) int pair[2] = { -1, -1 };
37 _cleanup_free___attribute__((cleanup(freep))) char *pp = NULL((void*)0), *qq = NULL((void*)0),
38 *display_session = NULL((void*)0), *cgroup = NULL((void*)0),
39 *display = NULL((void*)0), *remote_user = NULL((void*)0), *remote_host = NULL((void*)0),
40 *type = NULL((void*)0), *class = NULL((void*)0), *state = NULL((void*)0), *state2 = NULL((void*)0),
41 *seat = NULL((void*)0), *session = NULL((void*)0),
42 *unit = NULL((void*)0), *user_unit = NULL((void*)0), *slice = NULL((void*)0);
43 int r;
44 uid_t u, u2;
1
'u2' declared without an initial value
45 char *t, **seats, **sessions;
46
47 r = sd_pid_get_unit(0, &unit);
48 assert_se(r >= 0 || r == -ENODATA)do { if ((__builtin_expect(!!(!(r >= 0 || r == -61)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0 || r == -ENODATA"), "../src/libsystemd/sd-login/test-login.c"
, 48, __PRETTY_FUNCTION__); } while (0)
;
2
Assuming 'r' is >= 0
3
Taking false branch
4
Loop condition is false. Exiting loop
49 log_info("sd_pid_get_unit(0, …) → \"%s\"", strna(unit))({ 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/libsystemd/sd-login/test-login.c", 49, __func__, "sd_pid_get_unit(0, …) → \"%s\""
, strna(unit)) : -abs(_e); })
;
5
Assuming the condition is false
6
'?' condition is false
50
51 r = sd_pid_get_user_unit(0, &user_unit);
52 assert_se(r >= 0 || r == -ENODATA)do { if ((__builtin_expect(!!(!(r >= 0 || r == -61)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0 || r == -ENODATA"), "../src/libsystemd/sd-login/test-login.c"
, 52, __PRETTY_FUNCTION__); } while (0)
;
7
Assuming 'r' is >= 0
8
Taking false branch
9
Loop condition is false. Exiting loop
53 log_info("sd_pid_get_user_unit(0, …) → \"%s\"", strna(user_unit))({ 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/libsystemd/sd-login/test-login.c", 53, __func__, "sd_pid_get_user_unit(0, …) → \"%s\""
, strna(user_unit)) : -abs(_e); })
;
10
Assuming the condition is false
11
'?' condition is false
54
55 r = sd_pid_get_slice(0, &slice);
56 assert_se(r >= 0 || r == -ENODATA)do { if ((__builtin_expect(!!(!(r >= 0 || r == -61)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0 || r == -ENODATA"), "../src/libsystemd/sd-login/test-login.c"
, 56, __PRETTY_FUNCTION__); } while (0)
;
12
Assuming 'r' is >= 0
13
Taking false branch
14
Loop condition is false. Exiting loop
57 log_info("sd_pid_get_slice(0, …) → \"%s\"", strna(slice))({ 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/libsystemd/sd-login/test-login.c", 57, __func__, "sd_pid_get_slice(0, …) → \"%s\""
, strna(slice)) : -abs(_e); })
;
15
Assuming the condition is false
16
'?' condition is false
58
59 r = sd_pid_get_session(0, &session);
60 if (r < 0) {
17
Assuming 'r' is < 0
18
Taking true branch
61 log_warning_errno(r, "sd_pid_get_session(0, …): %m")({ int _level = ((4)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/libsystemd/sd-login/test-login.c", 61, __func__, "sd_pid_get_session(0, …): %m"
) : -abs(_e); })
;
19
Assuming the condition is false
20
'?' condition is false
62 if (r == -ENODATA61)
21
Assuming the condition is false
22
Taking false branch
63 log_info("Seems we are not running in a session, skipping some tests.")({ 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/libsystemd/sd-login/test-login.c", 63, __func__, "Seems we are not running in a session, skipping some tests."
) : -abs(_e); })
;
64 } else {
65 log_info("sd_pid_get_session(0, …) → \"%s\"", session)({ 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/libsystemd/sd-login/test-login.c", 65, __func__, "sd_pid_get_session(0, …) → \"%s\""
, session) : -abs(_e); })
;
66
67 assert_se(sd_pid_get_owner_uid(0, &u2) == 0)do { if ((__builtin_expect(!!(!(sd_pid_get_owner_uid(0, &
u2) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("sd_pid_get_owner_uid(0, &u2) == 0"
), "../src/libsystemd/sd-login/test-login.c", 67, __PRETTY_FUNCTION__
); } while (0)
;
68 log_info("sd_pid_get_owner_uid(0, …) → "UID_FMT, u2)({ 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/libsystemd/sd-login/test-login.c", 68, __func__, "sd_pid_get_owner_uid(0, …) → "
"%" "u", u2) : -abs(_e); })
;
69
70 assert_se(sd_pid_get_cgroup(0, &cgroup) == 0)do { if ((__builtin_expect(!!(!(sd_pid_get_cgroup(0, &cgroup
) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("sd_pid_get_cgroup(0, &cgroup) == 0"
), "../src/libsystemd/sd-login/test-login.c", 70, __PRETTY_FUNCTION__
); } while (0)
;
71 log_info("sd_pid_get_cgroup(0, …) → \"%s\"", cgroup)({ 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/libsystemd/sd-login/test-login.c", 71, __func__, "sd_pid_get_cgroup(0, …) → \"%s\""
, cgroup) : -abs(_e); })
;
72
73 r = sd_uid_get_display(u2, &display_session);
74 assert_se(r >= 0 || r == -ENODATA)do { if ((__builtin_expect(!!(!(r >= 0 || r == -61)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0 || r == -ENODATA"), "../src/libsystemd/sd-login/test-login.c"
, 74, __PRETTY_FUNCTION__); } while (0)
;
75 log_info("sd_uid_get_display("UID_FMT", …) → \"%s\"",({ 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/libsystemd/sd-login/test-login.c", 76, __func__, "sd_uid_get_display("
"%" "u"", …) → \"%s\"", u2, strnull(display_session)) : -
abs(_e); })
76 u2, strnull(display_session))({ 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/libsystemd/sd-login/test-login.c", 76, __func__, "sd_uid_get_display("
"%" "u"", …) → \"%s\"", u2, strnull(display_session)) : -
abs(_e); })
;
77
78 assert_se(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0)do { if ((__builtin_expect(!!(!(socketpair(1, SOCK_STREAM, 0,
pair) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD,
("socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0"), "../src/libsystemd/sd-login/test-login.c"
, 78, __PRETTY_FUNCTION__); } while (0)
;
79 sd_peer_get_session(pair[0], &pp);
80 sd_peer_get_session(pair[1], &qq);
81 assert_se(streq_ptr(pp, qq))do { if ((__builtin_expect(!!(!(streq_ptr(pp, qq))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("streq_ptr(pp, qq)"), "../src/libsystemd/sd-login/test-login.c"
, 81, __PRETTY_FUNCTION__); } while (0)
;
82
83 r = sd_uid_get_sessions(u2, false0, &sessions);
84 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 84, __PRETTY_FUNCTION__); } while (0)
;
85 assert_se(r == (int) strv_length(sessions))do { if ((__builtin_expect(!!(!(r == (int) strv_length(sessions
))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("r == (int) strv_length(sessions)"
), "../src/libsystemd/sd-login/test-login.c", 85, __PRETTY_FUNCTION__
); } while (0)
;
86 assert_se(t = strv_join(sessions, " "))do { if ((__builtin_expect(!!(!(t = strv_join(sessions, " "))
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("t = strv_join(sessions, \" \")"
), "../src/libsystemd/sd-login/test-login.c", 86, __PRETTY_FUNCTION__
); } while (0)
;
87 strv_free(sessions);
88 log_info("sd_uid_get_sessions("UID_FMT", …) → [%i] \"%s\"", u2, r, t)({ 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/libsystemd/sd-login/test-login.c", 88, __func__, "sd_uid_get_sessions("
"%" "u"", …) → [%i] \"%s\"", u2, r, t) : -abs(_e); })
;
89 free(t);
90
91 assert_se(r == sd_uid_get_sessions(u2, false, NULL))do { if ((__builtin_expect(!!(!(r == sd_uid_get_sessions(u2, 0
, ((void*)0)))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("r == sd_uid_get_sessions(u2, false, NULL)"), "../src/libsystemd/sd-login/test-login.c"
, 91, __PRETTY_FUNCTION__); } while (0)
;
92
93 r = sd_uid_get_seats(u2, false0, &seats);
94 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 94, __PRETTY_FUNCTION__); } while (0)
;
95 assert_se(r == (int) strv_length(seats))do { if ((__builtin_expect(!!(!(r == (int) strv_length(seats)
)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("r == (int) strv_length(seats)"
), "../src/libsystemd/sd-login/test-login.c", 95, __PRETTY_FUNCTION__
); } while (0)
;
96 assert_se(t = strv_join(seats, " "))do { if ((__builtin_expect(!!(!(t = strv_join(seats, " "))),0
))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("t = strv_join(seats, \" \")"
), "../src/libsystemd/sd-login/test-login.c", 96, __PRETTY_FUNCTION__
); } while (0)
;
97 strv_free(seats);
98 log_info("sd_uid_get_seats("UID_FMT", …) → [%i] \"%s\"", u2, r, t)({ 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/libsystemd/sd-login/test-login.c", 98, __func__, "sd_uid_get_seats("
"%" "u"", …) → [%i] \"%s\"", u2, r, t) : -abs(_e); })
;
99 free(t);
100
101 assert_se(r == sd_uid_get_seats(u2, false, NULL))do { if ((__builtin_expect(!!(!(r == sd_uid_get_seats(u2, 0, (
(void*)0)))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"r == sd_uid_get_seats(u2, false, NULL)"), "../src/libsystemd/sd-login/test-login.c"
, 101, __PRETTY_FUNCTION__); } while (0)
;
102 }
103
104 if (session) {
23
Assuming 'session' is non-null
24
Taking true branch
105 r = sd_session_is_active(session);
106 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 106, __PRETTY_FUNCTION__); } while (0)
;
25
Assuming 'r' is >= 0
26
Taking false branch
27
Loop condition is false. Exiting loop
107 log_info("sd_session_is_active(\"%s\") → %s", session, yes_no(r))({ 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/libsystemd/sd-login/test-login.c", 107, __func__, "sd_session_is_active(\"%s\") → %s"
, session, yes_no(r)) : -abs(_e); })
;
28
Assuming the condition is false
29
'?' condition is false
108
109 r = sd_session_is_remote(session);
110 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 110, __PRETTY_FUNCTION__); } while (0)
;
30
Assuming 'r' is >= 0
31
Taking false branch
32
Loop condition is false. Exiting loop
111 log_info("sd_session_is_remote(\"%s\") → %s", session, yes_no(r))({ 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/libsystemd/sd-login/test-login.c", 111, __func__, "sd_session_is_remote(\"%s\") → %s"
, session, yes_no(r)) : -abs(_e); })
;
33
Assuming the condition is false
34
'?' condition is false
112
113 r = sd_session_get_state(session, &state);
114 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 114, __PRETTY_FUNCTION__); } while (0)
;
35
Assuming 'r' is >= 0
36
Taking false branch
37
Loop condition is false. Exiting loop
115 log_info("sd_session_get_state(\"%s\") → \"%s\"", session, state)({ 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/libsystemd/sd-login/test-login.c", 115, __func__, "sd_session_get_state(\"%s\") → \"%s\""
, session, state) : -abs(_e); })
;
38
Assuming the condition is false
39
'?' condition is false
116
117 assert_se(sd_session_get_uid(session, &u) >= 0)do { if ((__builtin_expect(!!(!(sd_session_get_uid(session, &
u) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"sd_session_get_uid(session, &u) >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 117, __PRETTY_FUNCTION__); } while (0)
;
40
Assuming the condition is true
41
Taking false branch
42
Loop condition is false. Exiting loop
118 log_info("sd_session_get_uid(\"%s\") → "UID_FMT, session, u)({ 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/libsystemd/sd-login/test-login.c", 118, __func__, "sd_session_get_uid(\"%s\") → "
"%" "u", session, u) : -abs(_e); })
;
43
Assuming the condition is false
44
'?' condition is false
119 assert_se(u == u2)do { if ((__builtin_expect(!!(!(u == u2)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("u == u2"), "../src/libsystemd/sd-login/test-login.c"
, 119, __PRETTY_FUNCTION__); } while (0)
;
45
The right operand of '==' is a garbage value
120
121 assert_se(sd_session_get_type(session, &type) >= 0)do { if ((__builtin_expect(!!(!(sd_session_get_type(session, &
type) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("sd_session_get_type(session, &type) >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 121, __PRETTY_FUNCTION__); } while (0)
;
122 log_info("sd_session_get_type(\"%s\") → \"%s\"", session, type)({ 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/libsystemd/sd-login/test-login.c", 122, __func__, "sd_session_get_type(\"%s\") → \"%s\""
, session, type) : -abs(_e); })
;
123
124 assert_se(sd_session_get_class(session, &class) >= 0)do { if ((__builtin_expect(!!(!(sd_session_get_class(session,
&class) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("sd_session_get_class(session, &class) >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 124, __PRETTY_FUNCTION__); } while (0)
;
125 log_info("sd_session_get_class(\"%s\") → \"%s\"", session, class)({ 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/libsystemd/sd-login/test-login.c", 125, __func__, "sd_session_get_class(\"%s\") → \"%s\""
, session, class) : -abs(_e); })
;
126
127 r = sd_session_get_display(session, &display);
128 assert_se(r >= 0 || r == -ENODATA)do { if ((__builtin_expect(!!(!(r >= 0 || r == -61)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0 || r == -ENODATA"), "../src/libsystemd/sd-login/test-login.c"
, 128, __PRETTY_FUNCTION__); } while (0)
;
129 log_info("sd_session_get_display(\"%s\") → \"%s\"", session, strna(display))({ 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/libsystemd/sd-login/test-login.c", 129, __func__, "sd_session_get_display(\"%s\") → \"%s\""
, session, strna(display)) : -abs(_e); })
;
130
131 r = sd_session_get_remote_user(session, &remote_user);
132 assert_se(r >= 0 || r == -ENODATA)do { if ((__builtin_expect(!!(!(r >= 0 || r == -61)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0 || r == -ENODATA"), "../src/libsystemd/sd-login/test-login.c"
, 132, __PRETTY_FUNCTION__); } while (0)
;
133 log_info("sd_session_get_remote_user(\"%s\") → \"%s\"",({ 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/libsystemd/sd-login/test-login.c", 134, __func__, "sd_session_get_remote_user(\"%s\") → \"%s\""
, session, strna(remote_user)) : -abs(_e); })
134 session, strna(remote_user))({ 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/libsystemd/sd-login/test-login.c", 134, __func__, "sd_session_get_remote_user(\"%s\") → \"%s\""
, session, strna(remote_user)) : -abs(_e); })
;
135
136 r = sd_session_get_remote_host(session, &remote_host);
137 assert_se(r >= 0 || r == -ENODATA)do { if ((__builtin_expect(!!(!(r >= 0 || r == -61)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0 || r == -ENODATA"), "../src/libsystemd/sd-login/test-login.c"
, 137, __PRETTY_FUNCTION__); } while (0)
;
138 log_info("sd_session_get_remote_host(\"%s\") → \"%s\"",({ 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/libsystemd/sd-login/test-login.c", 139, __func__, "sd_session_get_remote_host(\"%s\") → \"%s\""
, session, strna(remote_host)) : -abs(_e); })
139 session, strna(remote_host))({ 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/libsystemd/sd-login/test-login.c", 139, __func__, "sd_session_get_remote_host(\"%s\") → \"%s\""
, session, strna(remote_host)) : -abs(_e); })
;
140
141 r = sd_session_get_seat(session, &seat);
142 if (r >= 0) {
143 assert_se(seat)do { if ((__builtin_expect(!!(!(seat)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("seat"), "../src/libsystemd/sd-login/test-login.c"
, 143, __PRETTY_FUNCTION__); } while (0)
;
144
145 log_info("sd_session_get_seat(\"%s\") → \"%s\"", session, seat)({ 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/libsystemd/sd-login/test-login.c", 145, __func__, "sd_session_get_seat(\"%s\") → \"%s\""
, session, seat) : -abs(_e); })
;
146
147 r = sd_seat_can_multi_session(seat);
148 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 148, __PRETTY_FUNCTION__); } while (0)
;
149 log_info("sd_session_can_multi_seat(\"%s\") → %s", seat, yes_no(r))({ 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/libsystemd/sd-login/test-login.c", 149, __func__, "sd_session_can_multi_seat(\"%s\") → %s"
, seat, yes_no(r)) : -abs(_e); })
;
150
151 r = sd_seat_can_tty(seat);
152 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 152, __PRETTY_FUNCTION__); } while (0)
;
153 log_info("sd_session_can_tty(\"%s\") → %s", seat, yes_no(r))({ 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/libsystemd/sd-login/test-login.c", 153, __func__, "sd_session_can_tty(\"%s\") → %s"
, seat, yes_no(r)) : -abs(_e); })
;
154
155 r = sd_seat_can_graphical(seat);
156 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 156, __PRETTY_FUNCTION__); } while (0)
;
157 log_info("sd_session_can_graphical(\"%s\") → %s", seat, yes_no(r))({ 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/libsystemd/sd-login/test-login.c", 157, __func__, "sd_session_can_graphical(\"%s\") → %s"
, seat, yes_no(r)) : -abs(_e); })
;
158 } else {
159 log_info_errno(r, "sd_session_get_seat(\"%s\"): %m", session)({ int _level = ((6)), _e = ((r)), _realm = (LOG_REALM_SYSTEMD
); (log_get_max_level_realm(_realm) >= ((_level) & 0x07
)) ? log_internal_realm(((_realm) << 10 | (_level)), _e
, "../src/libsystemd/sd-login/test-login.c", 159, __func__, "sd_session_get_seat(\"%s\"): %m"
, session) : -abs(_e); })
;
160 assert_se(r == -ENODATA)do { if ((__builtin_expect(!!(!(r == -61)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r == -ENODATA"), "../src/libsystemd/sd-login/test-login.c"
, 160, __PRETTY_FUNCTION__); } while (0)
;
161 }
162
163 assert_se(sd_uid_get_state(u, &state2) >= 0)do { if ((__builtin_expect(!!(!(sd_uid_get_state(u, &state2
) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, (
"sd_uid_get_state(u, &state2) >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 163, __PRETTY_FUNCTION__); } while (0)
;
164 log_info("sd_uid_get_state("UID_FMT", …) → %s", u, state2)({ 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/libsystemd/sd-login/test-login.c", 164, __func__, "sd_uid_get_state("
"%" "u"", …) → %s", u, state2) : -abs(_e); })
;
165 }
166
167 if (seat) {
168 _cleanup_free___attribute__((cleanup(freep))) char *session2 = NULL((void*)0), *buf = NULL((void*)0);
169 _cleanup_free___attribute__((cleanup(freep))) uid_t *uids = NULL((void*)0);
170 unsigned n;
171
172 assert_se(sd_uid_is_on_seat(u, 0, seat) > 0)do { if ((__builtin_expect(!!(!(sd_uid_is_on_seat(u, 0, seat)
> 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("sd_uid_is_on_seat(u, 0, seat) > 0"
), "../src/libsystemd/sd-login/test-login.c", 172, __PRETTY_FUNCTION__
); } while (0)
;
173
174 r = sd_seat_get_active(seat, &session2, &u2);
175 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 175, __PRETTY_FUNCTION__); } while (0)
;
176 log_info("sd_seat_get_active(\"%s\", …) → \"%s\", "UID_FMT, seat, session2, u2)({ 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/libsystemd/sd-login/test-login.c", 176, __func__, "sd_seat_get_active(\"%s\", …) → \"%s\", "
"%" "u", seat, session2, u2) : -abs(_e); })
;
177
178 r = sd_uid_is_on_seat(u, 1, seat);
179 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 179, __PRETTY_FUNCTION__); } while (0)
;
180 assert_se(!!r == streq(session, session2))do { if ((__builtin_expect(!!(!(!!r == (strcmp((session),(session2
)) == 0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!!r == streq(session, session2)"
), "../src/libsystemd/sd-login/test-login.c", 180, __PRETTY_FUNCTION__
); } while (0)
;
181
182 r = sd_seat_get_sessions(seat, &sessions, &uids, &n);
183 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 183, __PRETTY_FUNCTION__); } while (0)
;
184 assert_se(r == (int) strv_length(sessions))do { if ((__builtin_expect(!!(!(r == (int) strv_length(sessions
))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("r == (int) strv_length(sessions)"
), "../src/libsystemd/sd-login/test-login.c", 184, __PRETTY_FUNCTION__
); } while (0)
;
185 assert_se(t = strv_join(sessions, " "))do { if ((__builtin_expect(!!(!(t = strv_join(sessions, " "))
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("t = strv_join(sessions, \" \")"
), "../src/libsystemd/sd-login/test-login.c", 185, __PRETTY_FUNCTION__
); } while (0)
;
186 strv_free(sessions);
187 log_info("sd_seat_get_sessions(\"%s\", …) → %i, \"%s\", [%i] {%s}",({ 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/libsystemd/sd-login/test-login.c", 188, __func__, "sd_seat_get_sessions(\"%s\", …) → %i, \"%s\", [%i] {%s}"
, seat, r, t, n, format_uids(&buf, uids, n)) : -abs(_e); }
)
188 seat, r, t, n, format_uids(&buf, uids, n))({ 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/libsystemd/sd-login/test-login.c", 188, __func__, "sd_seat_get_sessions(\"%s\", …) → %i, \"%s\", [%i] {%s}"
, seat, r, t, n, format_uids(&buf, uids, n)) : -abs(_e); }
)
;
189 free(t);
190
191 assert_se(sd_seat_get_sessions(seat, NULL, NULL, NULL) == r)do { if ((__builtin_expect(!!(!(sd_seat_get_sessions(seat, ((
void*)0), ((void*)0), ((void*)0)) == r)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("sd_seat_get_sessions(seat, NULL, NULL, NULL) == r"
), "../src/libsystemd/sd-login/test-login.c", 191, __PRETTY_FUNCTION__
); } while (0)
;
192 }
193
194 r = sd_get_seats(&seats);
195 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 195, __PRETTY_FUNCTION__); } while (0)
;
196 assert_se(r == (int) strv_length(seats))do { if ((__builtin_expect(!!(!(r == (int) strv_length(seats)
)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("r == (int) strv_length(seats)"
), "../src/libsystemd/sd-login/test-login.c", 196, __PRETTY_FUNCTION__
); } while (0)
;
197 assert_se(t = strv_join(seats, ", "))do { if ((__builtin_expect(!!(!(t = strv_join(seats, ", "))),
0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("t = strv_join(seats, \", \")"
), "../src/libsystemd/sd-login/test-login.c", 197, __PRETTY_FUNCTION__
); } while (0)
;
198 strv_free(seats);
199 log_info("sd_get_seats(…) → [%i] \"%s\"", r, t)({ 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/libsystemd/sd-login/test-login.c", 199, __func__, "sd_get_seats(…) → [%i] \"%s\""
, r, t) : -abs(_e); })
;
200 t = mfree(t);
201
202 assert_se(sd_get_seats(NULL) == r)do { if ((__builtin_expect(!!(!(sd_get_seats(((void*)0)) == r
)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("sd_get_seats(NULL) == r"
), "../src/libsystemd/sd-login/test-login.c", 202, __PRETTY_FUNCTION__
); } while (0)
;
203
204 r = sd_seat_get_active(NULL((void*)0), &t, NULL((void*)0));
205 assert_se(IN_SET(r, 0, -ENODATA))do { if ((__builtin_expect(!!(!(({ _Bool _found = 0; static __attribute__
((unused)) char _static_assert__macros_need_to_be_extended[20
- sizeof((int[]){0, -61})/sizeof(int)]; switch(r) { case 0: case
-61: _found = 1; break; default: break; } _found; }))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("IN_SET(r, 0, -ENODATA)"), "../src/libsystemd/sd-login/test-login.c"
, 205, __PRETTY_FUNCTION__); } while (0)
;
206 log_info("sd_seat_get_active(NULL, …) (active session on current seat) → %s", strnull(t))({ 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/libsystemd/sd-login/test-login.c", 206, __func__, "sd_seat_get_active(NULL, …) (active session on current seat) → %s"
, strnull(t)) : -abs(_e); })
;
207 free(t);
208
209 r = sd_get_sessions(&sessions);
210 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 210, __PRETTY_FUNCTION__); } while (0)
;
211 assert_se(r == (int) strv_length(sessions))do { if ((__builtin_expect(!!(!(r == (int) strv_length(sessions
))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("r == (int) strv_length(sessions)"
), "../src/libsystemd/sd-login/test-login.c", 211, __PRETTY_FUNCTION__
); } while (0)
;
212 assert_se(t = strv_join(sessions, ", "))do { if ((__builtin_expect(!!(!(t = strv_join(sessions, ", ")
)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("t = strv_join(sessions, \", \")"
), "../src/libsystemd/sd-login/test-login.c", 212, __PRETTY_FUNCTION__
); } while (0)
;
213 strv_free(sessions);
214 log_info("sd_get_sessions(…) → [%i] \"%s\"", r, t)({ 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/libsystemd/sd-login/test-login.c", 214, __func__, "sd_get_sessions(…) → [%i] \"%s\""
, r, t) : -abs(_e); })
;
215 free(t);
216
217 assert_se(sd_get_sessions(NULL) == r)do { if ((__builtin_expect(!!(!(sd_get_sessions(((void*)0)) ==
r)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("sd_get_sessions(NULL) == r"
), "../src/libsystemd/sd-login/test-login.c", 217, __PRETTY_FUNCTION__
); } while (0)
;
218
219 {
220 _cleanup_free___attribute__((cleanup(freep))) uid_t *uids = NULL((void*)0);
221 _cleanup_free___attribute__((cleanup(freep))) char *buf = NULL((void*)0);
222
223 r = sd_get_uids(&uids);
224 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 224, __PRETTY_FUNCTION__); } while (0)
;
225 log_info("sd_get_uids(…) → [%i] {%s}", r, format_uids(&buf, uids, r))({ 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/libsystemd/sd-login/test-login.c", 225, __func__, "sd_get_uids(…) → [%i] {%s}"
, r, format_uids(&buf, uids, r)) : -abs(_e); })
;
226
227 assert_se(sd_get_uids(NULL) == r)do { if ((__builtin_expect(!!(!(sd_get_uids(((void*)0)) == r)
),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("sd_get_uids(NULL) == r"
), "../src/libsystemd/sd-login/test-login.c", 227, __PRETTY_FUNCTION__
); } while (0)
;
228 }
229
230 {
231 _cleanup_strv_free___attribute__((cleanup(strv_freep))) char **machines = NULL((void*)0);
232 _cleanup_free___attribute__((cleanup(freep))) char *buf = NULL((void*)0);
233
234 r = sd_get_machine_names(&machines);
235 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 235, __PRETTY_FUNCTION__); } while (0)
;
236 assert_se(r == (int) strv_length(machines))do { if ((__builtin_expect(!!(!(r == (int) strv_length(machines
))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("r == (int) strv_length(machines)"
), "../src/libsystemd/sd-login/test-login.c", 236, __PRETTY_FUNCTION__
); } while (0)
;
237 assert_se(buf = strv_join(machines, " "))do { if ((__builtin_expect(!!(!(buf = strv_join(machines, " "
))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("buf = strv_join(machines, \" \")"
), "../src/libsystemd/sd-login/test-login.c", 237, __PRETTY_FUNCTION__
); } while (0)
;
238 log_info("sd_get_machines(…) → [%i] \"%s\"", r, buf)({ 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/libsystemd/sd-login/test-login.c", 238, __func__, "sd_get_machines(…) → [%i] \"%s\""
, r, buf) : -abs(_e); })
;
239
240 assert_se(sd_get_machine_names(NULL) == r)do { if ((__builtin_expect(!!(!(sd_get_machine_names(((void*)
0)) == r)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("sd_get_machine_names(NULL) == r"
), "../src/libsystemd/sd-login/test-login.c", 240, __PRETTY_FUNCTION__
); } while (0)
;
241 }
242}
243
244static void test_monitor(void) {
245 sd_login_monitor *m = NULL((void*)0);
246 unsigned n;
247 int r;
248
249 r = sd_login_monitor_new("session", &m);
250 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 250, __PRETTY_FUNCTION__); } while (0)
;
251
252 for (n = 0; n < 5; n++) {
253 struct pollfd pollfd = {};
254 usec_t timeout, nw;
255
256 assert_se((pollfd.fd = sd_login_monitor_get_fd(m)) >= 0)do { if ((__builtin_expect(!!(!((pollfd.fd = sd_login_monitor_get_fd
(m)) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("(pollfd.fd = sd_login_monitor_get_fd(m)) >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 256, __PRETTY_FUNCTION__); } while (0)
;
257 assert_se((pollfd.events = sd_login_monitor_get_events(m)) >= 0)do { if ((__builtin_expect(!!(!((pollfd.events = sd_login_monitor_get_events
(m)) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("(pollfd.events = sd_login_monitor_get_events(m)) >= 0"
), "../src/libsystemd/sd-login/test-login.c", 257, __PRETTY_FUNCTION__
); } while (0)
;
258
259 assert_se(sd_login_monitor_get_timeout(m, &timeout) >= 0)do { if ((__builtin_expect(!!(!(sd_login_monitor_get_timeout(
m, &timeout) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("sd_login_monitor_get_timeout(m, &timeout) >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 259, __PRETTY_FUNCTION__); } while (0)
;
260
261 nw = now(CLOCK_MONOTONIC1);
262
263 r = poll(&pollfd, 1,
264 timeout == (uint64_t) -1 ? -1 :
265 timeout > nw ? (int) ((timeout - nw) / 1000) :
266 0);
267
268 assert_se(r >= 0)do { if ((__builtin_expect(!!(!(r >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("r >= 0"), "../src/libsystemd/sd-login/test-login.c"
, 268, __PRETTY_FUNCTION__); } while (0)
;
269
270 sd_login_monitor_flush(m);
271 printf("Wake!\n");
272 }
273
274 sd_login_monitor_unref(m);
275}
276
277int main(int argc, char* argv[]) {
278 log_parse_environment()log_parse_environment_realm(LOG_REALM_SYSTEMD);
279 log_open();
280
281 log_info("/* Information printed is from the live system */")({ 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/libsystemd/sd-login/test-login.c", 281, __func__, "/* Information printed is from the live system */"
) : -abs(_e); })
;
282
283 test_login();
284
285 if (streq_ptr(argv[1], "-m"))
286 test_monitor();
287
288 return 0;
289}