linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kernel/sysctl.c: drop unneeded assignment in proc_do_large_bitmap()
@ 2020-10-07 15:19 Sudip Mukherjee
  2020-10-07 18:44 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Sudip Mukherjee @ 2020-10-07 15:19 UTC (permalink / raw)
  To: Luis Chamberlain, Kees Cook, Iurii Zaikin
  Cc: linux-kernel, linux-safety, linux-fsdevel, Sudip Mukherjee

The variable 'first' is assigned 0 inside the while loop in the if block
but it is not used in the if block and is only used in the else block.
So, remove the unneeded assignment and move the variable in the else block.

Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---

v1: only had the removal of assignment

The resultant binary stayed same after this change. Verified with
md5sum which remained same with and without this change.

$ md5sum kernel/sysctl.o 
77e8b8f3cd9da4446e7f117115c8ba84  kernel/sysctl.o

 kernel/sysctl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ce75c67572b9..cc274a431d91 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1423,7 +1423,6 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
 			 void *buffer, size_t *lenp, loff_t *ppos)
 {
 	int err = 0;
-	bool first = 1;
 	size_t left = *lenp;
 	unsigned long bitmap_len = table->maxlen;
 	unsigned long *bitmap = *(unsigned long **) table->data;
@@ -1508,12 +1507,12 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
 			}
 
 			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
-			first = 0;
 			proc_skip_char(&p, &left, '\n');
 		}
 		left += skipped;
 	} else {
 		unsigned long bit_a, bit_b = 0;
+		bool first = 1;
 
 		while (left) {
 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
-- 
2.11.0


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

* Re: [PATCH v2] kernel/sysctl.c: drop unneeded assignment in proc_do_large_bitmap()
  2020-10-07 15:19 [PATCH v2] kernel/sysctl.c: drop unneeded assignment in proc_do_large_bitmap() Sudip Mukherjee
@ 2020-10-07 18:44 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2020-10-07 18:44 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Luis Chamberlain, Iurii Zaikin, linux-kernel, linux-safety,
	linux-fsdevel

On Wed, Oct 07, 2020 at 04:19:04PM +0100, Sudip Mukherjee wrote:
> The variable 'first' is assigned 0 inside the while loop in the if block
> but it is not used in the if block and is only used in the else block.
> So, remove the unneeded assignment and move the variable in the else block.
> 
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>

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

-- 
Kees Cook

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

end of thread, other threads:[~2020-10-07 18:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 15:19 [PATCH v2] kernel/sysctl.c: drop unneeded assignment in proc_do_large_bitmap() Sudip Mukherjee
2020-10-07 18:44 ` 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).