From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9123BC4332F for ; Mon, 6 Nov 2023 16:41:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 05E0441FAB; Mon, 6 Nov 2023 16:41:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 05E0441FAB Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=IPRVuF4l X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gcVAgbvIMBwJ; Mon, 6 Nov 2023 16:41:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id B4D6C41F9F; Mon, 6 Nov 2023 16:40:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B4D6C41F9F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 86751C0039; Mon, 6 Nov 2023 16:40:59 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 178F1C0032 for ; Mon, 6 Nov 2023 16:40:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D2FD041487 for ; Mon, 6 Nov 2023 16:40:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D2FD041487 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=IPRVuF4l X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G0X3pEYq3yd4 for ; Mon, 6 Nov 2023 16:40:56 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by smtp2.osuosl.org (Postfix) with ESMTPS id B074F41453 for ; Mon, 6 Nov 2023 16:40:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B074F41453 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699288855; x=1730824855; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=W6TBX3wq5n6LG78ZXRmLyTkh51LstlH+EyHwK5EG/UU=; b=IPRVuF4lSBU/EodqejFw1cIt6lALlEgmAdvdm+ab9HhXklQuWqHBpF3R L12kgTJW9lfaXAc9XJOU8OruD9HCPyddxCU2Tc03M8rWAG7TCwBMsxyCH WQ6qGa937/HCkFEfQQ7hJCalxcc45HJausSGgkN3ylLhVOrJtRKQHSU1y yxNWIu4LEb6cnGHOQxxPoY2JM0CA0PiguVdMGQA3c7x2iALS7UKeDoA4b rS8i/PJ9yagkwCjECbnhkLTmtvCqr+EPNtM3kJJg6h9kFj4yZ3dVmK82K 4S+u157SqLWH5rtfswGWjkdpO2+eoCMirD8SKdVHqTE+EWtWHyvOS2i8g A==; X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="453620460" X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="453620460" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 08:40:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="10502671" Received: from lpilolli-mobl.ger.corp.intel.com (HELO localhost) ([10.252.36.222]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 08:40:43 -0800 From: Jani Nikula To: Abhinav Singh , alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch Subject: Re: [PATCH] drivers: gpu: Fix warning using plain integer as NULL In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20231103155013.332367-1-singhabhinav9051571833@gmail.com> <87sf5jyvkt.fsf@intel.com> Date: Mon, 06 Nov 2023 18:40:39 +0200 Message-ID: <87h6lyzvg8.fsf@intel.com> MIME-Version: 1.0 Cc: linux-kernel-mentees@lists.linuxfoundation.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org X-BeenThere: linux-kernel-mentees@lists.linuxfoundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-kernel-mentees-bounces@lists.linuxfoundation.org Sender: "Linux-kernel-mentees" On Mon, 06 Nov 2023, Abhinav Singh wrote: > On 11/6/23 16:53, Jani Nikula wrote: >> On Fri, 03 Nov 2023, Abhinav Singh 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 >>> --- >>> 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 _______________________________________________ Linux-kernel-mentees mailing list Linux-kernel-mentees@lists.linuxfoundation.org https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees