From 18b0643b67df1bd76ca901446925cacd4aa00cf4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Sat, 5 Apr 2014 06:49:16 +0000 Subject: [PATCH] backports: enhance 0001-netdev_ops.cocci with data structure specifics The 0001-netdev_ops.cocci is fine but is uses Expression which makes the interpretation loose. We can reduce the namespace of the change by using struct. We have to keep expression on the right hand side as that can even be macros. For a full example test coverage of this change see the test netdev-ops github tree and run: make test1 git checkout -f make test2 The benefits should be clear, we are *not* modifying data structures that have similar names. This increases accuracy and security of our changes. The added run time penalty however is 50 seconds since we had to use --recursive-includes. The time penatly is worth it for the accuracy provided and since we'll likley need this flag elsewhere for other rules. mcgrof@drvbp1 ~/backports (git::master)$ time \ ./gentree.py --clean --refresh \ /home/mcgrof/linux-next \ /home/mcgrof/build/next-20140311 Copy original source files ... Apply patches ... Modify Kconfig tree ... Rewrite Makefiles and Kconfig files ... Done! real 1m56.339s user 19m31.428s sys 0m50.100s 1 2.6.25 [ OK ] 2 2.6.26 [ OK ] 3 2.6.27 [ OK ] 4 2.6.28 [ OK ] 5 2.6.29 [ OK ] 6 2.6.30 [ OK ] 7 2.6.31 [ OK ] 8 2.6.32 [ OK ] 9 2.6.33 [ OK ] 10 2.6.34 [ OK ] 11 2.6.35 [ OK ] 12 2.6.36 [ OK ] 13 2.6.37 [ OK ] 14 2.6.38 [ OK ] 15 2.6.39 [ OK ] 16 3.0.101 [ OK ] 17 3.1.10 [ OK ] 18 3.2.54 [ OK ] 19 3.3.8 [ OK ] 20 3.4.79 [ OK ] 21 3.5.7 [ OK ] 22 3.6.11 [ OK ] 23 3.7.10 [ OK ] 24 3.8.13 [ OK ] 25 3.9.11 [ OK ] 26 3.10.29 [ OK ] 27 3.11.10 [ OK ] 28 3.12.10 [ OK ] 29 3.13.2 [ OK ] 30 3.14-rc1 [ OK ] [0] https://github.com/mcgrof/netdev-ops Cc: Peter Senna Cc: Julia Lawall Cc: Gilles Muller Signed-off-by: Luis R. Rodriguez --- lib/bpcoccinelle.py | 1 + .../collateral-evolutions/network/0001-netdev_ops.cocci | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/bpcoccinelle.py b/lib/bpcoccinelle.py index 37307d24eea4..a71f4258ce0a 100644 --- a/lib/bpcoccinelle.py +++ b/lib/bpcoccinelle.py @@ -32,6 +32,7 @@ class ExecutionErrorThread(CoccinelleError): def spatch(cocci_file, outdir, max_threads, thread_id, temp_dir, ret_q, extra_args=[]): cmd = ['spatch', '--sp-file', cocci_file, '--in-place', + '--recursive-includes', '--backup-suffix', '.cocci_backup', '--dir', '.'] if (max_threads > 1): diff --git a/patches/collateral-evolutions/network/0001-netdev_ops.cocci b/patches/collateral-evolutions/network/0001-netdev_ops.cocci index f3d2e63de9fe..7c3d03afba1c 100644 --- a/patches/collateral-evolutions/network/0001-netdev_ops.cocci +++ b/patches/collateral-evolutions/network/0001-netdev_ops.cocci @@ -1,6 +1,6 @@ @@ -expression dev; -expression ops; +struct net_device *dev; +struct net_device_ops ops; @@ --dev->netdev_ops = ops; -+netdev_attach_ops(dev, ops); +-dev->netdev_ops = &ops; ++netdev_attach_ops(dev, &ops); -- 2.30.2