From: Frantisek Sumsal Date: Tue, 26 Dec 2023 19:21:48 +0000 (+0100) Subject: test: use IN_SET()/ERRNO_IS_NEG_*() more X-Git-Tag: v256-rc1~1379^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f8b3838c9fcb644dca47d56b64058a6678069ff;p=thirdparty%2Fsystemd.git test: use IN_SET()/ERRNO_IS_NEG_*() more --- diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index 0c1b849c897..1f71a258598 100644 --- a/src/test/test-mountpoint-util.c +++ b/src/test/test-mountpoint-util.c @@ -328,23 +328,23 @@ TEST(mount_option_supported) { r = mount_option_supported("tmpfs", "size", "64M"); log_info("tmpfs supports size=64M: %s (%i)", r < 0 ? "don't know" : yes_no(r), r); - assert_se(r > 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + assert_se(r > 0 || r == -EAGAIN || ERRNO_IS_NEG_PRIVILEGE(r)); r = mount_option_supported("ext4", "discard", NULL); log_info("ext4 supports discard: %s (%i)", r < 0 ? "don't know" : yes_no(r), r); - assert_se(r > 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + assert_se(r > 0 || r == -EAGAIN || ERRNO_IS_NEG_PRIVILEGE(r)); r = mount_option_supported("tmpfs", "idontexist", "64M"); log_info("tmpfs supports idontexist: %s (%i)", r < 0 ? "don't know" : yes_no(r), r); - assert_se(r == 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + assert_se(IN_SET(r, 0, -EAGAIN) || ERRNO_IS_NEG_PRIVILEGE(r)); r = mount_option_supported("tmpfs", "ialsodontexist", NULL); log_info("tmpfs supports ialsodontexist: %s (%i)", r < 0 ? "don't know" : yes_no(r), r); - assert_se(r == 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + assert_se(IN_SET(r, 0, -EAGAIN) || ERRNO_IS_NEG_PRIVILEGE(r)); r = mount_option_supported("proc", "hidepid", "1"); log_info("proc supports hidepid=1: %s (%i)", r < 0 ? "don't know" : yes_no(r), r); - assert_se(r >= 0 || r == -EAGAIN || (r < 0 && ERRNO_IS_PRIVILEGE(r))); + assert_se(r >= 0 || r == -EAGAIN || ERRNO_IS_NEG_PRIVILEGE(r)); } TEST(fstype_can_discard) { diff --git a/src/test/test-xattr-util.c b/src/test/test-xattr-util.c index 85901c9a49b..b473165a3e0 100644 --- a/src/test/test-xattr-util.c +++ b/src/test/test-xattr-util.c @@ -45,7 +45,7 @@ TEST(getxattr_at_malloc) { fd = open("/", O_RDONLY|O_DIRECTORY|O_CLOEXEC|O_NOCTTY); assert_se(fd >= 0); r = getxattr_at_malloc(fd, "usr", "user.idontexist", 0, &value); - assert_se(r < 0 && ERRNO_IS_XATTR_ABSENT(r)); + assert_se(ERRNO_IS_NEG_XATTR_ABSENT(r)); safe_close(fd); fd = open(x, O_PATH|O_CLOEXEC); @@ -99,7 +99,7 @@ TEST(xsetxattr) { /* by full path */ r = xsetxattr(AT_FDCWD, x, "user.foo", "fullpath", SIZE_MAX, 0); - if (r < 0 && ERRNO_IS_NOT_SUPPORTED(r)) + if (ERRNO_IS_NEG_NOT_SUPPORTED(r)) return (void) log_tests_skipped_errno(r, "no xattrs supported on /var/tmp"); assert_se(r >= 0); verify_xattr(dfd, "fullpath");