Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

coccinelle: Improve checking for missing NULL terminators

Extend checking on tables containing structures which are initialized
without specifying member name. Added new tables for checking:
i2c_device_id and platform_device_id.

Signed-off-by: Daniel Granat <d.granat@samsung.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.cz>

authored by

Daniel Granat and committed by
Michal Marek
67afc211 4743775c

+28 -5
+28 -5
scripts/coccinelle/misc/of_table.cocci
··· 1 - /// Make sure of_device_id tables are NULL terminated 1 + /// Make sure (of/i2c/platform)_device_id tables are NULL terminated 2 2 // 3 - // Keywords: of_table 3 + // Keywords: of_table i2c_table platform_table 4 4 // Confidence: Medium 5 5 // Options: --include-headers 6 6 ··· 13 13 identifier var, arr; 14 14 expression E; 15 15 @@ 16 - struct of_device_id arr[] = { 16 + ( 17 + struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { 17 18 ..., 18 19 { 19 20 .var = E, 20 21 * } 21 22 }; 23 + | 24 + struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { 25 + ..., 26 + * { ..., E, ... }, 27 + }; 28 + ) 22 29 23 30 @depends on patch@ 24 31 identifier var, arr; 25 32 expression E; 26 33 @@ 27 - struct of_device_id arr[] = { 34 + ( 35 + struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { 28 36 ..., 29 37 { 30 38 .var = E, ··· 40 32 + }, 41 33 + { } 42 34 }; 35 + | 36 + struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { 37 + ..., 38 + { ..., E, ... }, 39 + + { }, 40 + }; 41 + ) 43 42 44 43 @r depends on org || report@ 45 44 position p1; 46 45 identifier var, arr; 47 46 expression E; 48 47 @@ 49 - struct of_device_id arr[] = { 48 + ( 49 + struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { 50 50 ..., 51 51 { 52 52 .var = E, 53 53 } 54 54 @p1 55 55 }; 56 + | 57 + struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { 58 + ..., 59 + { ..., E, ... } 60 + @p1 61 + }; 62 + ) 56 63 57 64 @script:python depends on org@ 58 65 p1 << r.p1;