From patchwork Mon Dec 6 19:27:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Lacombe X-Patchwork-Id: 379652 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB6JSr73019742 for ; Mon, 6 Dec 2010 19:28:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752806Ab0LFT2x (ORCPT ); Mon, 6 Dec 2010 14:28:53 -0500 Received: from mail-vw0-f46.google.com ([209.85.212.46]:47832 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744Ab0LFT2w (ORCPT ); Mon, 6 Dec 2010 14:28:52 -0500 Received: by vws16 with SMTP id 16so2851834vws.19 for ; Mon, 06 Dec 2010 11:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=Jeu8evgfRrG8lKEU/FQc/EZoe7TX9Go4DQx/yOOwRw0=; b=nngalW/KbhXJGUmw8gV/lgP18ZtOU3zJKK/ruKTbDWeFzj/uj3iYW12czHOMFibsbS kr/QwJkjlKUecQ1tXDbRvS10MfEvhSWs/yZFtoh+tzKmKPeFjJ8KRO2rL9xcndphv7GX yEH1sl1H6fuWhKg1XmBDmst8a1LS85DM8gMeA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=J+JvDH6ZNMoHOnClTt1BnwtdwmBlmOO+hydR0wpZ6t8pCENfB7J/VpR53RreCc9Yfo lHRqrHsxkCJgcveWoa02kYp6VAct8axo0iKY5AFpKfMJhba9dgOW/15E963rdP5p3zcL j2jtAzxJu3VFnkQpGUAMF6b15gIYYsjcPwZ/k= Received: by 10.220.182.10 with SMTP id ca10mr1453091vcb.125.1291663731898; Mon, 06 Dec 2010 11:28:51 -0800 (PST) Received: from localhost.localdomain (69-196-129-64.dsl.teksavvy.com [69.196.129.64]) by mx.google.com with ESMTPS id j7sm604446vcr.39.2010.12.06.11.28.50 (version=SSLv3 cipher=RC4-MD5); Mon, 06 Dec 2010 11:28:50 -0800 (PST) From: Arnaud Lacombe To: linux-kbuild@vger.kernel.org Cc: Arnaud Lacombe , Catalin Marinas Subject: [PATCHv2] kconfig: simplify select-with-unmet-direct-dependency warning Date: Mon, 6 Dec 2010 14:27:49 -0500 Message-Id: <1291663669-13077-1-git-send-email-lacombar@gmail.com> X-Mailer: git-send-email 1.7.2.30.gc37d7.dirty Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 06 Dec 2010 19:28:54 +0000 (UTC) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 330e7c0..0a56c54 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1013,7 +1013,40 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2) #endif } -void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) +static inline struct expr * +expr_get_leftmost_symbol(const struct expr *e) +{ + + if (e == NULL) + return NULL; + + while (e->type != E_SYMBOL) + e = e->left.expr; + + return expr_copy(e); +} + +/* + * Given expression `e1' and `e2', returns the leaf of the longest + * sub-expression of `e1' not containing 'e2. + */ +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) +{ + struct expr *e, *ret; + + if (e1->type == E_OR) + return expr_alloc_and( + expr_simplify_unmet_dep(e1->left.expr, e2), + expr_simplify_unmet_dep(e1->right.expr, e2)); + + e = expr_alloc_and(expr_copy(e1), expr_copy(e2)); + e = expr_eliminate_dups(e); + ret = (!expr_eq(e, e1)) ? e1 : NULL; + expr_free(e); + return expr_get_leftmost_symbol(ret); +} + +void expr_print(const struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) { if (!e) { fn(data, NULL, "y"); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 47fe9c3..466eb1a 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -51,4 +51,4 @@ P(prop_get_type_name,const char *,(enum prop_type type)); /* expr.c */ P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); -P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)); +P(expr_print,void,(const struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 3acce4d..0c28a79 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -351,12 +351,16 @@ void sym_calc_value(struct symbol *sym) } calc_newval: if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { + struct expr *e; + e = expr_simplify_unmet_dep(sym->rev_dep.expr, + sym->dir_dep.expr); fprintf(stderr, "warning: ("); - expr_fprint(sym->rev_dep.expr, stderr); + expr_fprint(e, stderr); fprintf(stderr, ") selects %s which has unmet direct dependencies (", sym->name); expr_fprint(sym->dir_dep.expr, stderr); fprintf(stderr, ")\n"); + expr_free(e); } newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); }