diff options
author | Dmitry V. Levin <ldv@strace.io> | 2023-07-14 10:00:00 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-07-28 14:28:35 +0200 |
commit | 1553f9b1bc127eb21fc08a791d0a4a79e4a839ff (patch) | |
tree | 420b203fffc2a81bca966b2f569eee338daaddda /src/test/test-procfs-util.c | |
parent | userdb: cleanup use of ERRNO_IS_PRIVILEGE() (diff) | |
download | systemd-1553f9b1bc127eb21fc08a791d0a4a79e4a839ff.tar.xz systemd-1553f9b1bc127eb21fc08a791d0a4a79e4a839ff.zip |
test: cleanup use of ERRNO_IS_PRIVILEGE()
Given that ERRNO_IS_PRIVILEGE() also matches positive values,
make sure this macro is not called with arguments that do not have
errno semantics.
In this case the arguments passed to ERRNO_IS_PRIVILEGE() are the values
returned by procfs_get_pid_max() and procfs_get_threads_max() which are
not expected to return any positive values, but let's be consistent
anyway and move ERRNO_IS_PRIVILEGE() invocations to the branches where
the return values are known to be negative.
Diffstat (limited to 'src/test/test-procfs-util.c')
-rw-r--r-- | src/test/test-procfs-util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/test-procfs-util.c b/src/test/test-procfs-util.c index 7c3aa21d65..5427e1bec3 100644 --- a/src/test/test-procfs-util.c +++ b/src/test/test-procfs-util.c @@ -28,14 +28,14 @@ int main(int argc, char *argv[]) { pid_max = TASKS_MAX; r = procfs_get_pid_max(&pid_max); - if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r)) + if (r == -ENOENT || (r < 0 && ERRNO_IS_PRIVILEGE(r))) return log_tests_skipped_errno(r, "can't get pid max"); assert(r >= 0); log_info("kernel.pid_max: %"PRIu64, pid_max); threads_max = TASKS_MAX; r = procfs_get_threads_max(&threads_max); - if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r)) + if (r == -ENOENT || (r < 0 && ERRNO_IS_PRIVILEGE(r))) return log_tests_skipped_errno(r, "can't get threads max"); assert(r >= 0); log_info("kernel.threads-max: %"PRIu64, threads_max); |