From: Dmitry V. Levin Date: Fri, 14 Jul 2023 08:00:00 +0000 (+0000) Subject: test: cleanup use of ERRNO_IS_PRIVILEGE() X-Git-Tag: v255-rc1~886^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1553f9b1bc127eb21fc08a791d0a4a79e4a839ff;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/test/test-procfs-util.c b/src/test/test-procfs-util.c index 7c3aa21d657..5427e1bec3a 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);