Skip to contentSkip to conversation

Add coccinelle script that makes sure that tables are NULL terminated

PATCH Superseded Daniel Granat 5 participants 18 messages Feb 27, 2015 – Oct 26, 2015 Coccinelle/Semantic Patches (SmPL)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add coccinelle script that makes sure that tables are NULL terminated

---
 scripts/coccinelle/misc/device_id_tables.cocci | 95 ++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 scripts/coccinelle/misc/device_id_tables.cocci
scripts/coccinelle/misc/device_id_tables.cocci new file +95 -0
new file mode 100644
index 0000000..5968984
@@ -0,0 +1,95 @@
+/// Make sure '*_device_id$' tables are NULL terminated
+//
+// Keywords: device_id
+// Confidence: Medium
+// Options: --include-headers
+
+virtual org
+virtual report
+virtual patch
+
+ at initialize:python@
+@@
+import re
+
+postfix = '_device_id$'
+prefix_list = ['platform', 'of', 'i2c']
+
+ at r1 depends on patch || org || report@
+position p1;
+identifier var, arr;
+identifier struct_name;
+expression E;
+@@
+
+(
+struct struct_name arr[] = {
+	...,
+	{
+	.var = E,
+	}
+	@p1
+};
+|
+struct struct_name arr[] = {
+	...,
+	{ ..., var, ... },
+	@p1
+};
+)
+
+ at script:python depends on report@
+struct_name << r1.struct_name;
+p1 << r1.p1;
+arr << r1.arr;
+pattern;
+@@
+
+for i in prefix_list:
+	pattern = str(i)+postfix
+        if re.match(pattern, struct_name) != None:
+		print "\nCOCCI: \"%s\" matchs required pattern \"%s\"" % (struct_name, pattern)
+		msg = "\"%s\" is not NULL terminated at line %s" % (arr, p1[0].line)
+        	coccilib.report.print_report(p1[0],msg)
+		break
+
+ at script:python match depends on patch@
+struct_name << r1.struct_name;
+matched_name;
+pattern;
+@@
+
+coccinelle.matched_name = ''
+
+for i in prefix_list:
+	pattern = str(i)+postfix
+	if re.match(pattern, struct_name) != None:
+		coccinelle.matched_name = struct_name
+		break
+
+ at r2 depends on patch@
+position r1.p1;
+identifier var, arr;
+identifier match.matched_name;
+expression E;
+@@
+
+(
+struct matched_name arr[] = { 
+        ...,
+        {
+        .var = E,
+-       }
+	@p1
++	},
++	{},
+};
+|
+struct matched_name arr[] = { 
+        ...,
+        { ..., var, ... },
+	@p1
++	{},
+};
+)
+
Signature · 1 line
1.9.1
#1 lore raw

Hi,

Could you please review my patch I sent last month? It checks if tables in kernel are NULL terminated. Script matches only names specified in source code by postfix='*_device_id$' and by list of prefixes which is now prefix_list = ['platform', 'of', 'i2c']. I think it could by useful in kernel sources.

Quoted 4 lines · Daniel Granat

<pre wrap>
Signed-off-by: Daniel Granat &lt;d.granat at samsung.com&gt;
---
scripts/coccinelle/misc/device_id_tables.cocci | 95

++++++++++++++++++++++++++

Review

Quoted 4 lines
1 file changed, 95 insertions(+)

create mode 100644 scripts/coccinelle/misc/device_id_tables.cocci

(quoted diff) +0 -0

b/scripts/coccinelle/misc/device_id_tables.cocci

Quoted 46 lines

new file mode 100644
index 0000000..5968984

scripts/coccinelle/misc/device_id_tables.cocci new file +41 -0
@@ -0,0 +1,95 @@
+/// Make sure '*_device_id$' tables are NULL terminated
+//
+// Keywords: device_id
+// Confidence: Medium
+// Options: --include-headers
+
+virtual org
+virtual report
+virtual patch
+
+ at initialize:python@
+@@
+import re
+
+postfix = '_device_id$'
+prefix_list = ['platform', 'of', 'i2c']
+
+ at r1 depends on patch || org || report@
+position p1;
+identifier var, arr;
+identifier struct_name;
+expression E;
+@@
+
+(
+struct struct_name arr[] = {
+ ...,
+ {
+ .var = E,
+ }
+ @p1
+};
+|
+struct struct_name arr[] = {
+ ...,
+ { ..., var, ... },
+ @p1
+};
+)
+
+ at script:python depends on report@

scripts/coccinelle/misc/device_id_tables.cocci line 51

Quoted 10 lines
scripts/coccinelle/misc/device_id_tables.cocci new file +10 -0
+struct_name &lt;&lt; r1.struct_name;
+p1 &lt;&lt; r1.p1;
+arr &lt;&lt; r1.arr;
+pattern;
+@@
+
+for i in prefix_list:
+ pattern = str(i)+postfix
+ if re.match(pattern, struct_name) != None:
+ print "\nCOCCI: \"%s\" matchs required pattern \"%s\"" % 

(struct_name, pattern)

Quoted 47 lines
scripts/coccinelle/misc/device_id_tables.cocci new file +44 -0
+ msg = "\"%s\" is not NULL terminated at line %s" % (arr, p1[0].line)
+ coccilib.report.print_report(p1[0],msg)
+ break
+
+ at script:python match depends on patch@
+struct_name &lt;&lt; r1.struct_name;
+matched_name;
+pattern;
+@@
+
+coccinelle.matched_name = ''
+
+for i in prefix_list:
+ pattern = str(i)+postfix
+ if re.match(pattern, struct_name) != None:
+ coccinelle.matched_name = struct_name
+ break
+
+ at r2 depends on patch@
+position r1.p1;
+identifier var, arr;
+identifier match.matched_name;
+expression E;
+@@
+
+(
+struct matched_name arr[] = {
+ ...,
+ {
+ .var = E,
+- }
+ @p1
++ },
++ {},
+};
+|
+struct matched_name arr[] = {
+ ...,
+ { ..., var, ... },
+ @p1
++ {},
+};
+)
+

</pre></body>
</html>
</html>

Tested-by on v1 1/1
#2 lore raw
In reply to Daniel Granat

W dniu 27.02.2015 o 22:21, Daniel Granat pisze:

Quoted 5 lines
---
  scripts/coccinelle/misc/device_id_tables.cocci | 95 ++++++++++++++++++++++++++
  1 file changed, 95 insertions(+)

create mode 100644 scripts/coccinelle/misc/device_id_tables.cocci

I like the idea and I think it is useful.

However applying the patch gave some warnings:

Applying: Add coccinelle script that makes sure that tables are NULL terminated /home/dev/linux/linux/.git/rebase-apply/patch:64: space before tab in indent.

        	coccilib.report.print_report(p1[0],msg)

/home/dev/linux/linux/.git/rebase-apply/patch:89: trailing whitespace. struct matched_name arr[] = { /home/dev/linux/linux/.git/rebase-apply/patch:99: trailing whitespace. struct matched_name arr[] = { /home/dev/linux/linux/.git/rebase-apply/patch:106: new blank line at EOF. +
warning: 4 lines add whitespace errors.

Best regards,
Krzysztof

#3 lore raw

Ok, but I'm going to improve the script. New coccinelle release give my opportunity to simplify this a lot, so I'll send next version of my patch soon.

Best regards,
--
Daniel Granat
Junior Software Engineer
Samsung R&D Institute Poland (SRPOL)
Al. Armii Ludowej 14, 00-638 Warszawa, Poland

Quoted 26 lines · Krzysztof Kozlowski

W dniu 27.02.2015 o 22:21, Daniel Granat pisze:

Quoted 5 lines
---
   scripts/coccinelle/misc/device_id_tables.cocci | 95 ++++++++++++++++++++++++++
   1 file changed, 95 insertions(+)

create mode 100644 scripts/coccinelle/misc/device_id_tables.cocci

I like the idea and I think it is useful.

However applying the patch gave some warnings:

Applying: Add coccinelle script that makes sure that tables are NULL terminated /home/dev/linux/linux/.git/rebase-apply/patch:64: space before tab in indent.

         	coccilib.report.print_report(p1[0],msg)

/home/dev/linux/linux/.git/rebase-apply/patch:89: trailing whitespace. struct matched_name arr[] = { /home/dev/linux/linux/.git/rebase-apply/patch:99: trailing whitespace. struct matched_name arr[] = { /home/dev/linux/linux/.git/rebase-apply/patch:106: new blank line at EOF. +
warning: 4 lines add whitespace errors.

Best regards,
Krzysztof

#4 lore raw

PATCH v2 1/1 Add coccinelle script that makes sure that tables are NULL terminated

In reply to Daniel Granat
---
 scripts/coccinelle/misc/of_platform.cocci | 65 +++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 scripts/coccinelle/misc/of_platform.cocci
scripts/coccinelle/misc/of_platform.cocci new file +65 -0
new file mode 100644
index 0000000..02c6195
@@ -0,0 +1,65 @@
+/// Make sure that tables are NULL terminated
+//
+// Keywords: _device_id
+// Confidence: Medium
+// Options: --include-headers
+
+virtual report
+virtual patch
+
+ at r depends on report@
+position p1;
+identifier var, arr;
+identifier name = {of_device_id, i2c_device_id, platform_device_id};
+expression E;
+@@
+
+(
+struct name arr[] = {
+	...,
+	{
+	.var = E,
+	}
+	@p1
+};
+|
+struct name arr[] = {
+	...,
+	{ ..., var, ... },
+	@p1
+};
+)
+
+ at script:python depends on report@
+p1 << r.p1;
+arr << r.arr;
+@@
+
+msg = "%s is not NULL terminated at line %s" % (arr, p1[0].line)
+coccilib.report.print_report(p1[0],msg)
+
+@p depends on patch@
+position p1;
+identifier var, arr;
+identifier name = {of_device_id, i2c_device_id, platform_device_id};
+expression E;
+@@
+
+(
+struct name arr[] = {
+	...,
+	{
+	.var = E,
+-	}
+	@p1
++	},
++	{},
+};
+|
+struct name arr[] = {
+	...,
+	{ ..., var, ... },
+	@p1
++	{},
+};
+)
Signature · 1 line
1.9.1
#5 lore raw

There is already a rule misc/of_table.cocci for the of_device_id case. I think it would be better to extend that.

Also, rather than making an identifier name, it would be more efficient to put struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = ... The Coccinelle will only work on files that contain those identifiers.

julia

Quoted 81 lines · Daniel Granat
---
 scripts/coccinelle/misc/of_platform.cocci | 65 +++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 scripts/coccinelle/misc/of_platform.cocci
scripts/coccinelle/misc/of_platform.cocci new file +65 -1
new file mode 100644
index 0000000..02c6195
@@ -0,0 +1,65 @@
+/// Make sure that tables are NULL terminated
+//
+// Keywords: _device_id
+// Confidence: Medium
+// Options: --include-headers
+
+virtual report
+virtual patch
+
+ at r depends on report@
+position p1;
+identifier var, arr;
+identifier name = {of_device_id, i2c_device_id, platform_device_id};
+expression E;
+@@
+
+(
+struct name arr[] = {
+	...,
+	{
+	.var = E,
+	}
+	@p1
+};
+|
+struct name arr[] = {
+	...,
+	{ ..., var, ... },
+	@p1
+};
+)
+
+ at script:python depends on report@
+p1 << r.p1;
+arr << r.arr;
+@@
+
+msg = "%s is not NULL terminated at line %s" % (arr, p1[0].line)
+coccilib.report.print_report(p1[0],msg)
+
+ at p depends on patch@
+position p1;
+identifier var, arr;
+identifier name = {of_device_id, i2c_device_id, platform_device_id};
+expression E;
+@@
+
+(
+struct name arr[] = {
+	...,
+	{
+	.var = E,
+-	}
+	@p1
++	},
++	{},
+};
+|
+struct name arr[] = {
+	...,
+	{ ..., var, ... },
+	@p1
++	{},
+};
+)
--

1.9.1

#6 lore raw

PATCH v3 1/1 Added tables i2c_device_id and platform_device_id for checking. Extend checking on tables containing structures which are initialized without specifying member name.

In reply to Daniel Granat
---
 scripts/coccinelle/misc/of_table.cocci | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +21 -5
index 3c93404..74f7dbb 100644
@@ -1,6 +1,6 @@
-/// Make sure of_device_id tables are NULL terminated
+/// Make sure (of_device_id | i2c_device_id | platform_device_id) tables are NULL terminated
 //
-// Keywords: of_table
+// Keywords: of_table i2c_table platform_table
 // Confidence: Medium
 // Options: --include-headers
 
@@ -13,7 +13,7 @@ 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,
@@ -24,7 +24,8 @@ struct of_device_id arr[] = {
 identifier var, arr;
 expression E;
 @@
-struct of_device_id arr[] = {
+(
+struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
 	...,
 	{
 	.var = E,
@@ -32,19 +33,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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;
Signature · 1 line
1.9.1
#7 lore raw

Re: [PATCH v3] Added tables i2c_device_id and platform_device_id for checking. Extend checking on tables containing structures which are initialized without specifying member name.

Quoted 19 lines · Daniel Granat
---
 scripts/coccinelle/misc/of_table.cocci | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +2 -2
index 3c93404..74f7dbb 100644
@@ -1,6 +1,6 @@
-/// Make sure of_device_id tables are NULL terminated
+/// Make sure (of_device_id | i2c_device_id | platform_device_id) tables are NULL terminated
 //
-// Keywords: of_table
+// Keywords: of_table i2c_table platform_table
 // Confidence: Medium
 // Options: --include-headers
 

scripts/coccinelle/misc/of_table.cocci virtual report · line 19

Quoted 8 lines
scripts/coccinelle/misc/of_table.cocci +1 -1
@@ -13,7 +13,7 @@ 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,

This case (the context case) needs a ..., E, ... case like the patch rule has.

Quoted 31 lines
scripts/coccinelle/misc/of_table.cocci +11 -2
@@ -24,7 +24,8 @@ struct of_device_id arr[] = {
 identifier var, arr;
 expression E;
 @@
-struct of_device_id arr[] = {
+(
+struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
 	...,
 	{
 	.var = E,
@@ -32,19 +33,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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[] = {
 	...,

scripts/coccinelle/misc/of_table.cocci struct of_device_id arr[] = { · line 61

Quoted 10 lines
scripts/coccinelle/misc/of_table.cocci +5 -0
 	{
 	.var = E,
 	}
 	@p1
 };
+|
+struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
+	...,
+	{ ..., E, ... },
+	@p1

It is not a good idea to put the @p1 on the comma. The comma might not be there, and if it is not there Coccinelle seems to crash. A more graceful behavior would be for the rule simply not to match, since a comma that isn't there doesn't have a position. In any case, if you put the @p1 on the }, things are better.

I made the following test case, if you want to make a quick check of the rule. All four options should give four results.

 static const struct platform_device_id ab85xx_rtc_ids[] = {
	{ "ab8500-rtc", (kernel_ulong_t)&ab8500_rtc_ops, },
	{ "ab8540-rtc", (kernel_ulong_t)&ab8540_rtc_ops, },
 };
 static const struct platform_device_id ab85xx_rtc_ids[] = {
	{ "ab8500-rtc", (kernel_ulong_t)&ab8500_rtc_ops, },
        { "ab8540-rtc", (kernel_ulong_t)&ab8540_rtc_ops, }
 };
 static const struct platform_device_id ab85xx_rtc_ids[] = {
	{ .a = "ab8500-rtc", .b = (kernel_ulong_t)&ab8500_rtc_ops, },
	{ .a = "ab8540-rtc", .b = (kernel_ulong_t)&ab8540_rtc_ops, },
 };
 static const struct platform_device_id ab85xx_rtc_ids[] = {
	{ .a = "ab8500-rtc", .b = (kernel_ulong_t)&ab8500_rtc_ops, },
        { .a = "ab8540-rtc", .b = (kernel_ulong_t)&ab8540_rtc_ops, }

};

julia

Quoted 9 lines
scripts/coccinelle/misc/of_table.cocci +2 -0
+};
+)
 
 @script:python depends on org@
 p1 << r.p1;
Signature · 1 line
1.9.1
#8 lore raw

PATCH v4 1/1 Added tables i2c_device_id and platform_device_id for

In reply to Daniel Granat

Thank you for advices. I submit new patch with changes you suggested but I don't know why in "context" rule I get only two results instead of four.

#9 lore raw

PATCH v4 1/1 Added tables i2c_device_id and platform_device_id for checking. Extend checking on tables containing structures which are initialized without specifying member name.

---
 scripts/coccinelle/misc/of_table.cocci | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +29 -5
index 3c93404..bc3c944 100644
@@ -1,6 +1,6 @@
-/// Make sure of_device_id tables are NULL terminated
+/// Make sure (of_device_id | i2c_device_id | platform_device_id) tables are NULL terminated
 //
-// Keywords: of_table
+// Keywords: of_table i2c_table platform_table
 // Confidence: Medium
 // Options: --include-headers
 
@@ -13,18 +13,27 @@ 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,
@@ -32,19 +41,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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;
Signature · 1 line
1.9.1
#10 lore raw

Re: [PATCH v4] Added tables i2c_device_id and platform_device_id for checking. Extend checking on tables containing structures which are initialized without specifying member name.

scripts/coccinelle/misc/of_table.cocci line 1

Quoted 12 lines · Daniel Granat
---
 scripts/coccinelle/misc/of_table.cocci | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +1 -1
index 3c93404..bc3c944 100644
@@ -1,6 +1,6 @@
-/// Make sure of_device_id tables are NULL terminated
+/// Make sure (of_device_id | i2c_device_id | platform_device_id) tables are NULL terminated

It would be nice for the comment to be limited to 80 characters.

Quoted 13 lines
scripts/coccinelle/misc/of_table.cocci +3 -2
 //
-// Keywords: of_table
+// Keywords: of_table i2c_table platform_table
 // Confidence: Medium
 // Options: --include-headers
 
@@ -13,18 +13,27 @@ virtual report
 identifier var, arr;
 expression E;
 @@
-struct of_device_id arr[] = {
+(
+struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {

scripts/coccinelle/misc/of_table.cocci virtual report · line 27

Quoted 10 lines
scripts/coccinelle/misc/of_table.cocci +5 -0
 	...,
 	{
 	.var = E,
 *	}
 };
+|
+struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
+	...,
+	{ ..., E, ... },
+*	{ },

This should be:

struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
        ...,

* { ..., E, ... },
};

With that you get four results for the context case, like for the others.

The rest looks OK.

julia

Quoted 53 lines
scripts/coccinelle/misc/of_table.cocci +20 -3
+};
+)
 
 @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,
@@ -32,19 +41,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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;
--

1.9.1

#11 lore raw

PATCH v5 1/1 Added tables (i2c/platform)_device_id for checking. Extend checking on tables containing structures which are initialized without specifying member name.

---
 scripts/coccinelle/misc/of_table.cocci | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +28 -5
index 3c93404..2294915 100644
@@ -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
 
@@ -13,18 +13,26 @@ 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,
@@ -32,19 +40,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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;
Signature · 1 line
1.9.1
#12 lore raw

Re: [PATCH v5] Added tables (i2c/platform)_device_id for checking. Extend checking on tables containing structures which are initialized without specifying member name.

2015-06-23 20:02 GMT+09:00 Daniel Granat <[email protected]>:

Quoted 1 line

Something went wrong. It looks like changelog was used as subject and the body disappeared.

Best regards,
Krzysztof

Acked-by on v5 1/1
#13 lore raw

Re: [PATCH v5] Added tables (i2c/platform)_device_id for checking. Extend checking on tables containing structures which are initialized without specifying member name.

In reply to Daniel Granat
Quoted 1 line · Daniel Granat
Quoted 86 lines
---
 scripts/coccinelle/misc/of_table.cocci | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +28 -6
index 3c93404..2294915 100644
@@ -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
 
@@ -13,18 +13,26 @@ 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,
@@ -32,19 +40,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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;
--

1.9.1

#14 lore raw

PATCH v6 1/1 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.

---
 scripts/coccinelle/misc/of_table.cocci | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +28 -5
index 3c93404..2294915 100644
@@ -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
 
@@ -13,18 +13,26 @@ 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,
@@ -32,19 +40,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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;
Signature · 1 line
1.9.1
#15 lore raw

PATCH v6 1/1 coccinelle: Improve checking for missing NULL terminators

In reply to Daniel Granat

* 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.

---
 scripts/coccinelle/misc/of_table.cocci | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +28 -5
index 3c93404..2294915 100644
@@ -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
 
@@ -13,18 +13,26 @@ 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,
@@ -32,19 +40,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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;
Signature · 1 line
1.9.1
Acked-by on v6 1/1
#16 lore raw

Re: [PATCH v6] coccinelle: Improve checking for missing NULL terminators

Quoted 91 lines · Daniel Granat

* 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.

---
 scripts/coccinelle/misc/of_table.cocci | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)
scripts/coccinelle/misc/of_table.cocci +28 -5
index 3c93404..2294915 100644
@@ -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
 
@@ -13,18 +13,26 @@ 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,
@@ -32,19 +40,34 @@ struct of_device_id arr[] = {
 +	},
 +	{ }
 };
+|
+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;
Signature · 1 line
1.9.1
#17 lore raw

Re: [PATCH v6] coccinelle: Improve checking for missing NULL terminators

Dne 23.10.2015 v 21:35 Julia Lawall napsal(a):

Quoted 9 lines
Quoted 5 lines · Daniel Granat

* 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.

Applied to kbuild.git#misc.

Michal