backports: improve MTU spatch
authorJohannes Berg <johannes.berg@intel.com>
Tue, 7 Feb 2017 09:03:32 +0000 (10:03 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 7 Feb 2017 14:07:17 +0000 (15:07 +0100)
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

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
patches/0073-netdevice-mtu-range.cocci

index 30276f950e10032b05bd7dbc10b84c3fae113d45..d9fb3d7ab3fae8d29bf80606ec6568d34fa57523 100644 (file)
@@ -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)