All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tests: remove unneeded conversion to bool
@ 2021-12-06  0:07 davidcomponentone
  2021-12-06 19:03 ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: davidcomponentone @ 2021-12-06  0:07 UTC (permalink / raw)
  To: shuah
  Cc: skhan, davidcomponentone, ptikhomirov, christian.brauner,
	yang.guang5, linux-kselftest, linux-kernel, Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

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 <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>

---

Changes in v2:
- Change the return type to bool.
---
 .../move_mount_set_group/move_mount_set_group_test.c   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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..50ed5d475dd1 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
@@ -191,7 +191,7 @@ static bool is_shared_mount(const char *path)
 #define SET_GROUP_FROM	"/tmp/move_mount_set_group_supported_from"
 #define SET_GROUP_TO	"/tmp/move_mount_set_group_supported_to"
 
-static int move_mount_set_group_supported(void)
+static bool move_mount_set_group_supported(void)
 {
 	int ret;
 
@@ -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) {
@@ -232,7 +232,7 @@ FIXTURE(move_mount_set_group) {
 
 FIXTURE_SETUP(move_mount_set_group)
 {
-	int ret;
+	bool ret;
 
 	ASSERT_EQ(prepare_unpriv_mountns(), 0);
 
@@ -254,7 +254,7 @@ FIXTURE_SETUP(move_mount_set_group)
 
 FIXTURE_TEARDOWN(move_mount_set_group)
 {
-	int ret;
+	bool ret;
 
 	ret = move_mount_set_group_supported();
 	ASSERT_GE(ret, 0);
@@ -348,7 +348,7 @@ TEST_F(move_mount_set_group, complex_sharing_copying)
 		.shared = false,
 	};
 	pid_t pid;
-	int ret;
+	bool ret;
 
 	ret = move_mount_set_group_supported();
 	ASSERT_GE(ret, 0);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] tests: remove unneeded conversion to bool
  2021-12-06  0:07 [PATCH v2] tests: remove unneeded conversion to bool davidcomponentone
@ 2021-12-06 19:03 ` Shuah Khan
  2021-12-07  0:20   ` David Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2021-12-06 19:03 UTC (permalink / raw)
  To: davidcomponentone, shuah
  Cc: ptikhomirov, christian.brauner, yang.guang5, linux-kselftest,
	linux-kernel, Zeal Robot, Shuah Khan

On 12/5/21 5:07 PM, davidcomponentone@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
> 
> 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 <zealci@zte.com.cn>
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> 
> ---
> 
> Changes in v2:
> - Change the return type to bool.
> ---
>   .../move_mount_set_group/move_mount_set_group_test.c   | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> 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..50ed5d475dd1 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
> @@ -191,7 +191,7 @@ static bool is_shared_mount(const char *path)
>   #define SET_GROUP_FROM	"/tmp/move_mount_set_group_supported_from"
>   #define SET_GROUP_TO	"/tmp/move_mount_set_group_supported_to"
>   
> -static int move_mount_set_group_supported(void)
> +static bool move_mount_set_group_supported(void)
>   {
>   	int ret;
>   
> @@ -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) {
> @@ -232,7 +232,7 @@ FIXTURE(move_mount_set_group) {
>   
>   FIXTURE_SETUP(move_mount_set_group)
>   {
> -	int ret;
> +	bool ret;
>   
>   	ASSERT_EQ(prepare_unpriv_mountns(), 0);
>   
> @@ -254,7 +254,7 @@ FIXTURE_SETUP(move_mount_set_group)
>   
>   FIXTURE_TEARDOWN(move_mount_set_group)
>   {
> -	int ret;
> +	bool ret;
>   
>   	ret = move_mount_set_group_supported();
>   	ASSERT_GE(ret, 0);
> @@ -348,7 +348,7 @@ TEST_F(move_mount_set_group, complex_sharing_copying)
>   		.shared = false,
>   	};
>   	pid_t pid;
> -	int ret;
> +	bool ret;
>   
>   	ret = move_mount_set_group_supported();
>   	ASSERT_GE(ret, 0);
> 

Applied. In the future use selftests/<test>: .... convention for
patch summary. Review "git log <filename>" history for how to
write summaries and change logs.

I fixed this one for now.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] tests: remove unneeded conversion to bool
  2021-12-06 19:03 ` Shuah Khan
@ 2021-12-07  0:20   ` David Yang
  0 siblings, 0 replies; 3+ messages in thread
From: David Yang @ 2021-12-07  0:20 UTC (permalink / raw)
  To: Shuah Khan
  Cc: shuah, ptikhomirov, christian.brauner, yang.guang5,
	linux-kselftest, linux-kernel, Zeal Robot

Thank you for your advice.

On Mon, Dec 06, 2021 at 12:03:06PM -0700, Shuah Khan wrote:
> On 12/5/21 5:07 PM, davidcomponentone@gmail.com wrote:
> > From: Yang Guang <yang.guang5@zte.com.cn>
> > 
> > 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 <zealci@zte.com.cn>
> > Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> > 
> > ---
> > 
> > Changes in v2:
> > - Change the return type to bool.
> > ---
> >   .../move_mount_set_group/move_mount_set_group_test.c   | 10 +++++-----
> >   1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > 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..50ed5d475dd1 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
> > @@ -191,7 +191,7 @@ static bool is_shared_mount(const char *path)
> >   #define SET_GROUP_FROM	"/tmp/move_mount_set_group_supported_from"
> >   #define SET_GROUP_TO	"/tmp/move_mount_set_group_supported_to"
> > -static int move_mount_set_group_supported(void)
> > +static bool move_mount_set_group_supported(void)
> >   {
> >   	int ret;
> > @@ -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) {
> > @@ -232,7 +232,7 @@ FIXTURE(move_mount_set_group) {
> >   FIXTURE_SETUP(move_mount_set_group)
> >   {
> > -	int ret;
> > +	bool ret;
> >   	ASSERT_EQ(prepare_unpriv_mountns(), 0);
> > @@ -254,7 +254,7 @@ FIXTURE_SETUP(move_mount_set_group)
> >   FIXTURE_TEARDOWN(move_mount_set_group)
> >   {
> > -	int ret;
> > +	bool ret;
> >   	ret = move_mount_set_group_supported();
> >   	ASSERT_GE(ret, 0);
> > @@ -348,7 +348,7 @@ TEST_F(move_mount_set_group, complex_sharing_copying)
> >   		.shared = false,
> >   	};
> >   	pid_t pid;
> > -	int ret;
> > +	bool ret;
> >   	ret = move_mount_set_group_supported();
> >   	ASSERT_GE(ret, 0);
> > 
> 
> Applied. In the future use selftests/<test>: .... convention for
> patch summary. Review "git log <filename>" history for how to
> write summaries and change logs.
> 
> I fixed this one for now.
> 
> thanks,
> -- Shuah

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-07  0:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06  0:07 [PATCH v2] tests: remove unneeded conversion to bool davidcomponentone
2021-12-06 19:03 ` Shuah Khan
2021-12-07  0:20   ` David Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.