summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2009-11-14 12:45:45 -0500
committerDavid Malcolm <dmalcolm@redhat.com>2009-11-14 12:45:45 -0500
commit41a0e658a2db1c95bb9ca9ad7dc55a3d7d57e8a4 (patch)
tree4ed04f29ac660f69ecd7dbd2a4a2d5fcff57e196
parent190351e18b307ae4fef728208fa973e2c8ffd018 (diff)
downloadcheck-cpython-41a0e658a2db1c95bb9ca9ad7dc55a3d7d57e8a4.tar.gz
check-cpython-41a0e658a2db1c95bb9ca9ad7dc55a3d7d57e8a4.tar.xz
check-cpython-41a0e658a2db1c95bb9ca9ad7dc55a3d7d57e8a4.zip
Minor cleanups
-rw-r--r--.gitignore2
-rw-r--r--README12
-rw-r--r--pyarg-parsetuple.cocci7
3 files changed, 12 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2f836aa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*~
+*.pyc
diff --git a/README b/README
index b3713db..aa837ce 100644
--- a/README
+++ b/README
@@ -16,9 +16,11 @@ buggy.c:13: Mismatching type of argument 1: expected "int *" but got "unsigned l
which correctly detects an issue seen in socket.htons() on 64bit big endian machines
-Similarly, it detects the deliberate bug here:
-spatch -sp_file pyarg-parsetuple.cocci ../python-svn/Modules/xxmodule.c
+Similarly, it detects the deliberate bug in xxmodule.c:
+[david@brick static-analysis]$ spatch -sp_file pyarg-parsetuple.cocci ../../python-svn/Modules/xxmodule.c
init_defs_builtins: /usr/share/coccinelle/standard.h
-HANDLING: ../python-svn/Modules/xxmodule.c
-TYPE: header ../python-svn/Modules/Python.h not found
-../python-svn/Modules/xxmodule.c:206: unknown format char: '#'
+HANDLING: ../../python-svn/Modules/xxmodule.c
+TYPE: header ../../python-svn/Modules/Python.h not found
+../../python-svn/Modules/xxmodule.c:207:xx_roj:unknown format char in "O#:roj": '#'
+[david@brick static-analysis]$ echo $?
+1
diff --git a/pyarg-parsetuple.cocci b/pyarg-parsetuple.cocci
index 111d91a..4195b5e 100644
--- a/pyarg-parsetuple.cocci
+++ b/pyarg-parsetuple.cocci
@@ -1,14 +1,13 @@
@initialize:python@
"""
-Analyze format strings, compare to vararg types actually passed
+Analyze format strings passed to variadic function, compare to vararg types actually passed
-FIXME: generalize this to varargs; can coccinelle do this?
+FIXME: generalize this to arbitrary number of varargs; how to express this in SmPL?
"""
import sys
sys.path.append('.')
from validate import validate_types
num_errors = 0
-
@ParseTuple_1@
position pos;
expression args;
@@ -29,7 +28,6 @@ t1 << ParseTuple_1.t1;
# For some reason, locations are coming as a 1-tuple containing a Location (from
# coccilibs.elems), rather than the location itself
# Hence we use p1[0], not p1
-
num_errors += validate_types(pos[0], fmt.expr, [t1])
@@ -79,6 +77,7 @@ t3 << ParseTuple_3.t3;
@@
num_errors += validate_types(pos[0], fmt.expr, [t1, t2, t3])
+# and so on... need to find a general way of doing this, rather than repeating for 4, 5, 6...
@script:python @
@@