diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 06:53:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 06:53:20 +0000 |
commit | e5a812082ae033afb1eed82c0f2df3d0f6bdc93f (patch) | |
tree | a6716c9275b4b413f6c9194798b34b91affb3cc7 /devel/coccinelle/test | |
parent | Initial commit. (diff) | |
download | pacemaker-e5a812082ae033afb1eed82c0f2df3d0f6bdc93f.tar.xz pacemaker-e5a812082ae033afb1eed82c0f2df3d0f6bdc93f.zip |
Adding upstream version 2.1.6.upstream/2.1.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devel/coccinelle/test')
-rw-r--r-- | devel/coccinelle/test/ref-passed-variables-inited.input.c | 88 | ||||
-rw-r--r-- | devel/coccinelle/test/ref-passed-variables-inited.output | 76 | ||||
-rwxr-xr-x | devel/coccinelle/test/testrunner.sh | 13 |
3 files changed, 177 insertions, 0 deletions
diff --git a/devel/coccinelle/test/ref-passed-variables-inited.input.c b/devel/coccinelle/test/ref-passed-variables-inited.input.c new file mode 100644 index 0000000..9ddb626 --- /dev/null +++ b/devel/coccinelle/test/ref-passed-variables-inited.input.c @@ -0,0 +1,88 @@ +void foo(int *z) { + return: +} +void baz(int z) { + return; +} +void zob1(int **z) { + return; +} +void zob2(int ***z) { + return; +} + +void bar0(void) { + int i; + foo(&i); + baz(i); +} + +void bar1(void) { + int i; + foo(&i); + foo(&i); +} + +void bar2(void) { + int a = 1, b, c = 3; + foo(&a); + baz(a); + foo(&b); + baz(b); + foo(&c); + baz(c); +} + +void bar3(int *w) { + int i; + foo(&i); + *w = i; +} + +void bar4(int **w) { + int i; + foo(&i); + **w = *i; +} + +void bar5(int ***w) { + int *i; + zob(&i); + ***w = *i; +} + +void bar6(int ***w) { + int *i; + zob1(&i); + ***w = *i; +} + +void bar7(int ****w) { + int **i; + zob1(&i); + ****w = **i; +} + +int bar8(void) { + int i; + foo(&i); + return i; +} + +void not0(void) { + int i; + foo(&i); +} + +void not1(void) { + int i; + foo(&i); + i = 1; +} + +/* XXX false positive */ +void not2(void) { + int i; + foo(&i); + *(&i) = 2; +} diff --git a/devel/coccinelle/test/ref-passed-variables-inited.output b/devel/coccinelle/test/ref-passed-variables-inited.output new file mode 100644 index 0000000..c7a9f91 --- /dev/null +++ b/devel/coccinelle/test/ref-passed-variables-inited.output @@ -0,0 +1,76 @@ +@@ -12,19 +12,19 @@ void zob2(int ***z) { + } + + void bar0(void) { +- int i; ++ int i/*FIXME:initialize me*/; + foo(&i); + baz(i); + } + + void bar1(void) { +- int i; ++ int i/*FIXME:initialize me*/; + foo(&i); + foo(&i); + } + + void bar2(void) { +- int a = 1, b, c = 3; ++ int a = 1, b/*FIXME:initialize me*/, c = 3; + foo(&a); + baz(a); + foo(&b); +@@ -34,37 +34,37 @@ void bar2(void) { + } + + void bar3(int *w) { +- int i; ++ int i/*FIXME:initialize me*/; + foo(&i); + *w = i; + } + + void bar4(int **w) { +- int i; ++ int i/*FIXME:initialize me*/; + foo(&i); + **w = *i; + } + + void bar5(int ***w) { +- int *i; ++ int *i/*FIXME:initialize me*/; + zob(&i); + ***w = *i; + } + + void bar6(int ***w) { +- int *i; ++ int *i/*FIXME:initialize me*/; + zob1(&i); + ***w = *i; + } + + void bar7(int ****w) { +- int **i; ++ int **i/*FIXME:initialize me*/; + zob1(&i); + ****w = **i; + } + + int bar8(void) { +- int i; ++ int i/*FIXME:initialize me*/; + foo(&i); + return i; + } +@@ -82,7 +82,7 @@ void not1(void) { + + /* XXX false positive */ + void not2(void) { +- int i; ++ int i/*FIXME:initialize me*/; + foo(&i); + *(&i) = 2; + } diff --git a/devel/coccinelle/test/testrunner.sh b/devel/coccinelle/test/testrunner.sh new file mode 100755 index 0000000..07e4795 --- /dev/null +++ b/devel/coccinelle/test/testrunner.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -eu +_tmpdir=$(mktemp -d /tmp/coccicheck-XXXXXX) +_bname=$(basename "$1" .input.c) +_dname=$(dirname "$1") +spatch --very-quiet --sp-file "${_dname}/../${_bname}.cocci" "$1" \ + | tail -n+3 > "${_tmpdir}/out" +diff -u "${_dname}/${_bname}.output" "${_tmpdir}/out" + +if [ -d "${_tmpdir}" ]; then + rm "${_tmpdir}"/* + rmdir "${_tmpdir}" +fi |