summaryrefslogtreecommitdiffstats
path: root/devel/coccinelle/ref-passed-variables-inited.cocci
blob: 0d19ff756daf0f65394517a8d307f6870045ba4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright 2019-2020 the Pacemaker project contributors
 *
 * The version control history for this file may have further details.
 *
 * This source code is licensed under the GNU General Public License version 2
 * or later (GPLv2+) WITHOUT ANY WARRANTY.
 *
 *
 * We require each local variable that
 *
 * - is passed to a function through a dereference (suggesting it serves
 *   possibly also or merely as one of the output value propagators seperate
 *   from actual return value if employed at all) and
 *
 * - is then subsequently reused (possibly naively expecting it will always
 *   have been initialized (in said function at latest) further in its scope,
 *
 * to _always_ be assuredly initialized to some determined value, so as to
 * prevent a risk of accidentally accessing unspecified value subsequent
 * to the return from the considered function, which might not have set
 * that variable at all, lest it would touch it at all.
 */

virtual internal

@ref_passed_variables_inited exists@
identifier f_init, f_consume, var;
type T;
expression E, E_propagate;
@@

  T
- var
+ var /*FIXME:initialize me*/
  ;
  ... when != var = E
  f_init(..., &var, ...)
  ... when != var = E
(
  return var;
|
  f_consume(..., var, ...)
|
  E_propagate = var
|
  &var
|
  *var
)