Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2430773imd; Sun, 28 Oct 2018 09:52:25 -0700 (PDT) X-Google-Smtp-Source: AJdET5eXaDlGqvjuCGXHAUnKiReNezZE5Jdr7owJSHYv4REOsRnC5QkcxeoslCD1VuRNT0jNUG+b X-Received: by 2002:a17:902:163:: with SMTP id 90-v6mr7885632plb.87.1540745545428; Sun, 28 Oct 2018 09:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540745545; cv=none; d=google.com; s=arc-20160816; b=Ta6j5hBevznjpfyig2Y0eYro05yWWhXkuNWah3uYG7JYds3VF5s0qzh3WaByIPhDvn Cjl66DVYe78aI4IrT+UJ+7/U9sf2XEFP2hPnm8Cbl1UmUEYaxJ96LG5GHKecCy7nxhJ0 0gUXJ12EKaTEeYOmbT9l+6gTbX5pEYdH8MMdXIffqLsSOnOI62PGMYLg3Tt/duZUDiMe X8EfIFa/bLQGD0zeWMWmY4t+aCsnlnfWjbDRp0+PSlIM5RRp6+CWHZRYGLbw+GSYrrY5 Y61aNJqW0GH9khpLNst07jtWP7WuTEYQj2xSjPVYcUlK+Y6djQzdxFlD1KXir091nezC F+bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:dkim-filter; bh=6wTfhA8jd4V+D+sd2TOi97MoDVj3C650L3WDPK86rR8=; b=VbXROAOWYhdPzUqLSOYxrj/+5Vc19mbjyU4CSKFpguwvb2obbuQC6+991hoxymo6Vm apNB9DnIIqNmPFBvjmJrxvzX8lvWI4W3QNThsJMzP2CyMZ3/4MizAxYhbm3vgsFFh81V OF1wGM8b6vQ6wRkcq656WpIJlbSrDS9zxBdTsQEYRQAjTetdADLDLAACNrwPhxt5JWYM 3aJAWne6tAH2AHgTeBAKAFzfCIlBA8tHF73afY4BQlmU6PUlxf2eBpzYenLbzHF77G7d awtQJkTza1DcshcrCDAApPbiMgyXbBtYVCv1axNjKLbgOo2OemxJPM41fA3FriLACqFY m60A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=RqzDupv4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12-v6si15805551pff.192.2018.10.28.09.52.08; Sun, 28 Oct 2018 09:52:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=RqzDupv4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727781AbeJ2BXp (ORCPT + 99 others); Sun, 28 Oct 2018 21:23:45 -0400 Received: from conssluserg-01.nifty.com ([210.131.2.80]:60784 "EHLO conssluserg-01.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726692AbeJ2BXp (ORCPT ); Sun, 28 Oct 2018 21:23:45 -0400 Received: from mail-vs1-f44.google.com (mail-vs1-f44.google.com [209.85.217.44]) (authenticated) by conssluserg-01.nifty.com with ESMTP id w9SGcKii003293; Mon, 29 Oct 2018 01:38:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-01.nifty.com w9SGcKii003293 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1540744701; bh=6wTfhA8jd4V+D+sd2TOi97MoDVj3C650L3WDPK86rR8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RqzDupv4xhqMicdpSwEmD42C0UJmnOSphNHpJQifdHmKXEofq8HSVU19jhFpAS607 YNXHm9C8NTVutslWMKo2AD7iQ1gYmbnuftJH44PXr4crGejcOpF4uyuX/vdSposWfL IAXc4jwADM3jl9OjBZr9QcTCbkwIxK4YAO+1KSOn3cNsBgb4+20DgWT1YgMSIJ6Khl +nrDhYmPuw/Uk9naGUlt4F547Xw5tgD0hagqbQKZF37ydRdqaw8wS8XGwL5wSQWZyx 5tA2fXH3IDtzZS1IKNqtHe8AwTwaTsC3I5pFF1fbR3nl2ZIFImE7jm0kSO3+K52kzq 9XDoMHNvgj/Pw== X-Nifty-SrcIP: [209.85.217.44] Received: by mail-vs1-f44.google.com with SMTP id s9so3387259vsk.7; Sun, 28 Oct 2018 09:38:21 -0700 (PDT) X-Gm-Message-State: AGRZ1gKAUU7mGTsnIz1iVX3gd1RyhO5s6YnEIUrPNDa5i2pXGCvS5vHl 2MXgzeAsrgqHWlq97hdm9ZSPWy7gpxH1fTjVsVk= X-Received: by 2002:a67:385a:: with SMTP id f87mr4732325vsa.179.1540744700386; Sun, 28 Oct 2018 09:38:20 -0700 (PDT) MIME-Version: 1.0 References: <20181023011042.GA6582@WindFlash> In-Reply-To: <20181023011042.GA6582@WindFlash> From: Masahiro Yamada Date: Mon, 29 Oct 2018 01:37:44 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 3/5] Creates macro to avoid variable shadowing To: =?UTF-8?Q?Leonardo_Br=C3=A1s?= Cc: lkcamp@lists.libreplanetbr.org, Borislav Petkov , David.Laight@aculab.com, Andy Lutomirski , Ingo Molnar , helen@koikeco.de, Michal Marek , Linux Kbuild mailing list , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 23, 2018 at 10:11 AM Leonardo Br=C3=A1s w= rote: > > Creates DEF_FIELD_ADDR_VAR as a more generic version of the DEF_FIELD_ADD > macro, allowing usage of a variable name other than the struct element na= me. > Also, sets DEF_FIELD_ADDR as a specific usage of DEF_FILD_ADDR_VAR in whi= ch > the var name is the same as the struct element name. > > Signed-off-by: Leonardo Br=C3=A1s > --- Applied to linux-kbuild. > scripts/mod/file2alias.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > index 7be43697ff84..3015c0bdecb2 100644 > --- a/scripts/mod/file2alias.c > +++ b/scripts/mod/file2alias.c > @@ -95,12 +95,20 @@ extern struct devtable *__start___devtable[], *__stop= ___devtable[]; > */ > #define DEF_FIELD(m, devid, f) \ > typeof(((struct devid *)0)->f) f =3D TO_NATIVE(*(typeof(f) *)((m)= + OFF_##devid##_##f)) > + > +/* Define a variable v that holds the address of field f of struct devid > + * based at address m. Due to the way typeof works, for a field of type > + * T[N] the variable has type T(*)[N], _not_ T*. > + */ > +#define DEF_FIELD_ADDR_VAR(m, devid, f, v) \ > + typeof(((struct devid *)0)->f) *v =3D ((m) + OFF_##devid##_##f) > + > /* Define a variable f that holds the address of field f of struct devid > * based at address m. Due to the way typeof works, for a field of type > * T[N] the variable has type T(*)[N], _not_ T*. > */ > #define DEF_FIELD_ADDR(m, devid, f) \ > - typeof(((struct devid *)0)->f) *f =3D ((m) + OFF_##devid##_##f) > + DEF_FIELD_ADDR_VAR(m, devid, f, f) > > /* Add a table entry. We test function type matches while we're here. *= / > #define ADD_TO_DEVTABLE(device_id, type, function) \ > @@ -641,25 +649,27 @@ static void do_pnp_card_entries(void *symval, unsig= ned long size, > unsigned int i; > > device_id_check(mod->name, "pnp", size, id_size, symval); > + DEF_FIELD_ADDR(symval, pnp_card_device_id, devs); > + typeof(devs) devs_last; > > for (i =3D 0; i < count; i++) { > unsigned int j; > - DEF_FIELD_ADDR(symval + i*id_size, pnp_card_device_id, de= vs); > + devs_last =3D devs + i * id_size; > > for (j =3D 0; j < PNP_MAX_DEVICES; j++) { > - const char *id =3D (char *)(*devs)[j].id; > - int i2, j2; > + const char *id =3D (char *)(*devs_last)[j].id; > + int j2; > int dup =3D 0; > > if (!id[0]) > break; > > /* find duplicate, already added value */ > - for (i2 =3D 0; i2 < i && !dup; i2++) { > - DEF_FIELD_ADDR(symval + i2*id_size, pnp_c= ard_device_id, devs); > + while ((devs_last -=3D id_size) >=3D devs && !dup= ) { > > for (j2 =3D 0; j2 < PNP_MAX_DEVICES; j2++= ) { > - const char *id2 =3D (char *)(*dev= s)[j2].id; > + const char *id2 =3D > + (char *)(*devs_last)[j2].= id; > > if (!id2[0]) > break; > -- > 2.19.1 > --=20 Best Regards Masahiro Yamada