Patchworkβ Fix incorrect linearization of "x && y && z"

login
register
about
Submitter Daniel De Graaf
Date 2009-10-27 23:02:30
Message ID <4ae782bd.8602be0a.3a31.187a@mx.google.com>
Download mbox | patch
Permalink /patch/56198/
State New
Headers show

Comments

Daniel De Graaf - 2009-10-27 23:02:30
This fixes an incorrect assumption that results in && using shortcut
logic on the true branch instead of the false branch.

Signed-off-by: Daniel De Graaf <danieldegraaf@gmail.com>

---
 linearize.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
Christopher Li - 2009-10-28 22:48:43
On Tue, Oct 27, 2009 at 4:02 PM, Daniel De Graaf
<danieldegraaf@gmail.com> wrote:
> This fixes an incorrect assumption that results in && using shortcut
> logic on the true branch instead of the false branch.

Good catch. Thanks!
I applied it without the "else" line.

Chris

PS. I almost miss this email because it is send to "unlisted-recipients".
My patch tool catches it though.
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/linearize.c b/linearize.c
index 238ee5d..9247409 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1389,7 +1389,10 @@  static pseudo_t linearize_logical(struct entrypoint *ep, struct expression *expr
 
 	shortcut = alloc_const_expression(expr->pos, expr->op == SPECIAL_LOGICAL_OR);
 	shortcut->ctype = expr->ctype;
-	return  linearize_conditional(ep, expr, expr->left, shortcut, expr->right);
+	if (expr->op == SPECIAL_LOGICAL_OR)
+		return linearize_conditional(ep, expr, expr->left, shortcut, expr->right);
+	else
+		return linearize_conditional(ep, expr, expr->left, expr->right, shortcut);
 }
 
 static pseudo_t linearize_compare(struct entrypoint *ep, struct expression *expr)