linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 09/10] kernel/sysctl.c: Replace 1 and 0 by corresponding boolean value
       [not found] ` <20200327212358.5752-1-jbi.octave@gmail.com>
@ 2020-03-27 21:23   ` Jules Irenge
  2020-03-28 21:24     ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Jules Irenge @ 2020-03-27 21:23 UTC (permalink / raw)
  To: julia.lawall
  Cc: boqun.feng, Luis Chamberlain, Kees Cook, Iurii Zaikin,
	open list:PROC SYSCTL, open list:PROC SYSCTL

Coccinelle reports a warning

WARNING: Assignment of 0/1 to bool variable

To fix this, values 1 and 0 of first variable
are replaced by true and false respectively.
Given that variable first is of bool type.
This fixes the warnings.

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 kernel/sysctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ad5b88a53c5a..4132a35e85bd 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -3158,7 +3158,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
 			 void __user *buffer, size_t *lenp, loff_t *ppos)
 {
 	int err = 0;
-	bool first = 1;
+	bool first = true;
 	size_t left = *lenp;
 	unsigned long bitmap_len = table->maxlen;
 	unsigned long *bitmap = *(unsigned long **) table->data;
@@ -3249,7 +3249,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
 			}
 
 			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
-			first = 0;
+			first = false;
 			proc_skip_char(&p, &left, '\n');
 		}
 		kfree(kbuf);
@@ -3281,7 +3281,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
 					break;
 			}
 
-			first = 0; bit_b++;
+			first = false; bit_b++;
 		}
 		if (!err)
 			err = proc_put_char(&buffer, &left, '\n');
-- 
2.25.1


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

* Re: [PATCH 09/10] kernel/sysctl.c: Replace 1 and 0 by corresponding boolean value
  2020-03-27 21:23   ` [PATCH 09/10] kernel/sysctl.c: Replace 1 and 0 by corresponding boolean value Jules Irenge
@ 2020-03-28 21:24     ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2020-03-28 21:24 UTC (permalink / raw)
  To: Andrew Morton
  Cc: julia.lawall, boqun.feng, Jules Irenge, Luis Chamberlain,
	Iurii Zaikin, open list:PROC SYSCTL, open list:PROC SYSCTL

On Fri, Mar 27, 2020 at 09:23:56PM +0000, Jules Irenge wrote:
> Coccinelle reports a warning
> 
> WARNING: Assignment of 0/1 to bool variable
> 
> To fix this, values 1 and 0 of first variable
> are replaced by true and false respectively.
> Given that variable first is of bool type.
> This fixes the warnings.

Sure! Thanks. :)

> Signed-off-by: Jules Irenge <jbi.octave@gmail.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  kernel/sysctl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index ad5b88a53c5a..4132a35e85bd 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -3158,7 +3158,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
>  			 void __user *buffer, size_t *lenp, loff_t *ppos)
>  {
>  	int err = 0;
> -	bool first = 1;
> +	bool first = true;
>  	size_t left = *lenp;
>  	unsigned long bitmap_len = table->maxlen;
>  	unsigned long *bitmap = *(unsigned long **) table->data;
> @@ -3249,7 +3249,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
>  			}
>  
>  			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
> -			first = 0;
> +			first = false;
>  			proc_skip_char(&p, &left, '\n');
>  		}
>  		kfree(kbuf);
> @@ -3281,7 +3281,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
>  					break;
>  			}
>  
> -			first = 0; bit_b++;
> +			first = false; bit_b++;
>  		}
>  		if (!err)
>  			err = proc_put_char(&buffer, &left, '\n');
> -- 
> 2.25.1
> 

-- 
Kees Cook

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

end of thread, other threads:[~2020-03-28 21:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <0/10>
     [not found] ` <20200327212358.5752-1-jbi.octave@gmail.com>
2020-03-27 21:23   ` [PATCH 09/10] kernel/sysctl.c: Replace 1 and 0 by corresponding boolean value Jules Irenge
2020-03-28 21:24     ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).