linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Possible bug in linux-6.2/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_thresh_marked_sample_test.c
@ 2023-02-24 14:32 David Binderman
  2023-02-27  5:26 ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: David Binderman @ 2023-02-24 14:32 UTC (permalink / raw)
  To: mpe@ellerman.id.au, npiggin@gmail.com,
	christophe.leroy@csgroup.eu, shuah@kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-kselftest@vger.kernel.org,
	Linux Kernel Mailing List

Hello there,

I ran the static analyser cppcheck over the linux-6.2 source code and got this:

linux-6.2/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_thresh_marked_sample_test.c:68:10: style: Same expression '0x3' found multiple times in chain of '&' operators. [duplicateExpression]

Source code is

    FAIL_IF(EV_CODE_EXTRACT(event.attr.config, sample & 0x3) !=
            get_mmcra_sample_mode(get_reg_value(intr_regs, "MMCRA"), 4));

but

#define EV_CODE_EXTRACT(x, y)   \
    ((x >> ev_shift_##y) & ev_mask_##y)


Given the token pasting, I very much doubt an expression like "sample & 0x3"
will work correctly. Same thing on the line above 

    FAIL_IF(EV_CODE_EXTRACT(event.attr.config, sample >> 2) !=
            get_mmcra_rand_samp_elig(get_reg_value(intr_regs, "MMCRA"), 4));

"sample >> 2" doesn't look like a valid token to me.

Regards

David Binderman



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

end of thread, other threads:[~2023-02-28 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-24 14:32 Possible bug in linux-6.2/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_thresh_marked_sample_test.c David Binderman
2023-02-27  5:26 ` Michael Ellerman
2023-02-28 10:06   ` kajoljain

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).