Skip to contentSkip to conversation

ematch: Fix the matching of inverted containers (again).

PATCH In review Ignacy Gawędzki 3 participants 5 messages Oct 3, 2014 – Oct 5, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ematch: Fix the matching of inverted containers (again).

The result of a negated container has to be inverted before checking for early ending.

---
 net/sched/ematch.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
net/sched/ematch.c +5 -4
index ad57f44..300ecf6 100644
@@ -526,11 +526,12 @@ pop_stack:
 		match_idx = stack[--stackp];
 		cur_match = tcf_em_get_match(tree, match_idx);
 
-		if (tcf_em_early_end(cur_match, res)) {
-			if (tcf_em_is_inverted(cur_match))
-				res = !res;
+		if (tcf_em_is_inverted(cur_match))
+			res = !res;
+
+		if (tcf_em_early_end(cur_match, res))
 			goto pop_stack;
-		} else {
+		else {
 			match_idx++;
 			goto proceed;
 		}
Signature · 1 line
1.9.1
#1 lore raw

Hello.

Quoted 19 lines · Ignacy Gawędzki

The result of a negated container has to be inverted before checking for early ending.

---
  net/sched/ematch.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
net/sched/ematch.c +0 -3
index ad57f44..300ecf6 100644
@@ -526,11 +526,12 @@ pop_stack:
  		match_idx = stack[--stackp];
  		cur_match = tcf_em_get_match(tree, match_idx);
 
-		if (tcf_em_early_end(cur_match, res)) {
-			if (tcf_em_is_inverted(cur_match))
-				res = !res;

net/sched/ematch.c pop_stack: · line 537

Quoted 10 lines
net/sched/ematch.c +5 -1
+		if (tcf_em_is_inverted(cur_match))
+			res = !res;
+
+		if (tcf_em_early_end(cur_match, res))
  			goto pop_stack;
-		} else {
+		else {
  			match_idx++;
  			goto proceed;
  		}

The kernel style dictates that an *if* statement should have {} in all its
arms, if it has {} in at least one of the arms.

WBR, Sergei

#2 lore raw

On Fri, Oct 03, 2014 at 04:22:29PM +0400, thus spake Sergei Shtylyov:

Quoted 2 lines
   The kernel style dictates that an *if* statement should have {}

in all its arms, if it has {} in at least one of the arms.

Hi,

Thanks for your kind remark. Fixed patch follows.

Ignacy Gawędzki (1):
ematch: Fix early ending of inverted containers.

 net/sched/ematch.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 1/1 ematch: Fix early ending of inverted containers.

In reply to Sergei Shtylyov

The result of a negated container has to be inverted before checking for early ending.

This fixes my previous attempt (17c9c8232663a47f074b7452b9b034efda868ca7) to make inverted containers work correctly.

---
 net/sched/ematch.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/sched/ematch.c +3 -2
index ad57f44..f878fa1 100644
@@ -526,9 +526,10 @@ pop_stack:
 		match_idx = stack[--stackp];
 		cur_match = tcf_em_get_match(tree, match_idx);
 
+		if (tcf_em_is_inverted(cur_match))
+			res = !res;
+
 		if (tcf_em_early_end(cur_match, res)) {
-			if (tcf_em_is_inverted(cur_match))
-				res = !res;
 			goto pop_stack;
 		} else {
 			match_idx++;
Signature · 1 line
1.9.1
maintainer Applied
#4 lore raw

Re: [PATCH net v2 1/1] ematch: Fix early ending of inverted containers.

From: Ignacy Gawędzki <[email protected]>
Date: Fri, 3 Oct 2014 15:44:48 +0200

Quoted 7 lines

The result of a negated container has to be inverted before checking for early ending.

This fixes my previous attempt (17c9c8232663a47f074b7452b9b034efda868ca7) to make inverted containers work correctly.

Applied.