From patchwork Tue Feb 13 00:56:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 10214969 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 3F6A760236 for ; Tue, 13 Feb 2018 00:57:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A63D28E27 for ; Tue, 13 Feb 2018 00:57:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CDA828E2B; Tue, 13 Feb 2018 00:57: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 2B10928E27 for ; Tue, 13 Feb 2018 00:57:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932957AbeBMA5D (ORCPT ); Mon, 12 Feb 2018 19:57:03 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:52605 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932877AbeBMA5C (ORCPT ); Mon, 12 Feb 2018 19:57:02 -0500 Received: by mail-wm0-f68.google.com with SMTP id j199so681878wmj.2 for ; Mon, 12 Feb 2018 16:57: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:mime-version :content-transfer-encoding; bh=xiPXPEkX0Hffe67jr6OvOmjknwSxoquJDj2rZe1WBxI=; b=Vcz+QvE6dpQZXCHTFhhmwpfqSO6kYZ+IqubsPTRtGSiIhjD2MF4oNxwx4lmkOyOD0V dUIPTLZFCdtJ35RZhzmqpCw8HhBI6vJcyh9FNCyiQekyI6pVXD82Ppct9fsnxmmGmM+m J8ZvzCjS9Z6Bx1Dp2La9qt+VuYBwVtgrRu4xJYOLZhL+sIoAlXqgPreQjT6UvR0UYfR+ Cc/CnpbzuMbqtlAiWeB8lYKo+iBDejIlS3i0nd7A1XpWnz0J7zSA0qJBMYKzi2eAh5EN FceRCHgaOqgFsKOP7k+vhONCTAsJAbNfeXn8IuNAAdtnMbb62h3+kycXgaP7IwPfvuab 2V1w== 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:mime-version :content-transfer-encoding; bh=xiPXPEkX0Hffe67jr6OvOmjknwSxoquJDj2rZe1WBxI=; b=tWusPr8Gg4d9AAUnNuPewHMoK3xuKXUeiDPXgmFk92qjSBTCLI95pOK2COYqw1jqcT 6WhLcYL2r6VvKuDIRU/cRToPVOJHYCzlAZsWkTl66qqgpLr/XHRIx++/pdRm6ga8sK0H yxE1++cmNy6BQ7QrCs73JYfqY3SiCGsxpEWZ4K0Q4YvHsQdPh1dcyYel6j5p0xWiKSe2 fRgbIZt2LxEUlOMPqOI2liMSblJktTC79y+7xsIVdFcAC2pVvWkDiq8TnEaPtQ4QBaoZ fswE7qjCAFddO49QmFAZZ0HQ8i7fer8acJ12m25M/MqXL/SMwLXRB+P6Y05qTHRBfpwl LOPQ== X-Gm-Message-State: APf1xPDbghaahTaa6Cyv6y75w8FwYx8YRNdaM7WkxtGTNGpMlFgCi9AK bp9CR4LAuHD09VCpTR7q2S4= X-Google-Smtp-Source: AH8x226qLVayYCy0We3P+sSiFJLAoD8WnoO/MEsoaTYLyY87H9MXrN8SV7RTjTm5IwT9/02V1p159Q== X-Received: by 10.80.192.9 with SMTP id r9mr18355556edb.184.1518483421545; Mon, 12 Feb 2018 16:57:01 -0800 (PST) Received: from erosca.home ([2a02:8108:91c0:4bcc:1f4:a0a9:d348:b84f]) by smtp.gmail.com with ESMTPSA id 60sm5581719edy.36.2018.02.12.16.56.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Feb 2018 16:57:00 -0800 (PST) From: Eugeniu Rosca X-Google-Original-From: Eugeniu Rosca To: Masahiro Yamada , Ulf Magnusson , Nicolas Pitre , Randy Dunlap , Petr Vorel , Paul Bolle Cc: Eugeniu Rosca , linux-kbuild@vger.kernel.org, Eugeniu Rosca Subject: [PATCH 1/2] kconfig: Print reverse dependencies on new line consistently Date: Tue, 13 Feb 2018 01:56:09 +0100 Message-Id: <20180213005610.10575-1-rosca.eugeniu@gmail.com> X-Mailer: git-send-email 2.16.1 MIME-Version: 1.0 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 makes the implementation of something like below more complicated: Selected by: - [m] F & G /* where (F & G) evaluates to '=m' */ Adding '[m]', '[y]' or '[ ]' to the left side of each reverse dependency is subject of a different commit. The purpose of current commit is to print the 'Selected by:' and 'Implied by:' 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 custom 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..0704bcdf4c78 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) + expr_print_newline(e, fn, data, E_OR); + else + fn(data, e->left.sym, e->left.sym->name); 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_newline(e, fn, data, E_OR); + } else { + expr_print(e->left.expr, fn, data, E_AND); + fn(data, NULL, " && "); + expr_print(e->right.expr, fn, data, E_AND); + } break; case E_LIST: fn(data, e->right.sym, e->right.sym->name);