Skip to contentSkip to conversation

c99ism in latest linus -bk

PATCH In review Andrew Morton 4 participants 7 messages Jan 15, 2005 – Jan 17, 2005

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

net/sched/cls_api.c: In function `tcf_exts_validate':
net/sched/cls_api.c:489: parse error before int' net/sched/cls_api.c:493: act' undeclared (first use in this function) net/sched/cls_api.c:493: (Each undeclared identifier is reported only once net/sched/cls_api.c:493: for each function it appears in.) net/sched/cls_api.c:494: `err' undeclared (first use in this function)

Someone wanna fix that up please?

#1 lore raw

PATCH 1/1 PKT_SCHED: remove c99ism

* Andrew Morton <[email protected]> 2005-01-15 14:40

Quoted 6 lines

net/sched/cls_api.c: In function `tcf_exts_validate':
net/sched/cls_api.c:489: parse error before int' net/sched/cls_api.c:493: act' undeclared (first use in this function) net/sched/cls_api.c:493: (Each undeclared identifier is reported only once net/sched/cls_api.c:493: for each function it appears in.) net/sched/cls_api.c:494: `err' undeclared (first use in this function)

net/sched/cls_api.c +4 -3
@@ -486,10 +486,9 @@
 	memset(exts, 0, sizeof(*exts));
 	
 #ifdef CONFIG_NET_CLS_ACT
-	int err;
-	struct tc_action *act;
-
 	if (map->police && tb[map->police-1]) {
+		int err;
+		struct tc_action *act;
 		act = tcf_action_init_1(tb[map->police-1], rate_tlv, "police",
 			TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
 		if (act == NULL)
@@ -498,6 +497,8 @@
 		act->type = TCA_OLD_COMPAT;
 		exts->action = act;
 	} else if (map->action && tb[map->action-1]) {
+		int err;
+		struct tc_action *act;
 		act = tcf_action_init(tb[map->action-1], rate_tlv, NULL,
 			TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
 		if (act == NULL)
#2 lore raw

Re: [PATCH] PKT_SCHED: remove c99ism

Quoted 12 lines · Thomas Graf

#ifdef CONFIG_NET_CLS_ACT
- int err;
- struct tc_action *act;
-
if (map->police && tb[map->police-1]) {
+ int err;
+ struct tc_action *act;
act = tcf_action_init_1(tb[map->police-1], rate_tlv, "police",
TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
if (act == NULL)
@@ -498,6 +497,8 @@

Quoted 8 lines

act->type = TCA_OLD_COMPAT;
exts->action = act;
} else if (map->action && tb[map->action-1]) {
+ int err;
+ struct tc_action *act;
act = tcf_action_init(tb[map->action-1], rate_tlv, NULL,
TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
if (act == NULL)

yes, that's the obvious one, but it uses a little more stack space.

An uglier but more efficient approach is to whack braces around the whole thing.

#3 lore raw

PATCH 1/1 PKT_SCHED: remove c99ism

* Andrew Morton <[email protected]> 2005-01-15 15:32

Quoted 2 lines

An uglier but more efficient approach is to whack braces around the whole thing.

Fine with me as well. The code isn't used that often and not deep in the calling stack which is why I preferred the cleaner way first.

net/sched/cls_api.c +18 -16
@@ -486,24 +486,26 @@
 	memset(exts, 0, sizeof(*exts));
 	
 #ifdef CONFIG_NET_CLS_ACT
-	int err;
-	struct tc_action *act;
+	{
+		int err;
+		struct tc_action *act;
 
-	if (map->police && tb[map->police-1]) {
-		act = tcf_action_init_1(tb[map->police-1], rate_tlv, "police",
-			TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
-		if (act == NULL)
-			return err;
-
-		act->type = TCA_OLD_COMPAT;
-		exts->action = act;
-	} else if (map->action && tb[map->action-1]) {
-		act = tcf_action_init(tb[map->action-1], rate_tlv, NULL,
-			TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
-		if (act == NULL)
-			return err;
+		if (map->police && tb[map->police-1]) {
+			act = tcf_action_init_1(tb[map->police-1], rate_tlv, "police",
+				TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
+			if (act == NULL)
+				return err;
+
+			act->type = TCA_OLD_COMPAT;
+			exts->action = act;
+		} else if (map->action && tb[map->action-1]) {
+			act = tcf_action_init(tb[map->action-1], rate_tlv, NULL,
+				TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
+			if (act == NULL)
+				return err;
 
-		exts->action = act;
+			exts->action = act;
+		}
 	}
 #elif defined CONFIG_NET_CLS_POLICE
 	if (map->police && tb[map->police-1]) {
#4 lore raw

Re: [PATCH] PKT_SCHED: remove c99ism

Quoted 6 lines · Thomas Graf

* Andrew Morton <[email protected]> 2005-01-15 15:32

Quoted 2 lines

An uglier but more efficient approach is to whack braces around the whole thing.

Fine with me as well. The code isn't used that often and not deep in the calling stack which is why I preferred the cleaner way first.

hmm, please remind me why putting some

#ifdef CONFIG_NET_CLS_ACT
	int err;
	struct tc_action *act;

#endif

at the _beginning_ of that procedure would
be a bad choice?

TIA,
Herbert

Quoted 48 lines
net/sched/cls_api.c +18 -16
@@ -486,24 +486,26 @@
 	memset(exts, 0, sizeof(*exts));
 
 #ifdef CONFIG_NET_CLS_ACT
-	int err;
-	struct tc_action *act;
+	{
+		int err;
+		struct tc_action *act;
 
-	if (map->police && tb[map->police-1]) {
-		act = tcf_action_init_1(tb[map->police-1], rate_tlv, "police",
-			TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
-		if (act == NULL)
-			return err;
-
-		act->type = TCA_OLD_COMPAT;
-		exts->action = act;
-	} else if (map->action && tb[map->action-1]) {
-		act = tcf_action_init(tb[map->action-1], rate_tlv, NULL,
-			TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
-		if (act == NULL)
-			return err;
+		if (map->police && tb[map->police-1]) {
+			act = tcf_action_init_1(tb[map->police-1], rate_tlv, "police",
+				TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
+			if (act == NULL)
+				return err;
+
+			act->type = TCA_OLD_COMPAT;
+			exts->action = act;
+		} else if (map->action && tb[map->action-1]) {
+			act = tcf_action_init(tb[map->action-1], rate_tlv, NULL,
+				TCA_ACT_NOREPLACE, TCA_ACT_BIND, &err);
+			if (act == NULL)
+				return err;
 
-		exts->action = act;
+			exts->action = act;
+		}
 	}
 #elif defined CONFIG_NET_CLS_POLICE
 	if (map->police && tb[map->police-1]) {
#5 lore raw

Re: [PATCH] PKT_SCHED: remove c99ism

* Herbert Poetzl <[email protected]> 2005-01-17 10:09

Quoted 10 lines · Thomas Graf
Quoted 6 lines

* Andrew Morton <[email protected]> 2005-01-15 15:32

Quoted 2 lines

An uglier but more efficient approach is to whack braces around the whole thing.

Fine with me as well. The code isn't used that often and not deep in the calling stack which is why I preferred the cleaner way first.

hmm, please remind me why putting some

Quoted 7 lines
#ifdef CONFIG_NET_CLS_ACT
	int err;
	struct tc_action *act;

#endif

at the _beginning_ of that procedure would
be a bad choice?

I personally don't think it's a bad choice but the less ifdefs the better. 2 out of 3 of my latest bugs were related to such ifdefs because testing gets more error prone. Personally I think the cleanest way would be to create inlined functions together with a nop macro but it would hide the mutual exclusiveness of NET_CLS_ACT and NET_CLS_POLICE in this case which is even worse.

maintainer Applied
#6 lore raw

Re: [PATCH] PKT_SCHED: remove c99ism

In reply to Thomas Graf
Quoted 8 lines · On Sun, 16 Jan 2005 00:40:56 +0100 Thomas Graf <[email protected]> wrote:

* Andrew Morton <[email protected]> 2005-01-15 15:32

Quoted 2 lines

An uglier but more efficient approach is to whack braces around the whole thing.

Fine with me as well. The code isn't used that often and not deep in the calling stack which is why I preferred the cleaner way first.

Applied, thanks Thomas.