Message ID | 1620469990-22182-1-git-send-email-jiapeng.chong@linux.alibaba.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2] sysctl: Remove redundant assignment to first | expand |
On Sat, May 08, 2021 at 06:33:10PM +0800, Jiapeng Chong wrote: > Variable first is set to '0', but this value is never read as it is > not used later on, hence it is a redundant assignment and can be > removed. > > Clean up the following clang-analyzer warning: > > kernel/sysctl.c:1562:4: warning: Value stored to 'first' is never read > [clang-analyzer-deadcode.DeadStores]. > > Reported-by: Abaci Robot <abaci@linux.alibaba.com> > Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> To re-iterate, this does not fix anything, it is just a clean up. Acked-by: Luis Chamberlain <mcgrof@kernel.org> Luis > --- > Changes in v2: > -For the follow advice: https://lore.kernel.org/patchwork/patch/1422497/ > > kernel/sysctl.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/kernel/sysctl.c b/kernel/sysctl.c > index 14edf84..23de0d9 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -1474,7 +1474,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; > @@ -1559,12 +1558,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); > -- > 1.8.3.1 >
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 14edf84..23de0d9 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1474,7 +1474,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; @@ -1559,12 +1558,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);
Variable first is set to '0', but this value is never read as it is not used later on, hence it is a redundant assignment and can be removed. Clean up the following clang-analyzer warning: kernel/sysctl.c:1562:4: warning: Value stored to 'first' is never read [clang-analyzer-deadcode.DeadStores]. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> --- Changes in v2: -For the follow advice: https://lore.kernel.org/patchwork/patch/1422497/ kernel/sysctl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)