Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2251034rdf; Mon, 6 Nov 2023 08:41:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDmHrWyTxwOQcfb2GEQGuR4meRyPO2LGL6M6lWZiFk/x1s8PfZEC2R3qjCxiznTiVfhqGf X-Received: by 2002:a05:6a00:21c9:b0:68a:4103:9938 with SMTP id t9-20020a056a0021c900b0068a41039938mr26662605pfj.0.1699288882223; Mon, 06 Nov 2023 08:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699288882; cv=none; d=google.com; s=arc-20160816; b=PlL7jCP9tD0KxdJpuycg2trU/3NNyPL9JnHPLQ49LO7nsfYjaLAKM0jVbi971lxeZ2 DIYLJmwwDG3eovzQawnRSLq/g54JAim9vSlIsnjtH5HpH32DrFgVbmP1HV3JZvFpaCRU VFadcGhLxQWZhoEHOWseG3nW021eDq/3LLdkEVGPwtm6TWU6bkp8rKFUt+Gax1gGb2zN Y4dFtuQbfgb9NkMNB/qbMBgCp1Ysp5HYreuhvjxfi8RF4csc0+RqaSjgEE48CG59VAZU HfUhMp582Lme7uChLc+00SMKXGf/b+U8H8XbuscgukFiYFYp98xlT2nL6675ZxLslZCB rj4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=BD3RoN/dxrn87wma+BHBsW0e2Jvw+0WGYcZE4R+x++c=; fh=I8vrFns1+k4I+ZhO/sCsRv5D3F2TeY2ThYGA5z2Tebk=; b=RW8oClMOvNUCmJUBGIj5Mj8fP1nFbKqi1LuZ5LpbUdaORdOSv2HT1ds8vZsBPHmbo6 vfgr/eAEUvDl+2rOoAG5MFC9GOJdNtcHQMnc77s32VP1o8/KcOJxtNQJZkBuMgh283ay XN7G+vYaPz51BiE6apIkxTpJ4mIVw6FJvhhSkz8mFEUBHHsTq9sqh4mRLyLKiMLueFaQ n/nPMS+YQZ103dv0fSJRJuOF04Ym3FJAZFadGDe6R4m3b/U/mqGthIi0ps833MweE7OV B88kfEIBbP2bV9IfdHj163eTeleR3dqCZEEm19fhrJAhzDNp7eux4osZvYFn6MTCZPKT 2ZPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IPRVuF4l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id u13-20020a056a00158d00b0068e4c3f3ac2si8328132pfk.245.2023.11.06.08.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 08:41:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IPRVuF4l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CCFBC80617C7; Mon, 6 Nov 2023 08:41:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232882AbjKFQlJ (ORCPT + 99 others); Mon, 6 Nov 2023 11:41:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232912AbjKFQlD (ORCPT ); Mon, 6 Nov 2023 11:41:03 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C012C10FD for ; Mon, 6 Nov 2023 08:40:55 -0800 (PST) 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="453620461" X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="453620461" 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 Cc: linux-kernel-mentees@lists.linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org 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 Content-Type: text/plain X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 08:41:19 -0800 (PST) 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