Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp196644imm; Tue, 16 Oct 2018 21:19:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV63yBhzSvkIIhnNBS/Gwre4Xpk1ROKGeWjskWyb65A95l1mF6lkyKohscegYRVoefmBhldCf X-Received: by 2002:a62:808c:: with SMTP id j134-v6mr24649157pfd.47.1539749964931; Tue, 16 Oct 2018 21:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539749964; cv=none; d=google.com; s=arc-20160816; b=XnDyeYM8Yy8Va0SiyayuFGc3dfwZnWWTCAnu3JkA6wiNZ16S5XZ8kFchUklkq0WUFX rcEVyF4QrU+4YaBhU7CmoCnGLQ2274tIBnGjAv/PdUM/HKHjox735GwVczxewd6SXckd fm/vM9wKPeaxg5qPMu3KAOBWQLxNedoyWA7Ex573HsxhneZO2LAxXOnLpL/xWdjo1mdU b2NqRlAQZqccF1edZ4jT5w+cMR0WMWeQ+SjqY+rRs6cyLO2x+yD91wfUNnTQaIaYFrl1 Ty1O9cergjhT5nDtelFcu7e28ym9+wKyV2VF5kswcdl+LFFPWQNsI+bD3KJcjelKcO27 waeA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=DMprZeq/UiWnZrSRCaJlHaZ9WK3zUfxHnQ6rc1FtAbw=; b=x0TfXVB1HfcKYpB0HlOcOlRKfztD/90N3AbaKvZ7bAmU/gNM1eRISRSFtdzkFinyF9 JJida7kmAq1TCDkVUfXlkiXsXtzPJ0Mvt4T5v8kaiKU16dujEo6quDWtJRKN9fAZI9BG /YxOHT2AksMT+R1joOOOIgkleJstsLSTF3Ww8/gHYHgwWu6IcRjYmsqM2ztQwlDmOqNt Slumw3gbiL1vXpr3z0XZobFI2Cvye3OFs8XR28cIeXoPdyAwPqNnJ0BgMYjau+nx3N7d KQNYVnz9o1zKN+5i6HBTKnqlObY84AlNBdw/uqQjcfIC+lrfZzZ65Zt4cM5QSqyMbwHG KX6Q== ARC-Authentication-Results: i=1; mx.google.com; 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 v13-v6si16267119pgi.92.2018.10.16.21.19.08; Tue, 16 Oct 2018 21:19:24 -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; 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 S1727249AbeJQMMa (ORCPT + 99 others); Wed, 17 Oct 2018 08:12:30 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:34317 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727066AbeJQMM3 (ORCPT ); Wed, 17 Oct 2018 08:12:29 -0400 Received: by mail-qt1-f194.google.com with SMTP id o17-v6so28579237qtr.1; Tue, 16 Oct 2018 21:18:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=DMprZeq/UiWnZrSRCaJlHaZ9WK3zUfxHnQ6rc1FtAbw=; b=jhLpXygg7QH/hwq5lPVigWbHF503TYtKNPg0WA3SQhKSAELRV+Dnh//Del0Ye5FPBX nYfVpsx/2LTatZwjMuDBlK9NfAFYXM/ZhoA5FulS9+BwxUo5AfTKfZBr5iaVmDohCAhZ XIp/VRhO7P+Vg9P9d/gfGz2+XNeayqr+z/Np70WlaEGsNY5V7cxwJZjKGtkdfpVZkRqP zHtONFkgs8Pm5zbXpZyYTxpuli/z71hjacj6uRbjB+Z/FuNytykj05ownra8BcKeeNuj xiKuMB70IrNGewN3dzDLHO5kaTP98FnHtFnmQ2Ni1quNEHq3V0K6ySWCg5XnNh+BwMui 2guQ== X-Gm-Message-State: ABuFfohJUc/Dx1PmR/XBt2a7uIFc6SrAqAJK2OaSSx3jdzqkuNk+wJZw hkC1DHwgfqaU8xJJiVgcAzo= X-Received: by 2002:a0c:e3cf:: with SMTP id e15mr13163289qvl.51.1539749926335; Tue, 16 Oct 2018 21:18:46 -0700 (PDT) Received: from ?IPv6:2804:431:9718:6346:661:e081:23ef:66b? ([2804:431:9718:6346:661:e081:23ef:66b]) by smtp.gmail.com with ESMTPSA id p64-v6sm9084183qkc.96.2018.10.16.21.18.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 21:18:45 -0700 (PDT) Subject: Re: [Lkcamp] [PATCH 4/4] Changes macro usage to avoid shadowing a variable. To: =?UTF-8?Q?Leonardo_Br=c3=a1s?= , lkcamp@lists.libreplanetbr.org Cc: x86@kernel.org, linux-kbuild@vger.kernel.org, Matthew Wilcox , linux-kernel@vger.kernel.org, Masahiro Yamada , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Michal Marek , Thomas Gleixner References: <20181017000943.GA21382@WindFlash> From: Helen Koike Message-ID: <1f8c4570-4e56-1e96-711d-78f119f8d261@koikeco.de> Date: Wed, 17 Oct 2018 01:18:40 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181017000943.GA21382@WindFlash> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Leonardo, Thanks for the patch, just some small comments below. On 10/16/18 9:09 PM, Leonardo Brás wrote: > Changes the usage of DEF_FIELD_ADDR in this function to create a > reference and operate over it using an aux variable. > It also changes the loop logic used to find duplicates, to avoid > creating another variable. > > Signed-off-by: Leonardo Brás > --- > scripts/mod/file2alias.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c > index 7be43697ff84..9ea1db2aefdb 100644 > --- a/scripts/mod/file2alias.c > +++ b/scripts/mod/file2alias.c > @@ -641,25 +641,27 @@ static void do_pnp_card_entries(void *symval, unsigned 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 = 0; i < count; i++) { > unsigned int j; > - DEF_FIELD_ADDR(symval + i*id_size, pnp_card_device_id, devs); > + devs_last = devs + i * id_size; > > for (j = 0; j < PNP_MAX_DEVICES; j++) { > - const char *id = (char *)(*devs)[j].id; > - int i2, j2; > + const char *id = (char *)(*devs_last)[j].id; > + int j2; > int dup = 0; > > if (!id[0]) > break; > > /* find duplicate, already added value */ > - for (i2 = 0; i2 < i && !dup; i2++) { > - DEF_FIELD_ADDR(symval + i2*id_size, pnp_card_device_id, devs); > + while ((devs_last -= id_size) >= devs) { You forgot to consider the dup variable. Also you inverted the order of this loop, I am not sure this is important (I just took a quick look) but you need to be careful. This is also hard to read, I would define another variant macro where you can set any name of the variable, e.g. #define DEF_FIELD_ADDR_VAR(m, devid, f, var) \ typeof(((struct devid *)0)->f) *var = ((m) + OFF_##devid##_##f) In this way you don't need to change the logic, just the name of the variable. > > for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { > - const char *id2 = (char *)(*devs)[j2].id; > + const char *id2 = > + (char *)(*devs_last)[j2].id; > > if (!id2[0]) > break; > Regards, Helen