Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6605916rwi; Mon, 24 Oct 2022 03:55:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4UnkDus1saLIlw96ANApIZF7CygT+h3cl8lNw6fSVYr/qCFNYE1aMtwA45lz1IEn3Q1L5v X-Received: by 2002:a05:6402:35cc:b0:45d:4a39:2a43 with SMTP id z12-20020a05640235cc00b0045d4a392a43mr30401450edc.304.1666608910109; Mon, 24 Oct 2022 03:55:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666608910; cv=none; d=google.com; s=arc-20160816; b=RNVBDhm7UcwQMQCaKC/axZcNPGQCV4tR7J0UljcI7d5QfqYCRP8HyQfWRmo5DpaZ8W k8CMBVI5mhkMu9b96QDrrQ9KDzFgWlN1CbtQJya3UaWdCu8CPMe/X4z6Ys97GP1oXqah eX+bAWxu1oloaFRwVbtCiHwZzp3hOC+lNlaoz0tL18csdX7coTmF8BiMDIu91qC9POkz yIy24I0LyZ9EP0FBUS2bnN0ppbyA31IKASb+wbh5FrzIvB7zjUfyRa5t6WvJTH08IjlY bm+XYopuJJ5YVSxKN2hRVfGc1ngB7KPGqT+j5L3usGonntgUtofrRROQeilpVyIfeg8Z Mmfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=zzscwkryF+PMwsP4sBPpMpihEWVPi2dhjkEHtKcak00=; b=wExkgJAA49Ga5Mq3YeFR89GaBYkcNgIVmVfjC4nGhJWE0ankBcfBxwG5/N7DfGoVzQ rFdxfTGjZsANyq3QV6ayeAD6GgQXRayDGd4jc2EWsohk8GZT8SPj+REppqfky+m8EWht TXFvguIp+ESJQwGV6BbdGOex/pibHJD0U5P0H+N5F0QDbA5DcrHrI6gWO1Tj6T/QRB/b 9QQNBsuG0sNq0m3ZkWNrMlgLxmh4AxDJ0/GcObNKa/1eMZEBspRXsp/FsZ1YBegPcewF 4qjmnMA0s5vUt/QUD7fhdfODcipqKGsaWc0N09Fq5+7OgqKNKNpgnxjR4VVA/REi4nds yoCA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm12-20020a170907948c00b00791a3dd01b6si16252419ejc.864.2022.10.24.03.54.44; Mon, 24 Oct 2022 03:55:10 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbiJXJex convert rfc822-to-8bit (ORCPT + 99 others); Mon, 24 Oct 2022 05:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230177AbiJXJev (ORCPT ); Mon, 24 Oct 2022 05:34:51 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69CA3E019 for ; Mon, 24 Oct 2022 02:34:47 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-265-wp9O9KnaPFS-OBtI_B4QqQ-1; Mon, 24 Oct 2022 10:34:44 +0100 X-MC-Unique: wp9O9KnaPFS-OBtI_B4QqQ-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 24 Oct 2022 10:34:42 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.042; Mon, 24 Oct 2022 10:34:42 +0100 From: David Laight To: 'Andy Shevchenko' , Sakari Ailus CC: 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 Thread-Topic: [PATCH 1/1] linux/container_of.h: Warn about loss of constness Thread-Index: AQHY54ozH4qdMwC1Yk+S6+0KOnujn64dR6XQ Date: Mon, 24 Oct 2022 09:34:42 +0000 Message-ID: References: <20221024082610.74990-1-sakari.ailus@linux.intel.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)