Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /// Make sure (of/i2c/platform)_device_id tables are NULL terminated
0003 //
0004 // Keywords: of_table i2c_table platform_table
0005 // Confidence: Medium
0006 // Options: --include-headers
0007 
0008 virtual patch
0009 virtual context
0010 virtual org
0011 virtual report
0012 
0013 @depends on context@
0014 identifier var, arr;
0015 expression E;
0016 @@
0017 (
0018 struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
0019         ...,
0020         {
0021         .var = E,
0022 *       }
0023 };
0024 |
0025 struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
0026         ...,
0027 *       { ..., E, ... },
0028 };
0029 )
0030 
0031 @depends on patch@
0032 identifier var, arr;
0033 expression E;
0034 @@
0035 (
0036 struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
0037         ...,
0038         {
0039         .var = E,
0040 -       }
0041 +       },
0042 +       { }
0043 };
0044 |
0045 struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
0046         ...,
0047         { ..., E, ... },
0048 +       { },
0049 };
0050 )
0051 
0052 @r depends on org || report@
0053 position p1;
0054 identifier var, arr;
0055 expression E;
0056 @@
0057 (
0058 struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
0059         ...,
0060         {
0061         .var = E,
0062         }
0063         @p1
0064 };
0065 |
0066 struct \(of_device_id \| i2c_device_id \| platform_device_id\) arr[] = {
0067         ...,
0068         { ..., E, ... }
0069         @p1
0070 };
0071 )
0072 
0073 @script:python depends on org@
0074 p1 << r.p1;
0075 arr << r.arr;
0076 @@
0077 
0078 cocci.print_main(arr,p1)
0079 
0080 @script:python depends on report@
0081 p1 << r.p1;
0082 arr << r.arr;
0083 @@
0084 
0085 msg = "%s is not NULL terminated at line %s" % (arr, p1[0].line)
0086 coccilib.report.print_report(p1[0],msg)