Merge tag 'irqchip-fixes-5.11-1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / scripts / coccinelle / misc / uninitialized_var.cocci
1 // SPDX-License-Identifier: GPL-2.0-only
2 ///
3 /// Please, don't reintroduce uninitialized_var().
4 /// From Documentation/process/deprecated.rst:
5 ///  For any compiler warnings about uninitialized variables, just add
6 ///  an initializer. Using warning-silencing tricks is dangerous as it
7 ///  papers over real bugs (or can in the future), and suppresses unrelated
8 ///  compiler warnings (e.g. "unused variable"). If the compiler thinks it
9 ///  is uninitialized, either simply initialize the variable or make compiler
10 ///  changes. Keep in mind that in most cases, if an initialization is
11 ///  obviously redundant, the compiler's dead-store elimination pass will make
12 ///  sure there are no needless variable writes.
13 ///
14 // Confidence: High
15 // Copyright: (C) 2020 Denis Efremov ISPRAS
16 // Options: --no-includes --include-headers
17 //
18
19 virtual context
20 virtual report
21 virtual org
22
23 @r@
24 identifier var;
25 type T;
26 position p;
27 @@
28
29 (
30 * T var =@p var;
31 |
32 * T var =@p *(&(var));
33 |
34 * var =@p var
35 |
36 * var =@p *(&(var))
37 )
38
39 @script:python depends on report@
40 p << r.p;
41 @@
42
43 coccilib.report.print_report(p[0],
44   "WARNING this kind of initialization is deprecated (https://www.kernel.org/doc/html/latest/process/deprecated.html#uninitialized-var)")
45
46 @script:python depends on org@
47 p << r.p;
48 @@
49
50 coccilib.org.print_todo(p[0],
51   "WARNING this kind of initialization is deprecated (https://www.kernel.org/doc/html/latest/process/deprecated.html#uninitialized-var)")