Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/devel/Makefile.am b/devel/Makefile.am
index 979d021c03..42f21be75e 100644
--- a/devel/Makefile.am
+++ b/devel/Makefile.am
@@ -1,47 +1,53 @@
#
# 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.
#
-EXTRA_SCRIPTS = coccinelle/test/_testrunner.sh
+EXTRA_SCRIPTS = coccinelle/test/testrunner.sh
EXTRA_DIST = $(EXTRA_SCRIPTS) \
coccinelle/ref-passed-variables-inited.cocci \
- coccinelle/test/ref-passed-variables-inited.c
+ coccinelle/test/ref-passed-variables-inited.input.c \
+ coccinelle/test/ref-passed-variables-inited.output
# Coccinelle is a tool that takes special patch-like files (called semantic patches) and
# applies them throughout a source tree. This is useful when refactoring, changing APIs,
# catching dangerous or incorrect code, and other similar tasks. It's not especially
# easy to write a semantic patch but most users should only be concerned about running
# the target and inspecting the results.
#
# Documentation (including examples, which are the most useful):
# http://coccinelle.lip6.fr/documentation.php
#
# Run the "make cocci" target to just output what would be done, or "make cocci-inplace"
# to apply the changes to the source tree.
#
# COCCI_FILES may be set on the command line, if you want to test just a single file
# while it's under development. Otherwise, it is a list of all the files that are ready
# to be run.
#
# ref-passed-variables-inited.cocci seems to be returning some false positives around
# GHashTableIters, so it is disabled for the moment.
COCCI_FILES ?=
cocci:
for f in $(COCCI_FILES); do \
for d in daemons include lib tools; do \
test $$d = "include" \
&& spatch $(_SPATCH_FLAGS) --include-headers --local-includes \
--preprocess --sp-file $$f --dir ../$$d \
|| spatch $(_SPATCH_FLAGS) --local-includes \
--preprocess --sp-file $$f --dir ../$$d; \
done; \
done
cocci-inplace:
$(MAKE) $(AM_MAKEFLAGS) _SPATCH_FLAGS=--in-place cocci
+
+cocci-test:
+ for f in coccinelle/test/*.c; do \
+ coccinelle/test/testrunner.sh $$f; \
+ done
diff --git a/devel/coccinelle/test/_testrunner.sh b/devel/coccinelle/test/_testrunner.sh
deleted file mode 100755
index ee272c98b3..0000000000
--- a/devel/coccinelle/test/_testrunner.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env sh
-set -eu
-exec <&-
-_tmpdir=$(mktemp -d /tmp/coccicheck-XXXXXX)
-_bname=$(basename "$1")
-_dname=$(dirname "$1")
-sed -n '/#if 00/{n;:l;/#else/q;p;n;bl;}' "$1"> "${_tmpdir}/exp"
-spatch --very-quiet --sp-file "${_dname}/../${_bname%.c}.cocci" "$1" \
- | tail -n+3 > "${_tmpdir}/out"
-diff -u "${_tmpdir}/exp" "${_tmpdir}/out"
-rm "${_tmpdir}"/*
-rmdir "${_tmpdir}"
diff --git a/devel/coccinelle/test/ref-passed-variables-inited.c b/devel/coccinelle/test/ref-passed-variables-inited.c
deleted file mode 100755
index 476e1a6c36..0000000000
--- a/devel/coccinelle/test/ref-passed-variables-inited.c
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/sh
-#if 0
-./$(dirname "$0")/_testrunner.sh "$0" <<EOF
-#endif
-
-#if 00
-@@ -96,19 +96,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);
-@@ -118,37 +118,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;
- }
-@@ -166,7 +166,7 @@ void not1(void) {
-
- /* XXX false positive */
- void not2(void) {
-- int i;
-+ int i/*FIXME:initialize me*/;
- foo(&i);
- *(&i) = 2;
- }
-#else
-
-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;
-}
-#endif
-
-#if 0
-EOF
-#endif
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 0000000000..9ddb626fd1
--- /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 0000000000..c7a9f91fed
--- /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 0000000000..07e47952de
--- /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

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 8, 6:30 PM (11 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2002667
Default Alt Text
(8 KB)

Event Timeline