linux-4.14-rc3/arch/powerpc/perf/imc-pmu.c:599: pointless test ?

3 messages, 3 authors, 2017-10-09 · open the first message on its own page

linux-4.14-rc3/arch/powerpc/perf/imc-pmu.c:599: pointless test ?

From: David Binderman <hidden>
Date: 2017-10-06 18:55:02

Hello there,

linux-4.14-rc3/arch/powerpc/perf/imc-pmu.c:599]: (style) Unsigned variable =
'ncpu' can't be negative so it is unnecessary to test it.

Source code is

    if (ncpu >=3D 0 && ncpu < nr_cpu_ids) {

but

    unsigned int ncpu, core_id;

Suggest remove test.

Regards

David Binderman=

Re: linux-4.14-rc3/arch/powerpc/perf/imc-pmu.c:599: pointless test ?

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2017-10-09 05:01:54

David Binderman [off-list ref] writes:
Hello there,

linux-4.14-rc3/arch/powerpc/perf/imc-pmu.c:599]: (style) Unsigned variable 'ncpu' can't be negative so it is unnecessary to test it.

Source code is

    if (ncpu >= 0 && ncpu < nr_cpu_ids) {

but

    unsigned int ncpu, core_id;

Suggest remove test.
Thanks.

Notifying the author would be more helpful:

$ git blame -L 599,599 arch/powerpc/perf/imc-pmu.c
39a846db1d574 (Anju T Sudhakar 2017-07-19 03:06:35 +0530 599)   if (ncpu >= 0 && ncpu < nr_cpu_ids) {
$ git log -1 --format=%ae 39a846db1d574
anju@linux.vnet.ibm.com

cheers

Re: linux-4.14-rc3/arch/powerpc/perf/imc-pmu.c:599: pointless test ?

From: Anju T Sudhakar <hidden>
Date: 2017-10-09 11:38:58

Hi David,


On Monday 09 October 2017 10:31 AM, Michael Ellerman wrote:
David Binderman [off-list ref] writes:
quoted
Hello there,

linux-4.14-rc3/arch/powerpc/perf/imc-pmu.c:599]: (style) Unsigned variable 'ncpu' can't be negative so it is unnecessary to test it.

Source code is

     if (ncpu >= 0 && ncpu < nr_cpu_ids) {

but

     unsigned int ncpu, core_id;

Suggest remove test.
Nice catch. Thanks for mentioning this. I will fix this.

Thanks,
Anju
Thanks.

Notifying the author would be more helpful:

$ git blame -L 599,599 arch/powerpc/perf/imc-pmu.c
39a846db1d574 (Anju T Sudhakar 2017-07-19 03:06:35 +0530 599)   if (ncpu >= 0 && ncpu < nr_cpu_ids) {
$ git log -1 --format=%ae 39a846db1d574
anju@linux.vnet.ibm.com

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help