Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4071388imd; Mon, 29 Oct 2018 17:34:20 -0700 (PDT) X-Google-Smtp-Source: AJdET5dIRXQleUi2SloXcLM3YWIHwOOI1nuJJYi7xfqAJ2kcduIGkWBfwReKRAtE/uaEmLwMf1mJ X-Received: by 2002:a17:902:9047:: with SMTP id w7-v6mr16405275plz.4.1540859660561; Mon, 29 Oct 2018 17:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540859660; cv=none; d=google.com; s=arc-20160816; b=imkTQv+Rne/2HiKfiB322/mlMave9XeNDXNnRIcgp/EU+TgALZo2YYpg+JNeeCSrTw JSqNZHrsnfvZryay9KW4MiaNB68XinOVqNamU2d6TRuc2+rjn+sBBhGn1bFGfAIzklGT Hc6/zSjnBpIAjeZB9A5kF7B6E9rCH4+/cbzD9dYYb04TO159GLX3zWh0KAz14xYOVfY8 f0isNJZVEKrUOsvShugSaJ9CDOxvTMX4YHJyyzDU+e5/o3LHLFvoX+oKWXPd/lt7Xet6 giHna7Gu9UsaXRGDCxUBfELD0mZLUySP7GH6CfTBXlgW5O4mXTZhByBQ/N+MixDp4O8L 9cdA== 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; bh=2JkJKlN+UGaVyqKcPlrnc3ALtjUNlaFk4LeAqM69eqI=; b=GW+vZbgi4iXOCu09iooEL1GgRDpROl32WOvtqAyc6zkPgBKb07Igu9LgFT95BeBdX0 DK9x/bn2oUNFnzmzF1ml/A0uOWatrVttyb8qIXlmAgl6KEXOwFfA8MNTqJMAXpggdjEf DIgXkj0bNANyTGDG7lQF8n2XQvGwhzt56UqEdzqWmlEGhvFE0aod993hsOV+OhQp5Ih8 tfmxfJe9FdP5lqEI2XEf3FP6iNSGQgC3cy8DJDk7gnSSWWSynBV1DVTMdunMahDlqCm3 b8s/i+wIV43KG85zA3HZOHJ4f86m0Jcb30ZLm2TeW6z4fwaoIg1cOvC1w9YwMjlqSxW4 +xqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NPd6TYoM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20-v6si21654717pgk.586.2018.10.29.17.34.04; Mon, 29 Oct 2018 17:34:20 -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=@gmail.com header.s=20161025 header.b=NPd6TYoM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726364AbeJ3JX1 (ORCPT + 99 others); Tue, 30 Oct 2018 05:23:27 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:41605 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbeJ3JX1 (ORCPT ); Tue, 30 Oct 2018 05:23:27 -0400 Received: by mail-ot1-f66.google.com with SMTP id c32so9456690otb.8; Mon, 29 Oct 2018 17:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=2JkJKlN+UGaVyqKcPlrnc3ALtjUNlaFk4LeAqM69eqI=; b=NPd6TYoMCGHn/BhTT+mkFlkrqo+94FOxbcxXHQ2J3Z/Yyto3XND7dBC7FnFvV4j3Vd iP+ix5fMfSXwS9jAAnkYWMYiV3LYBW2vi3egXYPeXmmT4GKS+WosXs1FDa/i4OeFXbN0 tYQF7uRYLTljBtKOOnUBr4KhSMV83DMFf8kB5HAv5WygJ+RC4sGxcUUAAuiB3cHMXBxC trC64HnXZIpiBEpRz+Bl5RYdITg6rr4YNla1wHcmscHZfgq6gG/aEK5tj42b+n+2udtA 40Sla1CHf6y24iHHI5ts5KS1sheI4OohuwrN0jdZEwNRvTbQiDWuRNH29h4Sw6G8SOAw FAjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2JkJKlN+UGaVyqKcPlrnc3ALtjUNlaFk4LeAqM69eqI=; b=kYGB1OvgNh/49JSRct+aPt7bUg9pZZbd/h0HB7M0oHwCzuLj9232oHdW6DMDkpcLm7 zWEAfm2wTIOPl0Az/k26uY5TQ5pqkdSu8oF4RpTLXyV3jZtejgIyrjNU3oO8kvkEIQtO daDP4y51udRfwAtSRjS+tf1mHWgOVjFc6Kx/PeqWViunDo3zHjneCNYZyGQ4TpyusfO2 AqKYHchd3nAdcfB6SS8sUSZDyz+2NmPWMM5ehPPgeU6aBLdqkE7aJis2wtKhuFpAp3Xj J+NX8mGRD9V4p9Snb0L5X533ekZ9KcKwATy3A4aq+NBB52CpBkvq1bHOORKPIlX/k++z NlTQ== X-Gm-Message-State: AGRZ1gJwt4Ll2atBPi1bsq7dedLXBScf7j6sXsInUSwT53uxFgLgjjAf SUS7IdOIQNbu3aBnu5yNQJ6Mna1A97VZDS0sMW8= X-Received: by 2002:a9d:2339:: with SMTP id j54mr3993239otb.263.1540859536786; Mon, 29 Oct 2018 17:32:16 -0700 (PDT) MIME-Version: 1.0 References: <20181023011042.GA6582@WindFlash> In-Reply-To: From: Leonardo Bras Date: Mon, 29 Oct 2018 21:32:05 -0300 Message-ID: Subject: Re: [PATCH v2 3/5] Creates macro to avoid variable shadowing To: Masahiro Yamada Cc: lkcamp@lists.libreplanetbr.org, Borislav Petkov , David.Laight@aculab.com, Andy Lutomirski , Ingo Molnar , Helen Koike , Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel 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 Thank you! On Sun, Oct 28, 2018 at 1:38 PM Masahiro Yamada wrote: > > On Tue, Oct 23, 2018 at 10:11 AM Leonardo Br=C3=A1s = wrote: > > > > Creates DEF_FIELD_ADDR_VAR as a more generic version of the DEF_FIELD_A= DD > > macro, allowing usage of a variable name other than the struct element = name. > > Also, sets DEF_FIELD_ADDR as a specific usage of DEF_FILD_ADDR_VAR in w= hich > > 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[], *__st= op___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 dev= id > > + * based at address m. Due to the way typeof works, for a field of ty= pe > > + * 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 dev= id > > * based at address m. Due to the way typeof works, for a field of ty= pe > > * 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, uns= igned 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, = devs); > > + 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= _card_device_id, devs); > > + while ((devs_last -=3D id_size) >=3D devs && !d= up) { > > > > for (j2 =3D 0; j2 < PNP_MAX_DEVICES; j2= ++) { > > - const char *id2 =3D (char *)(*d= evs)[j2].id; > > + const char *id2 =3D > > + (char *)(*devs_last)[j2= ].id; > > > > if (!id2[0]) > > break; > > -- > > 2.19.1 > > > > > -- > Best Regards > Masahiro Yamada