Skip to content

Commit

Permalink
coccinelle: Improve checking for missing NULL terminators
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Granat authored and Michal Marek committed Oct 26, 2015
1 parent 4743775 commit 67afc21
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions scripts/coccinelle/misc/of_table.cocci
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Make sure of_device_id tables are NULL terminated
/// Make sure (of/i2c/platform)_device_id tables are NULL terminated
//
// Keywords: of_table
// Keywords: of_table i2c_table platform_table
// Confidence: Medium
// Options: --include-headers

Expand All @@ -13,38 +13,61 @@ virtual report
identifier var, arr;
expression E;
@@
struct of_device_id arr[] = {
(
struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
...,
{
.var = E,
* }
};
|
struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
...,
* { ..., E, ... },
};
)

@depends on patch@
identifier var, arr;
expression E;
@@
struct of_device_id arr[] = {
(
struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
...,
{
.var = E,
- }
+ },
+ { }
};
|
struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
...,
{ ..., E, ... },
+ { },
};
)

@r depends on org || report@
position p1;
identifier var, arr;
expression E;
@@
struct of_device_id arr[] = {
(
struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
...,
{
.var = E,
}
@p1
};
|
struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
...,
{ ..., E, ... }
@p1
};
)

@script:python depends on org@
p1 << r.p1;
Expand Down

0 comments on commit 67afc21

Please sign in to comment.