Daniel Granat | 67afc21 | 2015-10-23 17:31:06 +0200 | [diff] [blame] | 1 | /// Make sure (of/i2c/platform)_device_id tables are NULL terminated |
Stephen Boyd | 2d5c5db | 2014-06-03 20:25:27 +0200 | [diff] [blame] | 2 | // |
Daniel Granat | 67afc21 | 2015-10-23 17:31:06 +0200 | [diff] [blame] | 3 | // Keywords: of_table i2c_table platform_table |
Stephen Boyd | 2d5c5db | 2014-06-03 20:25:27 +0200 | [diff] [blame] | 4 | // Confidence: Medium |
| 5 | // Options: --include-headers |
| 6 | |
| 7 | virtual patch |
| 8 | virtual context |
| 9 | virtual org |
| 10 | virtual report |
| 11 | |
| 12 | @depends on context@ |
| 13 | identifier var, arr; |
| 14 | expression E; |
| 15 | @@ |
Daniel Granat | 67afc21 | 2015-10-23 17:31:06 +0200 | [diff] [blame] | 16 | ( |
| 17 | struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { |
Stephen Boyd | 2d5c5db | 2014-06-03 20:25:27 +0200 | [diff] [blame] | 18 | ..., |
| 19 | { |
| 20 | .var = E, |
| 21 | * } |
| 22 | }; |
Daniel Granat | 67afc21 | 2015-10-23 17:31:06 +0200 | [diff] [blame] | 23 | | |
| 24 | struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { |
| 25 | ..., |
| 26 | * { ..., E, ... }, |
| 27 | }; |
| 28 | ) |
Stephen Boyd | 2d5c5db | 2014-06-03 20:25:27 +0200 | [diff] [blame] | 29 | |
| 30 | @depends on patch@ |
| 31 | identifier var, arr; |
| 32 | expression E; |
| 33 | @@ |
Daniel Granat | 67afc21 | 2015-10-23 17:31:06 +0200 | [diff] [blame] | 34 | ( |
| 35 | struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { |
Stephen Boyd | 2d5c5db | 2014-06-03 20:25:27 +0200 | [diff] [blame] | 36 | ..., |
| 37 | { |
| 38 | .var = E, |
| 39 | - } |
| 40 | + }, |
| 41 | + { } |
| 42 | }; |
Daniel Granat | 67afc21 | 2015-10-23 17:31:06 +0200 | [diff] [blame] | 43 | | |
| 44 | struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { |
| 45 | ..., |
| 46 | { ..., E, ... }, |
| 47 | + { }, |
| 48 | }; |
| 49 | ) |
Stephen Boyd | 2d5c5db | 2014-06-03 20:25:27 +0200 | [diff] [blame] | 50 | |
| 51 | @r depends on org || report@ |
| 52 | position p1; |
| 53 | identifier var, arr; |
| 54 | expression E; |
| 55 | @@ |
Daniel Granat | 67afc21 | 2015-10-23 17:31:06 +0200 | [diff] [blame] | 56 | ( |
| 57 | struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { |
Stephen Boyd | 2d5c5db | 2014-06-03 20:25:27 +0200 | [diff] [blame] | 58 | ..., |
| 59 | { |
| 60 | .var = E, |
| 61 | } |
| 62 | @p1 |
| 63 | }; |
Daniel Granat | 67afc21 | 2015-10-23 17:31:06 +0200 | [diff] [blame] | 64 | | |
| 65 | struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = { |
| 66 | ..., |
| 67 | { ..., E, ... } |
| 68 | @p1 |
| 69 | }; |
| 70 | ) |
Stephen Boyd | 2d5c5db | 2014-06-03 20:25:27 +0200 | [diff] [blame] | 71 | |
| 72 | @script:python depends on org@ |
| 73 | p1 << r.p1; |
| 74 | arr << r.arr; |
| 75 | @@ |
| 76 | |
| 77 | cocci.print_main(arr,p1) |
| 78 | |
| 79 | @script:python depends on report@ |
| 80 | p1 << r.p1; |
| 81 | arr << r.arr; |
| 82 | @@ |
| 83 | |
| 84 | msg = "%s is not NULL terminated at line %s" % (arr, p1[0].line) |
| 85 | coccilib.report.print_report(p1[0],msg) |