Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2012736rwb; Fri, 2 Dec 2022 04:27:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf5UeH03pqHPESkcTSWjdyStIH1jBIsYQuhWm3QrDCS51Hj74Spe5rRq7meytMK8S5KFq7Ru X-Received: by 2002:a17:906:b108:b0:7b5:dd3e:69c1 with SMTP id u8-20020a170906b10800b007b5dd3e69c1mr44141351ejy.381.1669984044969; Fri, 02 Dec 2022 04:27:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669984044; cv=none; d=google.com; s=arc-20160816; b=m8uz9SDAg5bUfdwN4nH8XTazC0c3GIPcs/VQd28qO/G26EiWeSU+6KmVndwvL25E91 HLJgq5sYY34g0GcWkTogaoSz8A9DPxUSFb/1JSCdGxxin0EL34npshAwLdS87+2HgQei kvtNA8vw/n1tQSbGpOwSDbG4+avfkVw5cgs0oODAbju12KhY7J8wkabeOXSQfTnvW/r4 PIt3EZZ7YTU3uc2dV3gm0C58BoyzUH8p8YjhYicEieh35FleQ1ubZdw7G8o2vESu7eQP w2cjFZahTXiSmt3Rxfge68Sp4FeILfu69U9BIttJdiqsEBCG8EKeb9N3Xji6eouB5us7 aVFQ== 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=KzFIInL8Zjqssldfb8aPgUDvgPWXrGp06cq9AZA2B6o=; b=qPyL08uNp7eVRpMQ4RgRWbam38BYhvM9rlxZ3pyX3nwf9cMz35IxMbc5+BIa+j5VyY oVRufOiTYXqfMzWiZlPmBFFbc/V2ShUivwQBDXiOosDPvx6Yg2n2GE/g94jh/vlP1J5+ luhLLNsHe6gdwqMY1MJSh8Z5x57VJjbeWmGlqccXuSJ7BIya8zM1/Zez6xoKUscQYAs1 G+h1cuY8eT9bcvZIQZHMKzC+VWRLfmY9o0bg5hbmpnEMoxNwdsaDFCOTRaVKEvc0pn+S bVmHAHQK/1I01J+8dh/OKITb3hqIsRLcOrJpc+Pk8s/D8hgqLJ6QN56sVgiEArO9oB8J ZicQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bQYDl6z2; 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 by28-20020a0564021b1c00b0046207099f6bsi5558870edb.613.2022.12.02.04.27.03; Fri, 02 Dec 2022 04:27:24 -0800 (PST) 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=bQYDl6z2; 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 S232955AbiLBMBk (ORCPT + 83 others); Fri, 2 Dec 2022 07:01:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233056AbiLBMBi (ORCPT ); Fri, 2 Dec 2022 07:01:38 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1DCBA5558 for ; Fri, 2 Dec 2022 04:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669982496; x=1701518496; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=d0Yy2s7G/W07LhjNCb4gfDoO61gYuew0wj8EcyOoRX0=; b=bQYDl6z2ai4XG0k/8LNZEDmwPoORexgnQY+lBYZ02k3TassZBUdS2veu 53Bmde1jLzWXl7wgY90NGE//Leeh6RMWGhF5dtplo9X+Ov38+XRWIm7Dz HMvKSRfSqKqCCWELwLovkAm3i3zcgqd/EABUfLxgVVZZ6B72E5UrqdPof 2XtWxGwI0E32y9fcV+g1zA9ka1jhweWEldJ14h5cABzva1jbHdCdHwzOk UI88rnRMC8XbJ56l+oLR2UpveuZd/uAmLYHCI4OPS52RDFfPpt1IV92Lf N1iMgpSEIyKoaD0PA0CGAFmFn2OwxnlnOFoEh2udo5vH2StnNVJn3PPc8 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="378092424" X-IronPort-AV: E=Sophos;i="5.96,212,1665471600"; d="scan'208";a="378092424" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 04:01:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10548"; a="733791614" X-IronPort-AV: E=Sophos;i="5.96,212,1665471600"; d="scan'208";a="733791614" Received: from smile.fi.intel.com ([10.237.72.54]) by FMSMGA003.fm.intel.com with ESMTP; 02 Dec 2022 04:01:34 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1p14jU-003Rzl-1S; Fri, 02 Dec 2022 14:01:32 +0200 Date: Fri, 2 Dec 2022 14:01:31 +0200 From: Andy Shevchenko To: Greg Kroah-Hartman Cc: Sakari Ailus , linux-kernel@vger.kernel.org, Jason Gunthorpe , Matthew Wilcox , "Rafael J. Wysocki" Subject: Re: [PATCH 1/4] container_of: add container_of_const() that preserves const-ness of the pointer Message-ID: References: <20221201193057.1195255-1-gregkh@linuxfoundation.org> 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.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Fri, Dec 02, 2022 at 11:45:55AM +0100, Greg Kroah-Hartman wrote: > On Thu, Dec 01, 2022 at 11:21:50PM +0000, Sakari Ailus wrote: > > On Thu, Dec 01, 2022 at 08:30:54PM +0100, Greg Kroah-Hartman wrote: > > > container_of does not preserve the const-ness of a pointer that is > > > passed into it, which can cause C code that passes in a const pointer to > > > get a pointer back that is not const and then scribble all over the data > > > in it. To prevent this, container_of_const() will preserve the const > > > status of the pointer passed into it using the newly available _Generic() > > > method. > > > > "_const" in the name suggests that the macro would always take a const > > argument. > > I mean it here to be "this will preserve const" as yes, it can take a > const. Or not. > > > Could this be called e.g. container_of_safe() (for type-safe, but > > full type_safe would be a bit long)? > > const is an attribute of type safety, container_of is also type-safe > as-is, it's just the const portion here that is the difference between > the two. container_of_const_safe() :-) > Naming is hard :( True. -- With Best Regards, Andy Shevchenko