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