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
19virtual context
20virtual report
21virtual org
22
23@r@
24identifier var;
25type T;
26position 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@
40p << r.p;
41@@
42
43coccilib.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@
47p << r.p;
48@@
49
50coccilib.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)")
52