lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87h6lyzvg8.fsf@intel.com>
Date:   Mon, 06 Nov 2023 18:40:39 +0200
From:   Jani Nikula <jani.nikula@...ux.intel.com>
To:     Abhinav Singh <singhabhinav9051571833@...il.com>,
        alexander.deucher@....com, christian.koenig@....com,
        Xinhui.Pan@....com, airlied@...il.com, daniel@...ll.ch
Cc:     linux-kernel-mentees@...ts.linuxfoundation.org,
        dri-devel@...ts.freedesktop.org, amd-gfx@...ts.freedesktop.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers: gpu: Fix warning using plain integer as NULL

On Mon, 06 Nov 2023, Abhinav Singh <singhabhinav9051571833@...il.com> wrote:
> On 11/6/23 16:53, Jani Nikula wrote:
>> On Fri, 03 Nov 2023, Abhinav Singh <singhabhinav9051571833@...il.com> wrote:
>>> sparse static analysis tools generate a warning with this message
>>> "Using plain integer as NULL pointer". In this case this warning is
>>> being shown because we are trying to intialize a pointer to NULL using
>>> integer value 0.
>>>
>>> Signed-off-by: Abhinav Singh <singhabhinav9051571833@...il.com>
>>> ---
>>>   drivers/gpu/drm/radeon/clearstate_evergreen.h | 8 ++++----
>>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/radeon/clearstate_evergreen.h b/drivers/gpu/drm/radeon/clearstate_evergreen.h
>>> index 63a1ffbb3ced..3b645558f133 100644
>>> --- a/drivers/gpu/drm/radeon/clearstate_evergreen.h
>>> +++ b/drivers/gpu/drm/radeon/clearstate_evergreen.h
>>> @@ -1049,7 +1049,7 @@ static const struct cs_extent_def SECT_CONTEXT_defs[] =
>>>       {SECT_CONTEXT_def_5, 0x0000a29e, 5 },
>>>       {SECT_CONTEXT_def_6, 0x0000a2a5, 56 },
>>>       {SECT_CONTEXT_def_7, 0x0000a2de, 290 },
>>> -    { 0, 0, 0 }
>>> +    { NULL, 0, 0 }
>> 
>> Random drive-by comment:
>> 
>> I'd just use {} as the sentinel.
>> 
>> BR,
>> Jani.
>> 
>>>   };
>>>   static const u32 SECT_CLEAR_def_1[] =
>>>   {
>>> @@ -1060,7 +1060,7 @@ static const u32 SECT_CLEAR_def_1[] =
>>>   static const struct cs_extent_def SECT_CLEAR_defs[] =
>>>   {
>>>       {SECT_CLEAR_def_1, 0x0000ffc0, 3 },
>>> -    { 0, 0, 0 }
>>> +    { NULL, 0, 0 }
>>>   };
>>>   static const u32 SECT_CTRLCONST_def_1[] =
>>>   {
>>> @@ -1070,11 +1070,11 @@ static const u32 SECT_CTRLCONST_def_1[] =
>>>   static const struct cs_extent_def SECT_CTRLCONST_defs[] =
>>>   {
>>>       {SECT_CTRLCONST_def_1, 0x0000f3fc, 2 },
>>> -    { 0, 0, 0 }
>>> +    { NULL, 0, 0 }
>>>   };
>>>   static const struct cs_section_def evergreen_cs_data[] = {
>>>       { SECT_CONTEXT_defs, SECT_CONTEXT },
>>>       { SECT_CLEAR_defs, SECT_CLEAR },
>>>       { SECT_CTRLCONST_defs, SECT_CTRLCONST },
>>> -    { 0, SECT_NONE }
>>> +    { NULL, SECT_NONE }
>>>   };
>>> --
>>> 2.39.2
>>>
>> 
> Hi, Thanks for dropping by and the suggestion. I thought of using NULL 
> instead of {} is because, first the warning itself says that 0 is used 
> to intialize pointers with NULL, and second due this link 
> https://www.spinics.net/lists/linux-sparse/msg10066.html where linus is 
> talking about not using 0 NULL intialization of pointer variable and he 
> thinks this is a legitimate issue and not some false positive

But... {} is neither of those things. It's empty initialization instead
of 0. It's valid in GCC and C23, and used all over the place in the
kernel.

BR,
Jani.



-- 
Jani Nikula, Intel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ