Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1109111rdb; Fri, 1 Dec 2023 07:18:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4yni5vjAZudFM1Sk8fGvCXNEB+RbrC8Xt5PqZIkGKggYH+5p0Qrmdoo+4h1j+Kxax1uIQ X-Received: by 2002:a05:6a00:21c7:b0:68a:3ba3:e249 with SMTP id t7-20020a056a0021c700b0068a3ba3e249mr30958734pfj.16.1701443924143; Fri, 01 Dec 2023 07:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701443924; cv=none; d=google.com; s=arc-20160816; b=allQAiIVM6Xi6R/JMYxapIESaIF33wMN28qkpBu02QpGW/ROs0GRwUJmELn9bQSudY lLHclKxUuGT0FBQzaIahGH9kmUh6hugce5BU3lgpfM5DeZS5i08CCusF5jPbUq7txh+/ XAGPHMcq9ATed9YDwi0+aFPDKrV6NRuFgrnkW6YSVDsBcr9Re2OzGSEtg262h7+lHlIY e9vlCn7m+f/os7YSpntVeg/TCBqFQ9GV1affE15rldz0xHi2kTQFPhG0XKJg7nlcYJBA 0V1s+K+m1hWg9BfPbgatNsPNFrozC8aYTPGs/5De7h32jnM0nSAMSL0HtBS90G6Hgm0B TPyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wQO+IBEERJCQEuviyF1pS8HbTjU0dCxAuJRxws1CcU4=; fh=7fm2uWp79Fu/AWz0cXu/De1rJKUQWVX11fC0YFOeZsY=; b=InAmykVx8EHDoxepinyCJww9lsZyZfeaAP2+E9AnBlVg1KPp5xu2Vs7ACk7NVpkua9 4j9OLv8NFX/cqYiclbjgo8yHxgFT+xHx46PS+IsYnBzYKrwarHkFTtQ7uXlg8hfoT6/U XJanVEdRb5gnlbHF22u40tzQxzr7k7M3csMIAJZ0cRP7qONqd3gV8/KHkVZhOSxqesXM BrjejzV7L3CZfQG9WtTSG0p4MCNDSkjw6eyJeFEbL1isn5K2oQHc1koUBQMM3R7FlfVi +RkcTPdBYgUKOW1euMONY0o9wHToNSlaE3bd9Kz+No8kcA1Im0bnc5ooZVFtgFZex3F0 IbcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BSk1eTp8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id d15-20020a056a00198f00b006cb997ac3eesi3512935pfl.290.2023.12.01.07.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 07:18:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BSk1eTp8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 5FA4F84AB80C; Fri, 1 Dec 2023 07:18:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379420AbjLAPSF (ORCPT + 99 others); Fri, 1 Dec 2023 10:18:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379475AbjLAPRt (ORCPT ); Fri, 1 Dec 2023 10:17:49 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52F2C1726; Fri, 1 Dec 2023 07:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701443862; x=1732979862; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=wYPSx9+wbY4jC6jNQkQIxE7XoYAMfQUsgyw8T5lmYsg=; b=BSk1eTp8KH6vv/xHR/hqBvxjsmTmsyXdzRXG1Wo/L7e7G5SfwQylPMG+ YkXtbigEZsO5w1S2iweiDGXZE3iSHwiy2hGcke9MzRQ/Wf7+7RbPJQ0yB d5mUl2JYLwlSiJrwkHCENgayWrszw5EjLyyMilpOztM5ZkiPV97WaZgEB gc1xMQicCyPCHH5B7GT7jFQ5weEzDjCf6ukWsA9WbX9GbpQp1Sn42gvk5 4GkvCDs2urtN9tMD9T1hSlgCLTLIcZiQkznmc4o0i9HFLq0MGqG2C3/Kv uxzckUkozpf2PnDJddt/I/gU8IcgbWVvio6fga4qiMB/dCuJZVeDyDUHJ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="362668" X-IronPort-AV: E=Sophos;i="6.04,241,1695711600"; d="scan'208";a="362668" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2023 07:17:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10911"; a="763178004" X-IronPort-AV: E=Sophos;i="6.04,241,1695711600"; d="scan'208";a="763178004" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orsmga007.jf.intel.com with SMTP; 01 Dec 2023 07:17:36 -0800 Received: by stinkbox (sSMTP sendmail emulation); Fri, 01 Dec 2023 17:17:35 +0200 Date: Fri, 1 Dec 2023 17:17:35 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Pekka Paalanen Cc: Jernej Skrabec , Emma Anholt , Jonathan Corbet , dri-devel@lists.freedesktop.org, Samuel Holland , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Sandy Huang , Hans Verkuil , linux-rockchip@lists.infradead.org, Chen-Yu Tsai , Maxime Ripard , Thomas Zimmermann , linux-sunxi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Subject: Re: [PATCH v4 05/45] drm/connector: Check drm_connector_init pointers arguments Message-ID: References: <20231128-kms-hdmi-connector-state-v4-0-c7602158306e@kernel.org> <20231128-kms-hdmi-connector-state-v4-5-c7602158306e@kernel.org> <87h6l66nth.fsf@intel.com> <20231129121259.47746996@eldfell> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Patchwork-Hint: comment 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 pete.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 (pete.vger.email [0.0.0.0]); Fri, 01 Dec 2023 07:18:31 -0800 (PST) On Wed, Nov 29, 2023 at 12:25:37PM +0200, Ville Syrj?l? wrote: > On Wed, Nov 29, 2023 at 12:12:59PM +0200, Pekka Paalanen wrote: > > On Tue, 28 Nov 2023 15:49:08 +0200 > > Ville Syrj?l? wrote: > > > > > Should we perhaps start to use the (arguably hideous) > > > - void f(struct foo *bar) > > > + void f(struct foo bar[static 1]) > > > syntax to tell the compiler we don't accept NULL pointers? > > > > > > Hmm. Apparently that has the same problem as using any > > > other kind of array syntax in the prototype. That is, > > > the compiler demands to know the definition of 'struct foo' > > > even though we're passing in effectively a pointer. Sigh. > > > > > > __attribute__((nonnull)) ? > > I guess that would work, though the syntax is horrible when > you need to flag specific arguments. I played around with this a bit (blindly cocci'd tons of drm and i915 function declarations with the nonnull attribute) and it's somewhat underwhelming unfortunately. It will trip only if the compiler is 100% sure you're passing in a NULL. There is no way to eg. tell the compiler that a function can return a NULL and thus anything coming from it should be checked by the caller before passing it on to something with the nonnull attribute. And I suppose error pointers would also screw that idea over anyway. Additionally the NULL device checks being being done in the drm_err/dbg macros trip this up left right and center. And hiding that check inside a function (instead of having it in the macro) is also ruined by the fact that we apparently pass different types of pointers to these macros :( Generics could be used to sort out that type mess I suppose, or the code that passes the wrong type (DSI code at least) should just be changed to not do that. But not sure if there's enough benefit to warrant the work. -- Ville Syrj?l? Intel