Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6574548rwi; Mon, 24 Oct 2022 03:22:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4RG1PSc/Dl8Nh2htJ94qUVORKKeUAAH1AFrj0Js2cc4zgeDMl52Ec4m9/N1hXEXSxd1+JA X-Received: by 2002:a17:90b:3b43:b0:211:2d33:685d with SMTP id ot3-20020a17090b3b4300b002112d33685dmr26570181pjb.93.1666606951884; Mon, 24 Oct 2022 03:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666606951; cv=none; d=google.com; s=arc-20160816; b=INL+LllK0dOZvU9mqgY+hFr3OHRtoYdyP/6XwiGaqCeIskFKAcuQ6Chaxm61DpGgqj HFGGNiB8HeffDHZfv0R4mbrt8LKM9T/VJgURDoPPWOonjF64BfZvJ/auUxKSQdWixFPA JWn84qZpF8uCz5qWw3ks6Lk6qYfmu4wIv2+eEKfdkOLPNGoAbJgezRxRc1CA3/ft3Dyt oQC/uaUhgrx21stdlDWKWh8540eCccxUl86nScTAYkAARivCKcjUamIu7RY45l3W3A4R LKGI9zCEDVK4Cmi0ZN3mjgMTT0uyCsDIbnIOAY+dzx3+USZMjwYAkC1zsH56Mh+jbjl1 66uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ekNGpUlZhiH3lfLe/lYmf3gUE5233rBEbQ17mUlXuKc=; b=L0MkE7uA3TguTDFjgFoDdb/oDiOIE1gNgTP68zZ+mu76HpbowlvO8Aiux39QVFs/nn h1z+OKkLh9GO78/sFyyC6WvgZhRPvODpfzq/CL+8hjMvFfx+yDSOGUZx3YCAoMDRiyJS JoQeT53B4i5MGZ2s4yxxj6yjEb0oyttxqoKT78K15dHEGzSmBF4ITzzMMUb7GrtU3O4p Ofz+mSJ89z1+N17QUsE7a0rNxR2RVzpPnvOnlgsM6GhatYfuS4tZUJWeckuoI4ZeUJ6/ 49e+MQksf59jx6xZZCrDFq69zChMA6rcMBvL4ne/4V6WBwWAuq7X5uv2CnJ8JflTNtno pqKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cAZI+4F0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a170902f79000b00186a8bd137fsi3094414pln.453.2022.10.24.03.22.19; Mon, 24 Oct 2022 03:22:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cAZI+4F0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229906AbiJXJhT (ORCPT + 99 others); Mon, 24 Oct 2022 05:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbiJXJhS (ORCPT ); Mon, 24 Oct 2022 05:37:18 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA17546626 for ; Mon, 24 Oct 2022 02:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666604237; x=1698140237; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=a0MpMGFGpNDYiu9v5+FtkANV82sv0av8n2hfg3WgwSc=; b=cAZI+4F0yzfrqSLSn/U3bPIdC+Iy1IDgxoG3UJrctg7uEMbOm9pZX78R iO51n3Ctj2ykuZJO9daBUp2ULGRWuYzBXM32xYwLeGkzgd/ojMx65ByYA uBGZ+LnlM9v8NZmn2qUVUEPlaIz4yFN484qDjI2kD5XsA/7GFfpX7xD2T ubygLT4yuOwjQikMw0gRxn8WB61Fdyt3bvzLRoWKq6sTid82tON200CIf Z9oY3q5BIcxAgqueTSgl2Iyux21mAneR0jvkSwWl0iBiIGv61+AWsXnVO mql3duAToDNpqNaEe9MrRO3GMXx7uCwDqXfBnGI85C8HlvGkRynHySDOt g==; X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="294776855" X-IronPort-AV: E=Sophos;i="5.95,207,1661842800"; d="scan'208";a="294776855" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2022 02:37:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10509"; a="960362442" X-IronPort-AV: E=Sophos;i="5.95,207,1661842800"; d="scan'208";a="960362442" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga005.fm.intel.com with ESMTP; 24 Oct 2022 02:37:14 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1omttR-001N5H-0U; Mon, 24 Oct 2022 12:37:13 +0300 Date: Mon, 24 Oct 2022 12:37:12 +0300 From: 'Andy Shevchenko' To: David Laight Cc: Sakari Ailus , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" , "Rafael J. Wysocki" Subject: Re: [PATCH 1/1] linux/container_of.h: Warn about loss of constness Message-ID: References: <20221024082610.74990-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 24, 2022 at 09:34:42AM +0000, David Laight wrote: > From: Andy Shevchenko > > Sent: 24 October 2022 10:23 ... > > > > Wait, no one uses this macro, so why not just remove it entirely? > > > > > > Good question. It appears to be a (relatively) common pattern to look up > > > something and the return its containing object if the lookup was > > > successful. Doing a quick > > > > > > $ git grep 'container_of.*:' drivers include > > > > > > reveals more than 20 instances of the pattern. There are probably more > > > those that use if for testing for NULL. I guess people don't know about > > > this macro, apart from the developers of the staging driver it was added > > > for (commit 05e6557b8ed833546ee2b66ce6b58fecf09f439e). > > > > Maybe we can provide an example to keep this macro in the kernel, meaning > > convert one of the drivers / subsystem to actually use it? > > Adding _safe() to a function name doesn't actually tell you anything. > You still need to look up what it is 'safe' against. > > In this case the full code pattern is actually much clearer. > > It is also quite likely that it is followed by an: > if (!ptr) > return xxx; > You that can/should really be put before the container_of() call. return statements in macros are no go. Or you meant something else? -- With Best Regards, Andy Shevchenko