Re: [PATCH] perf tests: evsel-tp-sched: Fix bitwise operator

From: Gustavo A. R. Silva
Date: Mon Jan 28 2019 - 14:29:18 EST


Hi all,

Friendly ping:

Who can take this?

Thanks
--
Gustavo

On 1/23/19 2:40 AM, Gustavo A. R. Silva wrote:
>
>
> On 1/23/19 2:33 AM, Jiri Olsa wrote:
>> On Tue, Jan 22, 2019 at 05:34:39PM -0600, Gustavo A. R. Silva wrote:
>>> Notice that the use of the bitwise OR operator '|' always leads to
>>> true in this particular case, which seems a bit suspicious due to
>>> the context in which this expression is being used.
>>>
>>> Fix this by using bitwise AND operator '&' instead.
>>>
>>> This bug was detected with the help of Coccinelle.
>>>
>>> Fixes: 6a6cd11d4e57 ("perf test: Add test for the sched tracepoint format fields")
>>> Cc: stable@xxxxxxxxxxxxxxx
>>> Signed-off-by: Gustavo A. R. Silva <gustavo@xxxxxxxxxxxxxx>
>>
>> nice catch
>>
>
> Glad to help. :)
>
>> Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>
>>
>
> Thanks
> --
> Gustavo
>
>> thanks,
>> jirka
>>
>>
>>> ---
>>>
>>> NOTE: Notice that this code has been there since 2012. So, it would
>>> be helpful if someone can double-check this. Thanks.
>>>
>>> tools/perf/tests/evsel-tp-sched.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
>>> index 5f8501c68da4..5cbba70bcdd0 100644
>>> --- a/tools/perf/tests/evsel-tp-sched.c
>>> +++ b/tools/perf/tests/evsel-tp-sched.c
>>> @@ -17,7 +17,7 @@ static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name,
>>> return -1;
>>> }
>>>
>>> - is_signed = !!(field->flags | TEP_FIELD_IS_SIGNED);
>>> + is_signed = !!(field->flags & TEP_FIELD_IS_SIGNED);
>>> if (should_be_signed && !is_signed) {
>>> pr_debug("%s: \"%s\" signedness(%d) is wrong, should be %d\n",
>>> evsel->name, name, is_signed, should_be_signed);
>>> --
>>> 2.20.1
>>>