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: 10309285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 30B4660212 for ; Tue, 27 Mar 2018 05:34:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 215D329ADE for ; Tue, 27 Mar 2018 05:34:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 112AC29AE4; Tue, 27 Mar 2018 05:34:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B881929ADF for ; Tue, 27 Mar 2018 05:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752266AbeC0Fes (ORCPT ); Tue, 27 Mar 2018 01:34:48 -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-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Kees Cook Reviewed-by: Ulf Magnusson --- Changes in v2: - Simplify the patch. Just remove text expansion. scripts/kconfig/util.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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;