Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1355409imm; Wed, 17 Oct 2018 18:51:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV60UwENozA8j+tfre/SCHsCI5aeh8FKvW+Wd4CAm81LdzMbFEZfYLLs0kXar/egMmfEzbTwz X-Received: by 2002:a63:e07:: with SMTP id d7-v6mr1801518pgl.272.1539827465606; Wed, 17 Oct 2018 18:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539827465; cv=none; d=google.com; s=arc-20160816; b=X1Row1qml0y4ldG/cZzTp9yOhcsqHNBfdqcWfO8ilTImY5FpmyPZzeXeQhU9HTRQ1F H8U9vWO4mx9WYXP++NzQ/O2Fi3Gd5uZYUBFykvNEoQc3spFBtmoMj2WCgaFMrz90dreg cf/W4yDanr19zlRVsAVO5d3zxvS7xboVYQamSY3DdfvJWLVlgxSCL3koizV7UE7WaPA3 HRECoPUjv9kc/FqI53NXA+XNQm4td88CGgcxvyY5PS6gmldDUktZJZvDshqziLRjjbvm YIxwOrZwr6FlXaNa5OZ1OGb7GjQ8fZ1TMCg6hC/R6pjz/gPpLA3bvtLC9fhwAyN0SIzO /o8A== 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=tdT0I0zLF+if1rjK/teQ2+oVnyxx2c1rJ0Q/Q1Jsr0U=; b=Mzjk08G7uAqhghXf9okxq/K7q6wOaBFt3akAVUaRawwQ1Wck2lGI4BTNowkVRK72SJ 0NBIcPDywaWiOzNsDZywc/zDVdKtx9NcRh0bjWSwfZwRwRQmSXyWTCQEZd92r6G1TnKB YxzEu0ecQM0Tj5TcqPI/9d5IcTetp+3odlvIgXIUoqM2eXeQwa9+E4gfUlRgYzJZDIwR 4MpLwgDF6u16dVP9ywq8VvkXOibPqyA61iNsHU+NAo3BVOYZYVMVjyBjgU/ox1DTS7XE 6JV0jI19LgpDowFuD28A8Z+nX+ZHpQt2nKcrQcmhkrMxAH6XJ+L4Xh+FCMBosDX/beIP 2xbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qn45fXrs; 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 u1-v6si19221997pgh.244.2018.10.17.18.50.49; Wed, 17 Oct 2018 18:51:05 -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=qn45fXrs; 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 S1727392AbeJRJrY (ORCPT + 99 others); Thu, 18 Oct 2018 05:47:24 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:39087 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727028AbeJRJrY (ORCPT ); Thu, 18 Oct 2018 05:47:24 -0400 Received: by mail-ot1-f68.google.com with SMTP id l58so28229878otd.6; Wed, 17 Oct 2018 18:48:53 -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=tdT0I0zLF+if1rjK/teQ2+oVnyxx2c1rJ0Q/Q1Jsr0U=; b=qn45fXrsREsJ6M5xKTYXzvgjtxZjwYx3DFBcdOpHA8AjH25dMCo2EV4P93REv25l1l qm5Vp9wzlzksWXOkg2gGnb9pp2CnU1sgIIqSqAVOJqTsmPm8SqozWQnhVSErIqsfsVpI 70znYWeh0xifwWkIMXII3NpqejkGoePcNzBuBIaxnyUSYBBrtTQve/LXpOUqNWpQiFmg ScZx2SIjjApb1+BtAsRamXYRTmzDaFp7F8CFmjOCABVYHm9jFfIAgyH0Ze4I0JS4kgzi sRPu2JOXz9fATr9ZemFau/NoW9kQTQArP6hkqlUhpXhD+P4RNxcsrhaFV1pumkKjUi7F oN8Q== 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=tdT0I0zLF+if1rjK/teQ2+oVnyxx2c1rJ0Q/Q1Jsr0U=; b=Q6N52lgpVr9Hx5ACUkJ84Zs2Br3nBo7b+zjcyHypxUjliAmf0naBlufbJN5pzG+1ln r3dq6Sq2U6XanErGKOjkpr+ezN/r4n3Si3QN4Jc/ojQYCOPzQBs1W2oIO+nk6nAYGPor jt3wkQRKMtLCefgw5TyD8RtSs5si5fivgEfY4b+OQUGlqiCGifoEtCaMg02yAnglOK4h hIpCiOugrJZkBwASo1yjSOfi5bRhHo6YRVnITq3nFtn+4UwDuFP7AdHq49oZ9ytFZ+4c k2z8yOPL2NjWL/A3SfkrAI0vIos5mn/eLen6jbXYwqrTMgGiVa8j7zUPSNnIVoBawEyB CdHA== X-Gm-Message-State: ABuFfogyrhxZ9FwfM1ehdLuOgJwebRyjb2JYgwuluyH+F9rjINovK/Py 6XtKvgHqYCTrgNReqh6HjjyBh2agoF1m9xM6lfs= X-Received: by 2002:a9d:5b72:: with SMTP id e47mr19154551otj.318.1539827333010; Wed, 17 Oct 2018 18:48:53 -0700 (PDT) MIME-Version: 1.0 References: <20181017000943.GA21382@WindFlash> <1f8c4570-4e56-1e96-711d-78f119f8d261@koikeco.de> In-Reply-To: <1f8c4570-4e56-1e96-711d-78f119f8d261@koikeco.de> From: Leonardo Bras Date: Wed, 17 Oct 2018 22:48:41 -0300 Message-ID: Subject: Re: [Lkcamp] [PATCH 4/4] Changes macro usage to avoid shadowing a variable. To: helen@koikeco.de Cc: lkcamp@lists.libreplanetbr.org, x86@kernel.org, linux-kbuild@vger.kernel.org, Matthew Wilcox , linux-kernel , Masahiro Yamada , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Michal Marek , Thomas Gleixner 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 Hello Helen, On Wed, Oct 17, 2018 at 1:18 AM Helen Koike wrote: > > Hi Leonardo, > > Thanks for the patch, just some small comments below. > > On 10/16/18 9:09 PM, Leonardo Br=C3=A1s 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=C3=A1s > > --- > > 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, 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, 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) { > > You forgot to consider the dup variable. Sorry, I did not get it. Could you explain it? > 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. It seems to be looking for a duplicate. I don't think inverting will break anything. But I will give a better look anyway. > > This is also hard to read, Humm, IMO it looks easier to read this way. But ok, I can change it back. > 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 =3D ((m) + OFF_##devid##_##f) > > In this way you don't need to change the logic, just the name of the > variable. > Good suggestion. Is it ok to create a macro for using only once? It looks like its not worth the trouble. > > > > 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; > > > > Regards, > Helen Thank you for reviewing, Leonardo Bras