Skip to contentSkip to conversation

kernel/sysctl.c: drop unneeded assignment in proc_do_large_bitmap()

PATCH Superseded Sudip Mukherjee 2 participants 2 messages Oct 5, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/sysctl.c: drop unneeded assignment in proc_do_large_bitmap()

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.

---

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

$ md5sum kernel/sysctl.o 
e9e97adbfd3f0b32f83dd35d100c0e4e  kernel/sysctl.o
 kernel/sysctl.c | 1 -
 1 file changed, 1 deletion(-)
kernel/sysctl.c +0 -1
index ce75c67572b9..b51ebfd1ba6e 100644
@@ -1508,7 +1508,6 @@ 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;
Signature · 1 line
2.11.0
#1 lore raw
Quoted 3 lines · 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.

True, but in this case, please move the definition of "first" into the else block so it in only in scope there.

Thanks!

-Kees

Quoted 28 lines

---

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

$ md5sum kernel/sysctl.o 
e9e97adbfd3f0b32f83dd35d100c0e4e  kernel/sysctl.o
 kernel/sysctl.c | 1 -
 1 file changed, 1 deletion(-)
kernel/sysctl.c +0 -1
index ce75c67572b9..b51ebfd1ba6e 100644
@@ -1508,7 +1508,6 @@ 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;
Signature · 1 line
2.11.0
Signature · 1 line
Kees Cook