From 41a0e658a2db1c95bb9ca9ad7dc55a3d7d57e8a4 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Sat, 14 Nov 2009 12:45:45 -0500 Subject: Minor cleanups --- .gitignore | 2 ++ README | 12 +++++++----- pyarg-parsetuple.cocci | 7 +++---- 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 .gitignore 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 @ @@ -- cgit