From patchwork Sat Feb 17 02:05:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 10225931 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 8EE46601D4 for ; Sat, 17 Feb 2018 02:08:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CD3A289A0 for ; Sat, 17 Feb 2018 02:08:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7140C28A5F; Sat, 17 Feb 2018 02:08:05 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 B98AB289A0 for ; Sat, 17 Feb 2018 02:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750942AbeBQCIE (ORCPT ); Fri, 16 Feb 2018 21:08:04 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52708 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750960AbeBQCID (ORCPT ); Fri, 16 Feb 2018 21:08:03 -0500 Received: by mail-wm0-f65.google.com with SMTP id t3so6109555wmc.2 for ; Fri, 16 Feb 2018 18:08:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=RzGvhjuMsrfhopjGuksNguMCkwdF8wPJwMwSWKwiAa0=; b=Ss79DRng/Wam1wFSFicZCZkmg0gS5k/FFkrL7dJghRgsHnzllTvRLwjkAdo3f+lpcg 7zWkN8qZHj0WIep5tGGqEgiimKILd15jAulVIxYxk3pkOHNIiBk8OqF2Ckzk90vfzqxa rAvz0N2lqgXPRsKxc2twPjNNpPhKuDrlPP5Avd2/rd6KfjridEjOuQoe5OHXtwNuGjqr f4FsvXBbqJX1jbghNMt+ltwqFJSq7L7mTtNp3ZlpiKX47Bost0EOAbzZ6b9f+JiCvric E2+POmaLL9CmBmhMcCIqY5PHjsu5Yz8dMou89rAC63ki22IRbVURV5aVweygIV3zB/Qz /8Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=RzGvhjuMsrfhopjGuksNguMCkwdF8wPJwMwSWKwiAa0=; b=CbyB/9nHeJROpczJjEIA2AlVZ5+5bmvGTES5g0ZJSRnTQugC+CNkglusYreLmB/pb3 zJxduB2u/8I/y0IqNnLBGO2gclOdcJB8Lzqg8IWdbO3eSkUujT8xSszTgpFXaidjB1ZX tdIWkt/Zqi+Sw7zOA01uPAvVXXqGlYKOHc6Dm65D8J3LahwTZz2a5ORZtrEQShIJTDxo uAnt0x5Fj13orkN50vxCS9yYTKuPk3DbUzgQ1hHeLVOCfzjnx3RZPtg7qs9YGXqd2hW6 KZQrN95/APTVGQ46YFyH+pQ8Ocp2EhrNuRx4WQf1OkttmW4i88qNP1Ye0g3yXSv7ZOw3 fk0Q== X-Gm-Message-State: APf1xPBg2ObETbuUZJc4hODshuzVofYUHRjcY8Y+Kv4EUNOegQCZynLw xhuhNWT10NmQDd62pPnMa2g= X-Google-Smtp-Source: AH8x227Zx9SLR7iWuqQ1hgdcho4KkZw5sgLK9YpyvWAk6RU1qAh9QkoDAXTXsCLXIvg6XctUMvjXcw== X-Received: by 10.80.217.141 with SMTP id w13mr10363191edj.193.1518833281836; Fri, 16 Feb 2018 18:08:01 -0800 (PST) Received: from erosca.home (ip1f12fa85.dynamic.kabel-deutschland.de. [31.18.250.133]) by smtp.gmail.com with ESMTPSA id l9sm538791edi.96.2018.02.16.18.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Feb 2018 18:08:00 -0800 (PST) From: Eugeniu Rosca X-Google-Original-From: Eugeniu Rosca To: Masahiro Yamada , Ulf Magnusson , Petr Vorel , Nicolas Pitre , Randy Dunlap , Paul Bolle Cc: Eugeniu Rosca , Eugeniu Rosca , linux-kbuild@vger.kernel.org Subject: [PATCH v3 1/3] kconfig: Print reverse dependencies on new line consistently Date: Sat, 17 Feb 2018 03:05:21 +0100 Message-Id: <371cac6c90c4e1013f5bbfb53e48b572695b509a.1518826148.git.erosca@de.adit-jv.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: References: In-Reply-To: References: 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 From: Eugeniu Rosca Commit 1ccb27143360 ("kconfig: make "Selected by:" and "Implied by:" readable") made an incredible improvement in how reverse dependencies are perceived by the user, by breaking down the single (often interminable) expression string into small readable chunks, each of them displayed on a separate line: Selected by: - A && B - C && (D || E) Unfortunately, what happens with the non-OR (either E_SYMBOL or E_AND) expressions is that they don't get a dedicated line: Selected by: F && G That's arguably a bug/misbehavior, but it puts some amount of burden in implementing new ways of printing reverse dependencies to the user. As example, if we prefix every reverse dependency top level "||" token by its tristate value, then subjectively [2] looks more readable than [1]. [1] Selected by: [m] F && G [2] Selected by: - [m] F && G Also, if we print the reverse dependency sub-expressions in groups (clustered by the tristate value they evaluate to), then subjectively [4] looks more readable than [3]. [3] Selected by [m]: F && G [4] Selected by [m]: - F && G Based on the above, print all the reverse dependency sub-expressions on a separate line _consistently_. An example of change contributed by this commit is seen below. | Symbol: NEED_SG_DMA_LENGTH [=y] | ... | Selected by: IOMMU_DMA [=y] && IOMMU_SUPPORT [=y] becomes: | Symbol: NEED_SG_DMA_LENGTH [=y] | ... | Selected by: | - IOMMU_DMA [=y] && IOMMU_SUPPORT [=y] This patch has been tested using a tuned variant of zconfdump which prints the reverse dependencies for each config symbol. Suggested-by: Masahiro Yamada Suggested-by: Ulf Magnusson Signed-off-by: Eugeniu Rosca Reviewed-by: Ulf Magnusson --- scripts/kconfig/expr.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index d45381986ac7..b89baed7f15c 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1179,6 +1179,16 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) return expr_get_leftmost_symbol(ret); } +static void +expr_print_newline(struct expr *e, + void (*fn)(void *, struct symbol *, const char *), + void *data, + int prevtoken) +{ + fn(data, NULL, "\n - "); + expr_print(e, fn, data, prevtoken); +} + static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken, bool revdep) { if (!e) { @@ -1191,7 +1201,10 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con switch (e->type) { case E_SYMBOL: if (e->left.sym->name) - fn(data, e->left.sym, e->left.sym->name); + if (!revdep) + fn(data, e->left.sym, e->left.sym->name); + else + expr_print_newline(e, fn, data, E_OR); else fn(data, NULL, ""); break; @@ -1234,19 +1247,19 @@ static void __expr_print(struct expr *e, void (*fn)(void *, struct symbol *, con fn(data, e->right.sym, e->right.sym->name); break; case E_OR: - if (revdep && e->left.expr->type != E_OR) - fn(data, NULL, "\n - "); __expr_print(e->left.expr, fn, data, E_OR, revdep); - if (revdep) - fn(data, NULL, "\n - "); - else + if (!revdep) fn(data, NULL, " || "); __expr_print(e->right.expr, fn, data, E_OR, revdep); break; case E_AND: - expr_print(e->left.expr, fn, data, E_AND); - fn(data, NULL, " && "); - expr_print(e->right.expr, fn, data, E_AND); + if (!revdep) { + expr_print(e->left.expr, fn, data, E_AND); + fn(data, NULL, " && "); + expr_print(e->right.expr, fn, data, E_AND); + } else { + expr_print_newline(e, fn, data, E_OR); + } break; case E_LIST: fn(data, e->right.sym, e->right.sym->name);