~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/coccinelle/misc/struct_size.cocci

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/coccinelle/misc/struct_size.cocci (Architecture i386) and /scripts/coccinelle/misc/struct_size.cocci (Architecture m68k)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 ///                                                 2 ///
  3 /// Check for code that could use struct_size(      3 /// Check for code that could use struct_size().
  4 ///                                                 4 ///
  5 // Confidence: Medium                               5 // Confidence: Medium
  6 // Author: Jacob Keller <jacob.e.keller@intel.c      6 // Author: Jacob Keller <jacob.e.keller@intel.com>
  7 // Copyright: (C) 2023 Intel Corporation            7 // Copyright: (C) 2023 Intel Corporation
  8 // Options: --no-includes --include-headers         8 // Options: --no-includes --include-headers
  9                                                     9 
 10 virtual patch                                      10 virtual patch
 11 virtual context                                    11 virtual context
 12 virtual org                                        12 virtual org
 13 virtual report                                     13 virtual report
 14                                                    14 
 15 // the overflow Kunit tests have some code whi     15 // the overflow Kunit tests have some code which intentionally does not use
 16 // the macros, so we want to ignore this code      16 // the macros, so we want to ignore this code when reporting potential
 17 // issues.                                         17 // issues.
 18 @overflow_tests@                                   18 @overflow_tests@
 19 identifier f = overflow_size_helpers_test;         19 identifier f = overflow_size_helpers_test;
 20 @@                                                 20 @@
 21                                                    21 
 22 f                                                  22 f
 23                                                    23 
 24 //--------------------------------------------     24 //----------------------------------------------------------
 25 //  For context mode                               25 //  For context mode
 26 //--------------------------------------------     26 //----------------------------------------------------------
 27                                                    27 
 28 @depends on !overflow_tests && context@            28 @depends on !overflow_tests && context@
 29 expression E1, E2;                                 29 expression E1, E2;
 30 identifier m;                                      30 identifier m;
 31 @@                                                 31 @@
 32 (                                                  32 (
 33 * (sizeof(*E1) + (E2 * sizeof(*E1->m)))            33 * (sizeof(*E1) + (E2 * sizeof(*E1->m)))
 34 )                                                  34 )
 35                                                    35 
 36 //--------------------------------------------     36 //----------------------------------------------------------
 37 //  For patch mode                                 37 //  For patch mode
 38 //--------------------------------------------     38 //----------------------------------------------------------
 39                                                    39 
 40 @depends on !overflow_tests && patch@              40 @depends on !overflow_tests && patch@
 41 expression E1, E2;                                 41 expression E1, E2;
 42 identifier m;                                      42 identifier m;
 43 @@                                                 43 @@
 44 (                                                  44 (
 45 - (sizeof(*E1) + (E2 * sizeof(*E1->m)))            45 - (sizeof(*E1) + (E2 * sizeof(*E1->m)))
 46 + struct_size(E1, m, E2)                           46 + struct_size(E1, m, E2)
 47 )                                                  47 )
 48                                                    48 
 49 //--------------------------------------------     49 //----------------------------------------------------------
 50 //  For org and report mode                        50 //  For org and report mode
 51 //--------------------------------------------     51 //----------------------------------------------------------
 52                                                    52 
 53 @r depends on !overflow_tests && (org || repor     53 @r depends on !overflow_tests && (org || report)@
 54 expression E1, E2;                                 54 expression E1, E2;
 55 identifier m;                                      55 identifier m;
 56 position p;                                        56 position p;
 57 @@                                                 57 @@
 58 (                                                  58 (
 59  (sizeof(*E1)@p + (E2 * sizeof(*E1->m)))           59  (sizeof(*E1)@p + (E2 * sizeof(*E1->m)))
 60 )                                                  60 )
 61                                                    61 
 62 @script:python depends on org@                     62 @script:python depends on org@
 63 p << r.p;                                          63 p << r.p;
 64 @@                                                 64 @@
 65                                                    65 
 66 coccilib.org.print_todo(p[0], "WARNING should      66 coccilib.org.print_todo(p[0], "WARNING should use struct_size")
 67                                                    67 
 68 @script:python depends on report@                  68 @script:python depends on report@
 69 p << r.p;                                          69 p << r.p;
 70 @@                                                 70 @@
 71                                                    71 
 72 msg="WARNING: Use struct_size"                     72 msg="WARNING: Use struct_size"
 73 coccilib.report.print_report(p[0], msg)            73 coccilib.report.print_report(p[0], msg)
 74                                                    74 
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php