kconfig: Remove bad inference rules expr_eliminate_dups2()
v2 cover kconfig: Remove bad inference rules expr_eliminate_dups2()
This is the third time I send this patch. As I think it is an obvious improvement, but has not been applied, please tell me what is wrong with this patch and what I can do better.
PATCH 1: Remove expr_eliminate_dups2() and other related code. This does not seem to actually affect the behaviour when using Kconfig files from the mainline kernel. But there is a slight possibility that there are configuration files in other branches or in other projects that use the Linux Kernel configuration system that may be affected or may even rely on the behaviour (although I did not find such a case when doing a quick check on busybox, uClibc and openwrt). So, there is a tiny chance to break some very exotic case (on the other hand, it is plausible that it actually fixes any such case).
PATCH 2: When touching expr.c anyway, fix some comments and convert C99 style comments to traditional ones.
Martin Walch (2):
kconfig: completely remove expr_eliminate_dups2() and related code
kconfig: trivial - adjust comments
scripts/kconfig/expr.c | 146 +++++++------------------------------------------ scripts/kconfig/expr.h | 3 - 2 files changed, 19 insertions(+), 130 deletions(-)
Signature · 1 line
1.8.5.5
v2 cover kconfig: fix bad syntactic transformation
PATCH 1: Remove these two not semantics preserving inference rules:
(FOO || BAR) && (!FOO && !BAR) -> n
(FOO && BAR) || (!FOO || !BAR) -> y
When applied, they silently alter the meaning of symbol dependencies.
PATCH 2: When touching expr.c anyway, fix some comments and convert C99 style comments to traditional ones.
Martin Walch (2):
kconfig: fix bad syntactic transformation in expr.c
kconfig: trivial - adjust comments
scripts/kconfig/expr.c | 146 +++++++------------------------------------------ scripts/kconfig/expr.h | 3 - 2 files changed, 19 insertions(+), 130 deletions(-)
Signature · 1 line
1.8.5.5
PATCH v2 1/2 kconfig: fix bad syntactic transformation in expr.c
expr_eliminate_dups2() in scripts/kconfig/expr.c applies two bad inference rules:
(FOO || BAR) && (!FOO && !BAR) -> n
(FOO && BAR) || (!FOO || !BAR) -> y
They would be correct in propositional logic, but this is a three-valued logic, and here it is wrong in that it changes semantics. It becomes immediately visible when substituting FOO and BAR with m.
Fix it by removing expr_eliminate_dups2() and the functions that have no use anywhere else: expr_extract_eq_and(), expr_extract_eq_or(),
and expr_extract_eq() from scripts/kconfig/expr.[ch]
Currently the bug is not triggered in mainline, so this patch does not modify the configuration space there.
As a side effect, this reduces code size in expr.c by roughly 10% and slightly improves startup time for all configuration frontends.
--- scripts/kconfig/expr.c | 108 ------------------------------------------------- scripts/kconfig/expr.h | 3 -- 2 files changed, 111 deletions(-)
scripts/kconfig/expr.c +0 -108
@@ -553,62 +553,6 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct#undef e2 } -static void expr_eliminate_dups2 (enum expr_type type,struct expr **ep1,struct expr **ep2) -{ -#define e1 (*ep1) -#define e2 (*ep2) -struct expr *tmp, *tmp1, *tmp2; - -if (e1->type == type) { -expr_eliminate_dups2 (type, &e1->left.expr, &e2); -expr_eliminate_dups2 (type, &e1->right.expr, &e2); -return ; - } -if (e2->type == type) { -expr_eliminate_dups2 (type, &e1, &e2->left.expr); -expr_eliminate_dups2 (type, &e1, &e2->right.expr); - } -if (e1 == e2) -return ; - -switch (e1->type) { -case E_OR : -expr_eliminate_dups2 (e1->type, &e1, &e1); -// (FOO || BAR) && (!FOO && !BAR) -> n - tmp1 =expr_transform (expr_alloc_one (E_NOT ,expr_copy (e1))); - tmp2 =expr_copy (e2); - tmp =expr_extract_eq_and (&tmp1, &tmp2); -if (expr_is_yes (tmp1)) { -expr_free (e1); - e1 =expr_alloc_symbol (&symbol_no); - trans_count++; - } -expr_free (tmp2); -expr_free (tmp1); -expr_free (tmp); -break ; -case E_AND : -expr_eliminate_dups2 (e1->type, &e1, &e1); -// (FOO && BAR) || (!FOO || !BAR) -> y - tmp1 =expr_transform (expr_alloc_one (E_NOT ,expr_copy (e1))); - tmp2 =expr_copy (e2); - tmp =expr_extract_eq_or (&tmp1, &tmp2); -if (expr_is_no (tmp1)) { -expr_free (e1); - e1 =expr_alloc_symbol (&symbol_yes); - trans_count++; - } -expr_free (tmp2); -expr_free (tmp1); -expr_free (tmp); -break ; -default : - ; - } -#undef e1 -#undef e2 -} -struct expr *expr_eliminate_dups (struct expr *e) {int oldcount;
@@ -621,7 +565,6 @@ struct expr *expr_eliminate_dups(struct expr *e)switch (e->type) {case E_OR :case E_AND :expr_eliminate_dups1 (e->type, &e, &e); -expr_eliminate_dups2 (e->type, &e, &e);default : ; }
@@ -823,57 +766,6 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym)return false; } -struct expr *expr_extract_eq_and (struct expr **ep1,struct expr **ep2) -{ -struct expr *tmp =NULL ; -expr_extract_eq (E_AND , &tmp, ep1, ep2); -if (tmp) { - *ep1 =expr_eliminate_yn (*ep1); - *ep2 =expr_eliminate_yn (*ep2); - } -return tmp; -} - -struct expr *expr_extract_eq_or (struct expr **ep1,struct expr **ep2) -{ -struct expr *tmp =NULL ; -expr_extract_eq (E_OR , &tmp, ep1, ep2); -if (tmp) { - *ep1 =expr_eliminate_yn (*ep1); - *ep2 =expr_eliminate_yn (*ep2); - } -return tmp; -} - -void expr_extract_eq (enum expr_type type,struct expr **ep,struct expr **ep1,struct expr **ep2) -{ -#define e1 (*ep1) -#define e2 (*ep2) -if (e1->type == type) { -expr_extract_eq (type, ep, &e1->left.expr, &e2); -expr_extract_eq (type, ep, &e1->right.expr, &e2); -return ; - } -if (e2->type == type) { -expr_extract_eq (type, ep, ep1, &e2->left.expr); -expr_extract_eq (type, ep, ep1, &e2->right.expr); -return ; - } -if (expr_eq (e1, e2)) { - *ep = *ep ?expr_alloc_two (type, *ep, e1) : e1; -expr_free (e2); -if (type ==E_AND ) { - e1 =expr_alloc_symbol (&symbol_yes); - e2 =expr_alloc_symbol (&symbol_yes); - }else if (type ==E_OR ) { - e1 =expr_alloc_symbol (&symbol_no); - e2 =expr_alloc_symbol (&symbol_no); - } - } -#undef e1 -#undef e2 -} -struct expr *expr_trans_compare (struct expr *e,enum expr_type type,struct symbol *sym) {struct expr *e1, *e2;
scripts/kconfig/expr.h +0 -3
@@ -214,9 +214,6 @@ struct expr *expr_eliminate_dups(struct expr *e);struct expr *expr_transform (struct expr *e);int expr_contains_symbol (struct expr *dep,struct symbol *sym);bool expr_depends_symbol (struct expr *dep,struct symbol *sym); -struct expr *expr_extract_eq_and (struct expr **ep1,struct expr **ep2); -struct expr *expr_extract_eq_or (struct expr **ep1,struct expr **ep2); -void expr_extract_eq (enum expr_type type,struct expr **ep,struct expr **ep1,struct expr **ep2);struct expr *expr_trans_compare (struct expr *e,enum expr_type type,struct symbol *sym);struct expr *expr_simplify_unmet_dep (struct expr *e1,struct expr *e2);
Signature · 1 line
1.8.5.5
Re: [PATCH v2 1/2] kconfig: fix bad syntactic transformation in expr.c
Quoted 9 lines · Martin Walch
expr_eliminate_dups2()inscripts/kconfig/expr.capplies two bad inference rules:(FOO || BAR) && (!FOO && !BAR) -> n
(FOO && BAR) || (!FOO || !BAR) -> yThey would be correct in propositional logic, but this is a three-valued logic, and here it is wrong in that it changes semantics. It becomes immediately visible when substituting FOO and BAR with m.
Well, not to me. When I apply the rules under "Menu dependencies" in Documentation/kbuild/kconfig-language.txt, in embarrassingly small steps, I get:
(m || m) && (!m && !m) ->
(1 || 1) && ((2 - 1) && (2 - 1)) ->
(1 || 1) && (1 && 1) ->
max(1, 1) && min(1, 1) ->
1 && 1 ->
min(1, 1) ->
1 -> mand
(m && m) || (!m || !m) ->
(1 && 1) || ((2 - 1) || (2 - 1)) ->
(1 && 1) || (1 || 1) ->
min(1, 1) || max(1, 1) ->
1 || 1 ->
max(1, 1) ->
1 -> mDid I do that right? Anyway, perhaps you'd like to add a line or two how these two expressions actually evaluate when FOO and BAR are m.
Quoted 11 lines
Fix it by removing
expr_eliminate_dups2()and the functions that have no use anywhere else:expr_extract_eq_and(),expr_extract_eq_or(),
andexpr_extract_eq()from scripts/kconfig/expr.[ch]Currently the bug is not triggered in mainline, so this patch does not modify the configuration space there.
As a side effect, this reduces code size in
expr.cby roughly 10% and slightly improves startup time for all configuration frontends.Signed-off-by Martin Walch <[email protected]>
Does Yann still care about Kconfig? Yann has been rather quiet for a while now.
Paul Bolle
Re: [PATCH v2 1/2] kconfig: fix bad syntactic transformation in expr.c
Quoted 31 lines · Paul Bolle
Quoted 9 lines · Martin Walch
expr_eliminate_dups2()inscripts/kconfig/expr.capplies two bad inference rules:(FOO || BAR) && (!FOO && !BAR) -> n
(FOO && BAR) || (!FOO || !BAR) -> yThey would be correct in propositional logic, but this is a three-valued logic, and here it is wrong in that it changes semantics. It becomes immediately visible when substituting FOO and BAR with m.
Well, not to me. When I apply the rules under "Menu dependencies" in
Documentation/kbuild/kconfig-language.txt, in embarrassingly small steps, I get:(m || m) && (!m && !m) -> (1 || 1) && ((2 - 1) && (2 - 1)) -> (1 || 1) && (1 && 1) -> max(1, 1) && min(1, 1) -> 1 && 1 -> min(1, 1) -> 1 -> mand
(m && m) || (!m || !m) -> (1 && 1) || ((2 - 1) || (2 - 1)) -> (1 && 1) || (1 || 1) -> min(1, 1) || max(1, 1) -> 1 || 1 -> max(1, 1) -> 1 -> m
Quoted 2 lines
Did I do that right? Anyway, perhaps you'd like to add a line or two how these two expressions actually evaluate when FOO and BAR are m.
Perhaps, it helps to use a Kconfig file that visualizes the problem:
mainmenu "Expr Test"
config expr-config
bool "Expr Config" depends on (m || m) && (!m && !m)
# depends on (m && m) || (!m || !m)
config dummy
bool "Dummy"
config modules
bool
option modules
default y
Those two depends, according to your calculation and if I understood correctly also to Martin's, should evaluate to 'm' and thus the menu entry should always be visible, because both depends should evaluate to 'm'. But because of expr_eliminate_dups2() it is either invisible (the first depends becomes 'n') or always visible (the second depends becomes 'y').
Dirk
Quoted 22 lines
Quoted 11 lines
Fix it by removing
expr_eliminate_dups2()and the functions that have no use anywhere else:expr_extract_eq_and(),expr_extract_eq_or(),
andexpr_extract_eq()from scripts/kconfig/expr.[ch]Currently the bug is not triggered in mainline, so this patch does not modify the configuration space there.
As a side effect, this reduces code size in
expr.cby roughly 10% and slightly improves startup time for all configuration frontends.Signed-off-by Martin Walch <[email protected]>Does Yann still care about
Kconfig? Yann has been rather quiet for a while now.Paul Bolle
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/2] kconfig: fix bad syntactic transformation in expr.c
Quoted 33 lines · On Tuesday 07 October 2014 11:21:51 Dirk Gouders wrote:
Quoted 31 lines · Paul Bolle
Quoted 9 lines · Martin Walch
expr_eliminate_dups2()inscripts/kconfig/expr.capplies two bad inference rules:(FOO || BAR) && (!FOO && !BAR) -> n
(FOO && BAR) || (!FOO || !BAR) -> yThey would be correct in propositional logic, but this is a three-valued logic, and here it is wrong in that it changes semantics. It becomes immediately visible when substituting FOO and BAR with m.
Well, not to me. When I apply the rules under "Menu dependencies" in
Documentation/kbuild/kconfig-language.txt, in embarrassingly small steps, I get:(m || m) && (!m && !m) -> (1 || 1) && ((2 - 1) && (2 - 1)) -> (1 || 1) && (1 && 1) -> max(1, 1) && min(1, 1) -> 1 && 1 -> min(1, 1) -> 1 -> mand
(m && m) || (!m || !m) -> (1 && 1) || ((2 - 1) || (2 - 1)) -> (1 && 1) || (1 || 1) -> min(1, 1) || max(1, 1) -> 1 || 1 -> max(1, 1) -> 1 -> m
Quoted 2 lines
Quoted 2 lines
Did I do that right? Anyway, perhaps you'd like to add a line or two how these two expressions actually evaluate when FOO and BAR are m.
Yes, this is a proper evaluation.
To explain the problem in more detail, I will describe it a bit more formal. First of all, this is a thing about the formal system of the configuration logic, so I think it is a good idea to distinguish between syntax and semantics.
Any expression, e.g. "(FOO || BAR)" is pure syntax. It consists of non-constant symbols (FOO, BAR...), constant symbols (n, m, y), operators (||, &&, !), and parenthesis.
Semantics is when evaluating an expression by assigning values to the constant and the non-constant symbols and functions to the operators (overriding operator precedence with parenthesis), and then calculating an actual value.
So, this is pure syntax:
(FOO || BAR) && (!FOO && !BAR)
And semantics is:
* an assignment of 0, 1, or 2 to each of the non-constant symbols (arbitrary)
* the fixed assignments of 0 to n, 1 to m, and 2 to y
* applying the functions to values that correspond to the respective operators
So, e.g. when assigning 2 to FOO and 0 to BAR, then the evaluation of
(FOO || BAR) && (!FOO && !BAR)
is
min(max(2, 0), min(2-2, 2-0)) = 0
Above, we saw that assigning 1 to FOO as well as to BAR yields 1 for the whole expression.
Now getting back to the problem: the configuration system makes some syntactical transformations according to some rules, so they are easier to read in the user interfaces (e.g. mconf). In formal logic, such rules are called "inference rules". Obviously, inference rules are purely syntactical transformations, e.g. one rule could be to replace "FOO && FOO" with only "FOO". Another rule could replace "FOO || BAR" with "FOO && BAR". The difference between these two example rules is that in semantics, the first one keeps the result of the evaluation for all possible assignments, while the second one changes the results for some of the assignments. Formally, the first rule is "valid" while the second one is not.
With the term "valid" it is now easy to summarize the actual problem:
The inference rule
(FOO || BAR) && (!FOO && !BAR) -> n
is not valid. The proof for this is assigning 1 to FOO and also to BAR. As we have already seen, for this assignment, the expression evaluates to 1. In contrast, the expression "n" always evaluates to 0. So, this inference rule is not valid.
Quoted 17 lines
Perhaps, it helps to use a
Kconfigfile that visualizes the problem:mainmenu "Expr Test"
config expr-config
bool "Expr Config" depends on (m || m) && (!m && !m)# depends on (m && m) || (!m || !m)
config dummy
bool "Dummy"config modules
bool
option modules
default y
Quoted 6 lines
Those two depends, according to your calculation and if I understood correctly also to Martin's, should evaluate to 'm' and thus the menu entry should always be visible, because both depends should evaluate to 'm'. But because of
expr_eliminate_dups2()it is either invisible (the first depends becomes 'n') or always visible (the second depends becomes 'y').
This is a good idea. However, I tried to avoid an example that contains the constant symbol "m". The problem with this is that "m" is treated specially and can lead to some confusion, although a very short test case is possible using m:
config expr-config-short
bool "Expr Config Short" depends on m && !m
When this file is read, each of the two "m" symbols is replaced with "m && MODULES", so the expression reads:
(m && MODULES) && !(m && MODULES)
then the negation of "!(m && MODULES)" is transformed:
(m && MODULES) && (!m || !MODULES)
(this corresponds to one of the "De Morgan's laws" in other logical systems)
Finally, the bad inference rule applies (although the form of the expression is slightly different from above) and this expression is replaced with:
n
This is not valid (assigning 2 to MODULES should yield 1 for the whole expression, but "n" evaluates to 0).
Does this make things clearer?
Regards,
Martin Walch
Re: [PATCH v2 1/2] kconfig: fix bad syntactic transformation in expr.c
In reply to Martin WalchQuoted 6 lines · Martin Walch
Fix it by removing
expr_eliminate_dups2()and the functions that have no use anywhere else:expr_extract_eq_and(),expr_extract_eq_or(),
andexpr_extract_eq()from scripts/kconfig/expr.[ch]Currently the bug is not triggered in mainline, so this patch does not modify the configuration space there.
Would I be whining if I'd complained about the lack of documentation for expr_eliminate_dups(), expr_eliminate_dups1(), and expr_eliminate_dups2()?
So, I've put in these two calls of fprintf():
@@ -579,6 +606,7 @@ static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct
tmp2 = expr_copy(e2);
tmp = expr_extract_eq_and(&tmp1, &tmp2);
if (expr_is_yes(tmp1)) {
+ fprintf(stderr, "%s:%d:\n", __func__, __LINE__);
expr_free(e1);
e1 = expr_alloc_symbol(&symbol_no);
trans_count++;
@@ -594,6 +622,7 @@ static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct
tmp2 = expr_copy(e2);
tmp = expr_extract_eq_or(&tmp1, &tmp2);
if (expr_is_no(tmp1)) {
+ fprintf(stderr, "%s:%d:\n", __func__, __LINE__);
expr_free(e1);
e1 = expr_alloc_symbol(&symbol_yes);
trans_count++;None of the 500+ defconfig files in next-20141010 triggered those fprintf's.
Does that means it's likely that nothing in next-20141010 actually uses the functionality expr_eliminate_dups2() provides?
Paul Bolle
PATCH v2 2/2 kconfig: trivial - adjust comments
In reply to Martin WalchReplace any C99 comments with traditional ones (/*...*/).
Also fix the contents of two comments:
1) the second occurrence of
(a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
is probably copy & paste from above, missing the adjustment corresponding to the code.
It should probably read
(a!='b') && (a='c') -> 'b'='c' ? 'n' : a='c'
2) that one is similar:
(a!='m') && (a!='n') -> (a='m')
it should be
(a!='m') && (a!='n') -> (a='y')
--- scripts/kconfig/expr.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
scripts/kconfig/expr.c +19 -19
@@ -326,7 +326,7 @@ struct expr *expr_trans_bool(struct expr *e) e->right.expr =expr_trans_bool (e->right.expr);break ;case E_UNEQUAL : -// FOO!=n -> FOO +/* FOO!=n -> FOO */ if (e->left.sym->type ==S_TRISTATE ) {if (e->right.sym == &symbol_no) { e->type =E_SYMBOL ;
@@ -375,19 +375,19 @@ static struct expr *expr_join_or(struct expr *e1, struct expr *e2)if (e1->type ==E_EQUAL && e2->type ==E_EQUAL && ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) { -// (a='y') || (a='m') -> (a!='n') +/* (a='y') || (a='m') -> (a!='n') */ return expr_alloc_comp (E_UNEQUAL , sym1, &symbol_no); }if (e1->type ==E_EQUAL && e2->type ==E_EQUAL && ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) { -// (a='y') || (a='n') -> (a!='m') +/* (a='y') || (a='n') -> (a!='m') */ return expr_alloc_comp (E_UNEQUAL , sym1, &symbol_mod); }if (e1->type ==E_EQUAL && e2->type ==E_EQUAL && ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) { -// (a='m') || (a='n') -> (a!='y') +/* (a='m') || (a='n') -> (a!='y') */ return expr_alloc_comp (E_UNEQUAL , sym1, &symbol_yes); } }
@@ -438,29 +438,29 @@ static struct expr *expr_join_and(struct expr *e1, struct expr *e2)if ((e1->type ==E_SYMBOL && e2->type ==E_EQUAL && e2->right.sym == &symbol_yes) || (e2->type ==E_SYMBOL && e1->type ==E_EQUAL && e1->right.sym == &symbol_yes)) -// (a) && (a='y') -> (a='y') +/* (a) && (a='y') -> (a='y') */ return expr_alloc_comp (E_EQUAL , sym1, &symbol_yes);if ((e1->type ==E_SYMBOL && e2->type ==E_UNEQUAL && e2->right.sym == &symbol_no) || (e2->type ==E_SYMBOL && e1->type ==E_UNEQUAL && e1->right.sym == &symbol_no)) -// (a) && (a!='n') -> (a) +/* (a) && (a!='n') -> (a) */ return expr_alloc_symbol (sym1);if ((e1->type ==E_SYMBOL && e2->type ==E_UNEQUAL && e2->right.sym == &symbol_mod) || (e2->type ==E_SYMBOL && e1->type ==E_UNEQUAL && e1->right.sym == &symbol_mod)) -// (a) && (a!='m') -> (a='y') +/* (a) && (a!='m') -> (a='y') */ return expr_alloc_comp (E_EQUAL , sym1, &symbol_yes);if (sym1->type ==S_TRISTATE ) {if (e1->type ==E_EQUAL && e2->type ==E_UNEQUAL ) { -// (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' +/* (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' */ sym2 = e1->right.sym;if ((e2->right.sym->flags &SYMBOL_CONST ) && (sym2->flags &SYMBOL_CONST ))return sym2 != e2->right.sym ?expr_alloc_comp (E_EQUAL , sym1, sym2) :expr_alloc_symbol (&symbol_no); }if (e1->type ==E_UNEQUAL && e2->type ==E_EQUAL ) { -// (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' +/* (a!='b') && (a='c') -> 'b'='c' ? 'n' : a='c' */ sym2 = e2->right.sym;if ((e1->right.sym->flags &SYMBOL_CONST ) && (sym2->flags &SYMBOL_CONST )) return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
@@ -469,19 +469,19 @@ static struct expr *expr_join_and(struct expr *e1, struct expr *e2)if (e1->type ==E_UNEQUAL && e2->type ==E_UNEQUAL && ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) -// (a!='y') && (a!='n') -> (a='m') +/* (a!='y') && (a!='n') -> (a='m') */ return expr_alloc_comp (E_EQUAL , sym1, &symbol_mod);if (e1->type ==E_UNEQUAL && e2->type ==E_UNEQUAL && ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) -// (a!='y') && (a!='m') -> (a='n') +/* (a!='y') && (a!='m') -> (a='n') */ return expr_alloc_comp (E_EQUAL , sym1, &symbol_no);if (e1->type ==E_UNEQUAL && e2->type ==E_UNEQUAL && ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) -// (a!='m') && (a!='n') -> (a='m') +/* (a!='m') && (a!='n') -> (a='y') */ return expr_alloc_comp (E_EQUAL , sym1, &symbol_yes); if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) ||
@@ -641,7 +641,7 @@ struct expr *expr_transform(struct expr *e)case E_NOT :switch (e->left.expr->type) {case E_NOT : -// !!a -> a +/* !!a -> a */ tmp = e->left.expr->left.expr;free (e->left.expr);free (e);
@@ -650,14 +650,14 @@ struct expr *expr_transform(struct expr *e)break ;case E_EQUAL :case E_UNEQUAL : -// !a='x' -> a!='x' +/* !a='x' -> a!='x' */ tmp = e->left.expr;free (e); e = tmp; e->type = e->type ==E_EQUAL ?E_UNEQUAL :E_EQUAL ;break ;case E_OR : -// !(a || b) -> !a && !b +/* !(a || b) -> !a && !b */ tmp = e->left.expr; e->type =E_AND ; e->right.expr =expr_alloc_one (E_NOT , tmp->right.expr);
@@ -666,7 +666,7 @@ struct expr *expr_transform(struct expr *e) e =expr_transform (e);break ;case E_AND : -// !(a && b) -> !a || !b +/* !(a && b) -> !a || !b */ tmp = e->left.expr; e->type =E_OR ; e->right.expr =expr_alloc_one (E_NOT , tmp->right.expr);
@@ -676,7 +676,7 @@ struct expr *expr_transform(struct expr *e)break ;case E_SYMBOL :if (e->left.expr->left.sym == &symbol_yes) { -// !'y' -> 'n' +/* !'y' -> 'n' */ tmp = e->left.expr;free (e); e = tmp;
@@ -685,7 +685,7 @@ struct expr *expr_transform(struct expr *e)break ; }if (e->left.expr->left.sym == &symbol_mod) { -// !'m' -> 'm' +/* !'m' -> 'm' */ tmp = e->left.expr;free (e); e = tmp;
@@ -694,7 +694,7 @@ struct expr *expr_transform(struct expr *e)break ; }if (e->left.expr->left.sym == &symbol_no) { -// !'n' -> 'y' +/* !'n' -> 'y' */ tmp = e->left.expr;free (e); e = tmp;
Signature · 1 line
1.8.5.5
Re: [PATCH v2 2/2] kconfig: trivial - adjust comments
Hi Martin,
I haven't yet dared to review 1/2, which is the interesting change. So I cheated and skipped to 2/2.
Quoted 1 line · Martin Walch
Replace any C99 comments with traditional ones (/*...*/).
Perhaps you could split those changes off in a separate, trivial patch.
Quoted 9 lines
Also fix the contents of two comments:
1) the second occurrence of
(a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b'
is probably copy & paste from above, missing the adjustment corresponding to the code.
It should probably read
(a!='b') && (a='c') -> 'b'='c' ? 'n' : a='c'
Quoted 4 lines
2) that one is similar:
(a!='m') && (a!='n') -> (a='m')
it should be
(a!='m') && (a!='n') -> (a='y')
And perhaps even send these two changes as two separate patches. Not sure, as I don't review much, but it should make it easier to review.
Quoted 9 lines
Signed-off-by Martin Walch <[email protected]>--- scripts/kconfig/expr.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)scripts/kconfig/expr.c +0
-0
scripts/kconfig/expr.c static struct expr *expr_join_and(struct expr *e1, struct expr *e2) · line 456
Quoted 5 lines
scripts/kconfig/expr.c +1
-1if (sym1->type ==S_TRISTATE ) {if (e1->type ==E_EQUAL && e2->type ==E_UNEQUAL ) { -// (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' +/* (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' */
Could you make this match the code? Ie,
/* (a='b') && (a!='c') -> 'b'!='c' ? a='b' : 'n' */
if I'm reading the code right.
scripts/kconfig/expr.c static struct expr *expr_join_and(struct expr *e1, struct expr *e2) · line 463
Quoted 8 lines
scripts/kconfig/expr.c +1
-1sym2 = e1->right.sym;if ((e2->right.sym->flags &SYMBOL_CONST ) && (sym2->flags &SYMBOL_CONST ))return sym2 != e2->right.sym ?expr_alloc_comp (E_EQUAL , sym1, sym2) :expr_alloc_symbol (&symbol_no); }if (e1->type ==E_UNEQUAL && e2->type ==E_EQUAL ) { -// (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' +/* (a!='b') && (a='c') -> 'b'='c' ? 'n' : a='c' */
Likewise:
/* (a!='b') && (a='c') -> 'b'!='c' ? a='c' : 'n' */
scripts/kconfig/expr.c static struct expr *expr_join_and(struct expr *e1, struct expr *e2) · line 466
Quoted 3 lines
scripts/kconfig/expr.c +0
-0sym2 = e2->right.sym;if ((e1->right.sym->flags &SYMBOL_CONST ) && (sym2->flags &SYMBOL_CONST )) return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2)
(You could also make the code match the comments. But that would make the patch less trivial.)
Paul Bolle