Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp687905rdb; Tue, 15 Aug 2023 09:02:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzPTYZ0RGAPcdkTXBmEeYL9CEQkr98STFG89Rh+WFyAxA82m4nrWOhyGZ+DBhcE0kOa7ZF X-Received: by 2002:a05:6a20:8f21:b0:133:71e4:c172 with SMTP id b33-20020a056a208f2100b0013371e4c172mr18699380pzk.15.1692115337829; Tue, 15 Aug 2023 09:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692115337; cv=none; d=google.com; s=arc-20160816; b=gP+IuZeA8Lgbpbt+KhcSf/lyO2ib7cr2eK8HAcLl+MLl9R4tyH9jVdbgrkMZIeQVTJ xtEyh54NQ3guO01Qsa+IZ8v3fOenSAVU3+paJYdeuFPwBtgV3D1jknSIVZXySppkv4vK DeFXHEHvAdJ4VdLUAnCIcFC16kZ3jdZ54VwPWBXmGfRDogPcacIhMTDM7gfmI67/FlH2 LK8PwLaFENL90/wVRj5Fze5hngfbxgzNrq1MIIJJt+3KcEXk+hKGex8l4u2y9ogKBDgz 8v/WzmV9n9dok0LOXzLgJFYiaS6D8vup3LIcQDkiY/4Jvmq7AfVMeCeZotg7totgsYLE jsOA== 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=7XMFXwy28EygZzx1k2ueh/ubfgRGDEd/pLyJPTEj87U=; fh=PSdyraYsZwbTFDTZMpE9guUcxVGXiTYKLpQw6QUk9pY=; b=m/R2+LY1ah4dj8sjF1b+W0aB0xo+GxsYdy0ROfTMNNcmsytE2eZXIdbzG9EXWlVRpj ktWA/tiFra2DBYhN5bbgcgGlZG3wypLBRiRHVWS186BVxgEL7z9kc7vsA2PRIOOiYpSw PoTY/630TehZ+8rOnZ+NRQftpi4D/Q48v0PzCFwvP+TJCy5J9BKCtwJqucfcrz3fVCjj 4VFprwnovggR1jtEN7ayc28vVpGDBroDJ8VZ9BqXNlhxE8+ZrwoU4pq+rCd+3VJTqbmo J5EjGO3e5ihfcPGnIGmIPpsqGg0jWhHz5XDcmswLt20MQ2rLbvXiujy3zj1DlY4Fjt1Y U7jg== 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 i68-20020a639d47000000b0055c8ad484a1si9682798pgd.125.2023.08.15.09.02.03; Tue, 15 Aug 2023 09:02:17 -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 S237916AbjHOPRZ convert rfc822-to-8bit (ORCPT + 99 others); Tue, 15 Aug 2023 11:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238016AbjHOPRU (ORCPT ); Tue, 15 Aug 2023 11:17:20 -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 CC5691BD0 for ; Tue, 15 Aug 2023 08:17:00 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-193-Ping3woFOOOiUUPI28DQrQ-1; Tue, 15 Aug 2023 16:16:29 +0100 X-MC-Unique: Ping3woFOOOiUUPI28DQrQ-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 15 Aug 2023 16:16:26 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Tue, 15 Aug 2023 16:16:26 +0100 From: David Laight To: 'Peter Zijlstra' , Rasmus Villemoes CC: Linus Torvalds , Greg Kroah-Hartman , "dan.j.williams@intel.com" , "linux-kernel@vger.kernel.org" , Nick Desaulniers Subject: RE: cleanup: Make no_free_ptr() __must_check Thread-Topic: cleanup: Make no_free_ptr() __must_check Thread-Index: AQHZz4AGFMD1jvh0k02ojUASiqmepq/rdtJA Date: Tue, 15 Aug 2023 15:16:26 +0000 Message-ID: <4ff59df127e24b83a7c3c9d9aba17857@AcuMS.aculab.com> References: <20230815105204.GA927051@hirez.programming.kicks-ass.net> <20230815135339.GA966323@hirez.programming.kicks-ass.net> In-Reply-To: <20230815135339.GA966323@hirez.programming.kicks-ass.net> 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,PDS_BAD_THREAD_QP_64, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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: Peter Zijlstra > Sent: 15 August 2023 14:54 ... > > Also, isn't it more complicated than necessary? Can we get rid of the > > inner stmt expr and tmp var by just making it > > > > ((void) (p), ((typeof(p))__no_free_ptr((void **)&(p))) > > > > which is more or less the whole reason comma expressions is a thing. > > Ah, so the point of the statement expression before the comma is to > validate that (p) is in fact a pointer, and to that effect we assign it > to a 'void *' temporary. > > If that case is invalid, we'll get a compile fail with a dodgy message. > > I did this, because (void **)&(p) looses type integrity due to the cast. > > But yeah, I suppose it all needs a wee comment. Perhaps add an is_pointer_type() along with is_signed_type() (and really is_constexpr()) to a global header. Various checks can be used including: #define is_pointer_type(t) (!is_constexpr((t)0)) which gives a 0/1 to play with rather than an immediate error. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)