summaryrefslogtreecommitdiffstats
path: root/devel/coccinelle/string-null-matches.cocci
blob: b5471f694d4c416ef080aa719d8b0b79076a355c (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * Copyright 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.
 *
 * Catch places where a string can either be NULL or can match some other
 * string.  In these cases, passing the right flag to pcmk__str_eq will get
 * the same result but without having to do the NULL comparison manually.
 */

virtual internal

@ string_null_matches_1 depends on internal @
expression E1, E2;
@@
- ((E1 == NULL) || crm_str_eq(E1, E2, TRUE))
+ pcmk__str_eq(E1, E2, pcmk__str_null_matches)

@ string_null_matches_2 depends on internal @
expression E1, E2;
@@
- ((E1 == NULL) || crm_str_eq(E2, E1, TRUE))
+ pcmk__str_eq(E1, E2, pcmk__str_null_matches)

@ string_null_matches_3 depends on internal @
expression E1, E2;
@@
- ((E1 == NULL) || safe_str_eq(E1, E2))
+ pcmk__str_eq(E1, E2, pcmk__str_null_matches|pcmk__str_casei)

@ string_null_matches_4 depends on internal @
expression E1, E2;
@@
- ((E1 == NULL) || safe_str_eq(E2, E1))
+ pcmk__str_eq(E1, E2, pcmk__str_null_matches|pcmk__str_casei)

@ string_null_matches_5 depends on internal @
expression E1, E2;
@@
- ((E1 == NULL) || strcmp(E1, E2) == 0)
+ pcmk__str_eq(E1, E2, pcmk__str_null_matches)

@ string_null_matches_6 depends on internal @
expression E1, E2;
@@
- ((E1 == NULL) || strcmp(E2, E1) == 0)
+ pcmk__str_eq(E1, E2, pcmk__str_null_matches)

@ string_null_matches_7 depends on internal @
expression E1, E2;
@@
- ((E1 == NULL) || !strcmp(E1, E2))
+ pcmk__str_eq(E1, E2, pcmk__str_null_matches)

@ string_null_matches_8 depends on internal @
expression E1, E2;
@@
- ((E1 == NULL) || !strcmp(E2, E1))
+ pcmk__str_eq(E1, E2, pcmk__str_null_matches)

@ string_null_matches_9 depends on internal @
expression E1, E2;
@@
- ((E1 != NULL) && strcmp(E1, E2) != 0)
+ !pcmk__str_eq(E1, E2, pcmk__str_null_matches)

@ string_null_matches_10 depends on internal @
expression E1, E2;
@@
- ((E1 != NULL) && strcmp(E2, E1) != 0)
+ !pcmk__str_eq(E1, E2, pcmk__str_null_matches)