From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A31ACC3DA6E for ; Fri, 16 Dec 2022 23:15:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbiLPXPV (ORCPT ); Fri, 16 Dec 2022 18:15:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbiLPXPR (ORCPT ); Fri, 16 Dec 2022 18:15:17 -0500 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4451563A1; Fri, 16 Dec 2022 15:15:15 -0800 (PST) Received: by mail-wm1-f42.google.com with SMTP id o5-20020a05600c510500b003d21f02fbaaso5104181wms.4; Fri, 16 Dec 2022 15:15:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pBsUm8iDTB+c2THpWnNDO3v6zfDYGcvFBEzQEwB5p+Q=; b=2TDXOIWSJhk3wAeCu4qMaFNwMz6v+33DlY4AlnalYCk3TUHKjcvD1w2te8BZOyg1X0 xMwXLHHwpJjpBf01A+wY3kZO8S1TUZbHhFLxW1pyAwmHOZTrga2erJyTzpforX2RLkqS zOgKCZOECUPtpPotXVJr9Qgkg97RmOz9yoKZpbxRrM05C1ZLOpBtY7KHZAd0pQotKsEr fHJddQnDQa6/yTvLqmqmc08Crun0M8At8GKj3PFw2ZGc6S0wTpd/8bwV/x/mcuAzp4J8 ZKW7fBrv3hppw0vWObrATQo2pX4SPKcYNtNGGsVym5NYNVcx3jCyhq59IurgK+/0oJD0 ZazA== X-Gm-Message-State: ANoB5pmh5Wn7xypf4e7brTxCqHZSTlbrUXiAHNYUkls65E2UUPzELYRH GkzGKDxVgQ4m3nSjz/3zarAW24zrHHY= X-Google-Smtp-Source: AA0mqf69VdlADAtAcOu7aIwHaTjSRlqjYaHbBCGX0RiV1+qcxsWc0R71WoRsYxrexyS40+lyu23dKA== X-Received: by 2002:a05:600c:21c1:b0:3cf:8833:1841 with SMTP id x1-20020a05600c21c100b003cf88331841mr26926497wmj.39.1671232513890; Fri, 16 Dec 2022 15:15:13 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id x33-20020a05600c18a100b003d1cc0464a2sm3681803wmp.8.2022.12.16.15.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 15:15:13 -0800 (PST) Date: Fri, 16 Dec 2022 23:15:11 +0000 From: Wei Liu To: Wedson Almeida Filho Cc: Wei Liu , rust-for-linux@vger.kernel.org, Linux Kernel List , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron Subject: Re: [PATCH] rust: kernel: drop repetition in offset_of macro Message-ID: References: <20221216174927.1008629-1-wei.liu@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: rust-for-linux@vger.kernel.org On Fri, Dec 16, 2022 at 06:26:57PM +0000, Wedson Almeida Filho wrote: > On Fri, 16 Dec 2022 at 17:49, Wei Liu wrote: > > > > It doesn't make sense to allow multiple fields to be specified in > > offset_of. > > Why do you say it doesn't make sense? > > Here's what I had in mind: > ``` > struct Y { > z: u32 > } > struct X { > y: Y > } > offset_of!(X, y.z) > ``` > > Which is something very plausible. > > > No functional change. > > > > Signed-off-by: Wei Liu > > --- > > Cc: Miguel Ojeda > > Cc: Alex Gaynor > > Cc: Wedson Almeida Filho > > Cc: Boqun Feng > > Cc: Gary Guo > > Cc: Björn Roy Baron > > --- > > rust/kernel/lib.rs | 10 ++++++---- > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs > > index 6a322effa60c..2f3601e4e27e 100644 > > --- a/rust/kernel/lib.rs > > +++ b/rust/kernel/lib.rs > > @@ -208,7 +208,7 @@ impl<'a> Drop for KParamGuard<'a> { > > /// ``` > > #[macro_export] > > macro_rules! offset_of { > > - ($type:ty, $($f:tt)*) => {{ Shouldn't this be + instead of *? offset_of!(X,) is valid according to this pattern. Thanks, Wei.