From 1553f9b1bc127eb21fc08a791d0a4a79e4a839ff Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 14 Jul 2023 08:00:00 +0000 Subject: [PATCH] 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. --- src/test/test-procfs-util.c | 4 ++-- 1 file 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); -- 2.25.1