From patchwork Tue Mar 27 05:29:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132450 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp4655296ljb; Mon, 26 Mar 2018 22:34:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELtJ/AbOhZpwvoTFLheD0nMvS4ewHWkBgKmzKifrvnNVx4gc8AZ3jHtNUrQDIR0Mlpoq5C0e X-Received: by 10.98.196.153 with SMTP id h25mr27448349pfk.111.1522128897567; Mon, 26 Mar 2018 22:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522128897; cv=none; d=google.com; s=arc-20160816; b=HpFYjRy64IE6LjOLuBnOR+0nW/KcOwizosSaP8BhruIol0jbcN9SM4kROHyaWrWeAg 7N/FjsSY8g8L4E+SQ+/xjJOWGCYtLZSUInwyrtegNQ8lPr6JgFUsIxp4TJrCrKV/F8uV Q2uxSW9dVUCC1rQEy0ffLpgngWUgS5jNCEY+6Wg8o4HDZLAnXkgxV4hXG5lu501jvfW/ 8vY/u6p4CSCXhyodpseZ5KCzAnDRv9+l9BUWhzJoVDk2cSC4MOi0e7PRp5E4qMa92y4E dKI41QpzVkGRD770aDZM+e3gMMNTFApCv90HUBC0QOLl9786M3QC2vAFlpSYD4PvP0pl 9Hjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=3YSzDtX7AAyzV3555aHdl8YmRdjyPFtREyhq2EffcVw=; b=Ygns/N18Oxr10vlu6kZV0+tPj5WllXNkEu4H/jVgTiQiU521sIn4QCd01+/I4hcrhG ou2nnFmy2XvHqVaSuf7C1J/vj3EmsFXNdzqJDrxpmEbHZPNcZbm7D+3Ds9m2+kIfmPcz dVEnNOobuZOZa1dp3oJ0Jyne66s11Bwa8e+82NlkHZU8ey3qcCu80RFd/THquXxTZ6nH TYNqyE7hakL7qFcCx5CmDcANuby4brLWviFaLJJVODtTQ+R1Mns2+ICjFe8r+UV8aaB4 DA1g8wDxC0nT1uoZdQG/o8TwcQl57QT96suMTgoBDegEM/uELzK2xieyx4aJP7RgnzUL bJMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=WO0pecUg; 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 g1-v6si507736plk.138.2018.03.26.22.34.57; Mon, 26 Mar 2018 22:34:57 -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=WO0pecUg; 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 S1752561AbeC0Few (ORCPT + 28 others); Tue, 27 Mar 2018 01:34:52 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:44788 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbeC0FcE (ORCPT ); Tue, 27 Mar 2018 01:32:04 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id w2R5TaLo011947; Tue, 27 Mar 2018 14:29:43 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com w2R5TaLo011947 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1522128584; bh=3YSzDtX7AAyzV3555aHdl8YmRdjyPFtREyhq2EffcVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WO0pecUgnoeGRDpww1FardE2UMEFzUiippf+dUzjCFRxXjrHg7Ijzg/JaN7rREDHe +YNeZ4MeMTfwVOoJfHBMjfoC6tWHCCUNVVf1lOOBoVjbzenkihSByQ+GnodqOiCF4g ht9xNJPKUZ75eLPjKJEX29JYc3IA4iU6CS+MGG6sMsPtSvq0FU94hZQoyj2RL8LmA1 lKS69lzV0QkZsKMOF1Dcl5dh8DFZo0k5/2sJTDsd2yi/4PX6AC/9HyTDopx84wYsLD WJSdMZTUdGrnEi+dYdWMRBjJcbYP+sIuWN2Y5/kb8OMwsSUK7UyR2k/qs4FfsanY88 zn06WgftCH8Qw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Linus Torvalds , Arnd Bergmann , Ulf Magnusson , Kees Cook , Thomas Gleixner , Greg Kroah-Hartman , Randy Dunlap , "Luis R . Rodriguez" , Nicolas Pitre , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 05/21] kconfig: remove string expansion in file_lookup() Date: Tue, 27 Mar 2018 14:29:19 +0900 Message-Id: <1522128575-5326-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> References: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are two callers of file_lookup(). [1] zconf_initscan() This is used to open the first Kconfig. However, it cannot contain environments in the file path because zconf_fopen() is called before file_lookup(). By swapping the call order, KBUILD_KCONFIG would be able to contain environments, but I do not see practical benefits to support it. [2] zconf_nextfile() This is used to open the next file from 'source' statement like source "arch/$SRCARCH/Kconfig" but this has already been expanded in the lexer phase. So, file_lookup() does not need to expand the given path. By the way, file_lookup() was already buggy; it expanded a given path, but it used the path before expansion for look-up: if (!strcmp(name, file->name)) { Signed-off-by: Masahiro Yamada --- Changes in v2: - Simplify the patch. Just remove text expansion. scripts/kconfig/util.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.7.4 Reviewed-by: Kees Cook Reviewed-by: Ulf Magnusson diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 136e497..3d27c49 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -58,18 +58,16 @@ char *expand_string_value(const char *in) struct file *file_lookup(const char *name) { struct file *file; - char *file_name = expand_string_value(name); for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) { - free(file_name); return file; } } file = xmalloc(sizeof(*file)); memset(file, 0, sizeof(*file)); - file->name = file_name; + file->name = xstrdup(name); file->next = file_list; file_list = file; return file;