2018-02-21 05:46:47

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH] kconfig: Print reverse dependencies in groups

Signed-off-by: Masahiro Yamada <[email protected]>
---

This patch requires the following as a pre-requisite:
https://patchwork.kernel.org/patch/10229545/

These two will work equivalently to the following three:

https://patchwork.kernel.org/patch/10226951/
https://patchwork.kernel.org/patch/10226953/
https://patchwork.kernel.org/patch/10226955/


scripts/kconfig/expr.c | 18 ++++++++++++------
scripts/kconfig/expr.h | 3 ++-
scripts/kconfig/menu.c | 10 ++++++----
3 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index cd3a8f5..49376e1 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -1323,19 +1323,25 @@ void expr_gstr_print(struct expr *e, struct gstr *gs)
*/
static void expr_print_revdep(struct expr *e,
void (*fn)(void *, struct symbol *, const char *),
- void *data)
+ void *data, tristate pr_type, const char **title)
{
if (e->type == E_OR) {
- expr_print_revdep(e->left.expr, fn, data);
- expr_print_revdep(e->right.expr, fn, data);
- } else {
+ expr_print_revdep(e->left.expr, fn, data, pr_type, title);
+ expr_print_revdep(e->right.expr, fn, data, pr_type, title);
+ } else if (expr_calc_value(e) == pr_type) {
+ if (*title) {
+ fn(data, NULL, *title);
+ *title = NULL;
+ }
+
fn(data, NULL, " - ");
expr_print(e, fn, data, E_NONE);
fn(data, NULL, "\n");
}
}

-void expr_gstr_print_revdep(struct expr *e, struct gstr *gs)
+void expr_gstr_print_revdep(struct expr *e, struct gstr *gs,
+ tristate pr_type, const char *title)
{
- expr_print_revdep(e, expr_print_gstr_helper, gs);
+ expr_print_revdep(e, expr_print_gstr_helper, gs, pr_type, &title);
}
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index c16e82e..8dbf2a4 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -310,7 +310,8 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
void expr_fprint(struct expr *e, FILE *out);
struct gstr; /* forward */
void expr_gstr_print(struct expr *e, struct gstr *gs);
-void expr_gstr_print_revdep(struct expr *e, struct gstr *gs);
+void expr_gstr_print_revdep(struct expr *e, struct gstr *gs,
+ tristate pr_type, const char *title);

static inline int expr_is_yes(struct expr *e)
{
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 7e70be3..3b9beca 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -827,14 +827,16 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,

get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
if (sym->rev_dep.expr) {
- str_append(r, _(" Selected by: \n"));
- expr_gstr_print_revdep(sym->rev_dep.expr, r);
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]\n");
}

get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
if (sym->implied.expr) {
- str_append(r, _(" Implied by: \n"));
- expr_gstr_print_revdep(sym->implied.expr, r);
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Implied by [y]\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Implied by [m]\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Implied by [n]\n");
}

str_append(r, "\n\n");
--
2.7.4



2018-02-21 11:12:33

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH] kconfig: Print reverse dependencies in groups

Hi Masahiro,

> Signed-off-by: Masahiro Yamada <[email protected]>
Acked-by: Petr Vorel <[email protected]>
Just please fix typo leading to segfault and add ':'

<snip>
> get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
> if (sym->rev_dep.expr) {
> - str_append(r, _(" Selected by: \n"));
> - expr_gstr_print_revdep(sym->rev_dep.expr, r);
> + expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]\n");
> + expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]\n");
> + expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]\n");
Maybe add ':' to be consistent with the rest of titles?
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]:\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]:\n");
+ expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]:\n");

> }

> get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
> if (sym->implied.expr) {
> - str_append(r, _(" Implied by: \n"));
> - expr_gstr_print_revdep(sym->implied.expr, r);
> + expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Implied by [y]\n");
> + expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Implied by [m]\n");
> + expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Implied by [n]\n");
And the same here.
+ the most important thing - copy paste error, which obviously leads to segfault on
"Implied by":
Try search for PTP_1588_CLOCK (in x86_64 defconfig). gdb in coredump shows
#0 0x000000000041043e in expr_print_revdep (e=0x0, fn=0x410297 <expr_print_gstr_helper>, data=0x7fff0f2a8640, pr_type=yes, title=0x7fff0f2a85a0) at scripts/kconfig/expr.c:1328
1328 if (e->type == E_OR) {

So the correct is:
expr_gstr_print_revdep(sym->implied.expr, r, yes, " Implied by [y]:\n");
expr_gstr_print_revdep(sym->implied.expr, r, mod, " Implied by [m]:\n");
expr_gstr_print_revdep(sym->implied.expr, r, no, " Implied by [n]:\n");


Kind regards,
Petr

2018-02-21 11:19:27

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH] kconfig: Print reverse dependencies in groups

Hi Masahiro,

> > Signed-off-by: Masahiro Yamada <[email protected]>
> Acked-by: Petr Vorel <[email protected]>
Well, I'm not really the one to ack anything here, so please:
Reviewed-by: Petr Vorel <[email protected]>

Kind regards,
Petr

2018-02-21 14:04:16

by Ulf Magnusson

[permalink] [raw]
Subject: Re: [PATCH] kconfig: Print reverse dependencies in groups

On Wed, Feb 21, 2018 at 12:17 PM, Petr Vorel <[email protected]> wrote:
> Hi Masahiro,
>
>> > Signed-off-by: Masahiro Yamada <[email protected]>
>> Acked-by: Petr Vorel <[email protected]>
> Well, I'm not really the one to ack anything here, so please:
> Reviewed-by: Petr Vorel <[email protected]>
>
> Kind regards,
> Petr

Looks good to me too.

Reviewed-by: Ulf Magnusson <[email protected]>

Cheers,
Ulf