From patchwork Thu Mar 22 17:00:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 132310 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1087941ljb; Thu, 22 Mar 2018 10:02:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELuwSGhz2mvSEc61ruEesqM1683BsQgcxVLum7j9Uf1Kqj4BthFouNTMlV5finbuqWyln+RG X-Received: by 2002:a17:902:1e5:: with SMTP id b92-v6mr14380066plb.78.1521738122724; Thu, 22 Mar 2018 10:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521738122; cv=none; d=google.com; s=arc-20160816; b=V/MP1zTySZSRIZvKfigDpXoGV9RBd27E0wVCjG3NkYQHI/YNHHopG/H9sJJOYvP4ZT w0RaLhhDOSohDg2ZnLmFoMGf7oEOn3eOiEIUQgMg5PI03U+mpM1EfRQkSLy6iezTsSBt pqTVY3XXItNeAigFRyv3boV0BCjgtnacnRKe/sRRLbBUxoaMWjOuqdW9Sc3Cjmox4y6L xSVgf1TMB5BT14Ee/PQ5NT/T3ZM0BjW1Nr2jHJ/uTYDgiCJRCniyfwMNzEFjwTORwKpt AN+STiyYCDCvTyoZVvqXNelNge2C1g6a4bf6VQsi4lCek9qMOq/Y3WAXqUDh5LBAwl0v 5nbA== 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=6zVpC8ia9MmGsSQYMOG0Ae5Nm+HHA9lEhJv5gwvzIvI=; b=PMX4olgqmdOt8TEqCwzxVDLUUXHdjSPF4Eij5Zk2IYpObKszjCujjREYErFtonKAaI 6PQqPFBBk8AF3R47lfQXtIgJSP9RQRjZqJZTBDV98b4svUsCKlMSVC8gtiPd2xZBFDi7 pi5BeFC+qmXM+qbPMST/ITCxBczkpwtD8gcNqGgAiLDC/dV12WKm1hzKKRc1Muw29HNT BYyBhhQAy5umCE9O5QTZMd1FvJ/3lCcQ3om6vVffYxV6zWw1v46kMFEiBMxkxS7pQ5PJ r+K13oMYDL/DLLOILureSb5++QfBVedu96R+Shv9fiuvBMxdc/2GNejEMHersnvROb1V ApUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=DNtipiad; 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 t13si4443387pgu.62.2018.03.22.10.01.57; Thu, 22 Mar 2018 10:02:02 -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=DNtipiad; 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 S1752025AbeCVRBe (ORCPT + 28 others); Thu, 22 Mar 2018 13:01:34 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:47943 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751898AbeCVRBZ (ORCPT ); Thu, 22 Mar 2018 13:01:25 -0400 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-09.nifty.com with ESMTP id w2MH0Mr3012430; Fri, 23 Mar 2018 02:00:23 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com w2MH0Mr3012430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521738023; bh=6zVpC8ia9MmGsSQYMOG0Ae5Nm+HHA9lEhJv5gwvzIvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNtipiadzqYW06bMC+7pv8wag/scc3QcK3GZym3/DqR7U7Fu0nuPAcY0goQ+SvU50 nq5zxQZV7ZSKu4E5M25PQPXFVUNT5Na/15VQFY5/ZT819QzCA0ky6/wj88MED5fyMk gTNIUmo27mUp/wwJRxOR1BclxqomBpQHH2e/adOs/ti9GT2DBZ9leHsSDvxWHz+1iC pE4mSF6QIsEfmo1psIyvW/8V5ZBmMYIlXjnGkCTS9eIugQGr3C/7NwP1W//iFCyLAA c3gA4Z/dOap6/9jvUU1zQ6Hwx6Q+FKA9s/6eQ0ONr5q1k8h1Ww7gRDEpFm3HZ/I7St toxEvR2v20ftw== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Michal Marek , Sam Ravnborg , Ulf Magnusson , "Luis R . Rodriguez" , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] kconfig: detect recursive inclusion earlier Date: Fri, 23 Mar 2018 02:00:13 +0900 Message-Id: <1521738014-18895-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521738014-18895-1-git-send-email-yamada.masahiro@socionext.com> References: <1521738014-18895-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 Currently, the recursive inclusion is not detected when the offending file is about to be included; it is detected the offending file is about to include the *next* file. This is because the detection loop does not involve the file being included. Do this check against the file that is about to be included so that the recursive inclusion is detected before unneeded parsing happens. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 6f139d2..29b5d33 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -325,23 +325,25 @@ void zconf_nextfile(const char *name) buf->parent = current_buf; current_buf = buf; - for (iter = current_file->parent; iter; iter = iter->parent ) { - if (!strcmp(current_file->name,iter->name) ) { + file->parent = current_file; + + for (iter = current_file; iter; iter = iter->parent) { + if (!strcmp(iter->name, file->name)) { fprintf(stderr, "Recursive inclusion detected.\n" "Inclusion path:\n" - " current file : %s\n", zconf_curname()); - iter = current_file; + " current file : %s\n", file->name); + iter = file; do { iter = iter->parent; fprintf(stderr, " included from: %s:%d\n", iter->name, iter->lineno - 1); - } while (strcmp(iter->name, current_file->name)); + } while (strcmp(iter->name, file->name)); exit(1); } } + file->lineno = 1; - file->parent = current_file; current_file = file; }