2021-11-25 01:48:41

by David Yang

[permalink] [raw]
Subject: [PATCH] tests: remove unneeded conversion to bool

From: Yang Guang <[email protected]>

The coccinelle report
./tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c:225:18-23:
WARNING: conversion to bool not needed here
Relational and logical operators evaluate to bool,
explicit conversion is overly verbose and unneeded.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Yang Guang <[email protected]>
---
.../selftests/move_mount_set_group/move_mount_set_group_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
index 860198f83a53..80ff0b692486 100644
--- a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
+++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
@@ -222,7 +222,7 @@ static int move_mount_set_group_supported(void)
AT_FDCWD, SET_GROUP_TO, MOVE_MOUNT_SET_GROUP);
umount2("/tmp", MNT_DETACH);

- return ret < 0 ? false : true;
+ return ret >= 0;
}

FIXTURE(move_mount_set_group) {
--
2.30.2



2021-12-03 18:35:01

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] tests: remove unneeded conversion to bool

On 11/24/21 5:58 PM, [email protected] wrote:
> From: Yang Guang <[email protected]>
>
> The coccinelle report
> ./tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c:225:18-23:
> WARNING: conversion to bool not needed here
> Relational and logical operators evaluate to bool,
> explicit conversion is overly verbose and unneeded.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Yang Guang <[email protected]>
> ---
> .../selftests/move_mount_set_group/move_mount_set_group_test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> index 860198f83a53..80ff0b692486 100644
> --- a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> +++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> @@ -222,7 +222,7 @@ static int move_mount_set_group_supported(void)
> AT_FDCWD, SET_GROUP_TO, MOVE_MOUNT_SET_GROUP);
> umount2("/tmp", MNT_DETACH);
>
> - return ret < 0 ? false : true;
> + return ret >= 0;
> }
>
> FIXTURE(move_mount_set_group) {
>

In this case it would be better to change the return type for
move_mount_set_group_supported() to bool

thanks,
-- Shuah

2021-12-03 18:35:08

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH] tests: remove unneeded conversion to bool

On 11/24/21 5:58 PM, [email protected] wrote:
> From: Yang Guang <[email protected]>
>
> The coccinelle report
> ./tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c:225:18-23:
> WARNING: conversion to bool not needed here
> Relational and logical operators evaluate to bool,
> explicit conversion is overly verbose and unneeded.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Yang Guang <[email protected]>
> ---
> .../selftests/move_mount_set_group/move_mount_set_group_test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> index 860198f83a53..80ff0b692486 100644
> --- a/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> +++ b/tools/testing/selftests/move_mount_set_group/move_mount_set_group_test.c
> @@ -222,7 +222,7 @@ static int move_mount_set_group_supported(void)
> AT_FDCWD, SET_GROUP_TO, MOVE_MOUNT_SET_GROUP);
> umount2("/tmp", MNT_DETACH);
>
> - return ret < 0 ? false : true;
> + return ret >= 0;
> }
>
> FIXTURE(move_mount_set_group) {
>

In this case it would be better to change the return type for
move_mount_set_group_supported() to bool

thanks,
-- Shuah