Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp77157pxp; Thu, 10 Mar 2022 23:02:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzeD2SUlyoWiZBNlb4oTsxgoTGpkAWJbLBVk/EZ5qGK2DPM/oikOeuSwiS+JCVbd7g9EnB X-Received: by 2002:a05:6a00:1687:b0:4e1:45d:3ded with SMTP id k7-20020a056a00168700b004e1045d3dedmr8696677pfc.0.1646982157187; Thu, 10 Mar 2022 23:02:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646982157; cv=none; d=google.com; s=arc-20160816; b=m4EhW5+/bHPUP7YnGxzx/eB87dVy9e175AGms7nC7We+6n0I0ArC/Shk7W2BP3L8WH TxzK2wLaagV1EsMU+eitlG3iI6NbeCnYXc9YeSTE6asLDPQRFWeuCfUEw2R31H04CNUS Ywlo5b6gJKG4zl9wDsyiXkCSHpbiqOpqNPx0S8rxgGlGfZ6ggRbho7EvCQNwQcc2rnm5 QUxZk4owkPDqyDROFmDaF4fOsA/sJS6eo2L+lQlu5iBX07IM1u9Rtx4xudjo0RZY7T1W 1Dx2O+6b4C768H8BXB9uAw4Nh57wIb1ucb16g6KoaV3NzqeRokn01JUcB734ujjim3zj 6mSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=580k28RZJWmruhyNLJaUIw7q1yifrWd4WqcSy+ybKWo=; b=NsBIcFcGio5iC4fdY0Hj8m7OqCrV5bjAvdpDG3xQvKscTF0cjfz8xXaXudmss6kyPg pksu+YnDOo8nTBR9q6EuFUmlwIUdWvfHfBnC/ez5yOWEmYG2pKXZLoxJSRzp5tgo9/4M j1jjPMt76nGoeg6CRBFQUwFsV5aBzgak3zGstUhRNPh/qrwE9W1wGbP2WnXf7cmANRDb VWENF2Rrge/6K6NcR9L/rsCxbG/9nbNTqrsHV14DkGGU/vrxHxa21yIsOsYa2//Amqgw HTb1F4SeohvK3zvD+MxeGh0cnPN/2dhhtYpG33Xt/fV1cE7Lqz8mbDzuXLHFEnd2jUMx pkTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=ZF8FYbbF; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a63e449000000b00373aa082ca2si7074483pgk.189.2022.03.10.23.02.01; Thu, 10 Mar 2022 23:02:37 -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=@protonmail.com header.s=protonmail3 header.b=ZF8FYbbF; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345657AbiCKCut (ORCPT + 99 others); Thu, 10 Mar 2022 21:50:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233034AbiCKCur (ORCPT ); Thu, 10 Mar 2022 21:50:47 -0500 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C08A91A274F for ; Thu, 10 Mar 2022 18:49:45 -0800 (PST) Date: Fri, 11 Mar 2022 02:49:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1646966983; bh=580k28RZJWmruhyNLJaUIw7q1yifrWd4WqcSy+ybKWo=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID; b=ZF8FYbbFpCzxGnaB7xZpON8TRl6aEG9ZJXzgjVQdF/0AaUKypfyo2r6NOf41G4VPX chPLti/RlDcF1XukztOtMmYbSMzy2dM2xXq38Iw3rFe55l1RTmuXP6it83vOPb5MOH qJajJIRq0AK+ZgZ+PaTlV17YnB5UTh7oYgF04Ru733MZqiTbAK4q4dDtWDCaV0xy6a urzqvoUKEuOmAW97BV0uRrETdfOnY1jZf2HJOej5uu6/v8kLzs0rtTIFJwNtarMZGj Dbkgrn4ScnkWOWLDdu9aM1S+eC4v5ossq5QL/ensZaLjBXuMelyytpe7kva6H3dqwr dsDmBshLVTHMw== To: Linus Torvalds From: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: Linux Kernel Mailing List , Greg Kroah-Hartman , Andrew Morton , Xiaomeng Tong , Kees Cook , Jakob Koschel , Arnd Bergmann Reply-To: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Subject: Re: [RFC PATCH v1 1/2] list: add type-safer list_head wrapper Message-ID: In-Reply-To: References: <20220311013238.3387227-1-pobrn@protonmail.com> <20220311013238.3387227-2-pobrn@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi 2022. m=C3=A1rcius 11., p=C3=A9ntek 3:01 keltez=C3=A9ssel, Linus Torvalds = =C3=ADrta: > On Thu, Mar 10, 2022 at 5:42 PM Linus Torvalds > wrote: > > > > That one didn't do the automatic offset thing, but see > > > > https://lore.kernel.org/all/CAADWXX-Pr-D3wSr5wsqTEOBSJzB9k7bSH+7hnCA= j0AeL0=3DU4mg@mail.gmail.com/ > > > > on the problems that has. > > Note: I think the problems are serious enough that it almost certainly > isn't worth doing - it makes the code uglier for very little upside. > > So I tried to explain how it _could_ be done, but that doesn't mean > that it _should_ be done. > > Having the member name as part of the list traversal macro isn't > actually generally a real problem. > > I added it to the list_traversal_head() macro in that original patch > because I think we can easily use the member head name to _verify_ > that the declaration and the use match. > > Yes, squirrelling off the offset and not needing the member head name > at all at when traversing the list is obviously simpler syntax, but > that part has never been the real problem with list traversal. And > verifying that the member name that is passed in is the same as in the > list_traversal_head() would be trivial. > > To verify it, we could simply change that type name from: > > type *name##_traversal_type; > > to be > > type *name##_traversal_type_##member; > > instead, and suddenly the member name in 'list_traverse()' has to > match that thing that list_traversal_head() created. > > So yes, you'd have that third argument in list_traverse(), but it > would be trivially checked at compile-time. That is indeed a simpler thing to do, and doesn't need `offsetof()` at the declaration, but there are places - not many - where the `list_head` membe= r is inside a subobject, for example, so `member` now contains a period. > > And you'd avoid all the ugly complexities (described above) with lists > that are embedded inside data structures that refer to each other) Regards, Barnab=C3=A1s P=C5=91cze