Skip to contentSkip to conversation

backports: improve MTU spatch

PATCH In review Johannes Berg 2 participants 2 messages Feb 7, 2017 – Feb 10, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backports: improve MTU spatch

From: Johannes Berg <[email protected]>

Improve the MTU spatch to
1) not handle arbitrary expressions, only constants - the one case where I found expressions can't actually just move it to a function, it won't compile
2) if min_mtu isn't set, assume 0

---
 patches/0073-netdevice-mtu-range.cocci | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
patches/0073-netdevice-mtu-range.cocci +29 -2
index 30276f950e10..d9fb3d7ab3fa 100644
@@ -3,6 +3,32 @@
 
 first_ops = 0
 
+@both@
+expression ndevexp;
+constant e1, e2;
+identifier func;
+position p;
+@@
+func(...) {
+	<+...
+	ndevexp->min_mtu = e1;
+	ndevexp->max_mtu@p = e2;
+	...+>
+}
+
+@@
+expression ndevexp;
+constant MAX;
+identifier func;
+position p != both.p;
+@@
+func(...) {
+	<+...
++	ndevexp->min_mtu = 0;
+	ndevexp->max_mtu@p = MAX;
+	...+>
+}
+
 @r@
 identifier OPS;
 position p;
@@ -32,7 +58,8 @@ if not(first_ops == ln):
   cocci.include_match(False)
 
 @r1 exists@
-expression ndevexp, e1, e2;
+expression ndevexp;
+constant e1, e2;
 identifier func;
 @@
 func(...) {
@@ -45,7 +72,7 @@ func(...) {
 }
 
 @r2@
-expression r1.e1,r1.e2;
+constant r1.e1,r1.e2;
 identifier r.OPS;
 @@
 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
Signature · 4 lines
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe backports" in
#1 lore raw
Quoted 10 lines · Johannes Berg

From: Johannes Berg <[email protected]>

Improve the MTU spatch to
1) not handle arbitrary expressions, only constants - the one case where I found expressions can't actually just move it to a function, it won't compile
2) if min_mtu isn't set, assume 0

---

Looks OK to me, though I'm still only starting to get used to coccinelle.

- Steve
--
To unsubscribe from this list: send the line "unsubscribe backports" in