From a35aa12a916f0ba167b109e709538e4289141e58 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 13 Nov 2009 20:33:19 -0500 Subject: Add current_element to error messages --- README | 10 +++++++++- pyarg-parsetuple.cocci | 2 +- validate.py | 7 ++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README b/README index 0cd9087..b3713db 100644 --- a/README +++ b/README @@ -13,4 +13,12 @@ init_defs_builtins: /usr/share/coccinelle/standard.h HANDLING: buggy.c buggy.c:13: Mismatching type of argument 1: expected "int *" but got "unsigned long *" -which correctly detects an issue seen in socket.htons() on 64bit big endian machines \ No newline at end of file +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 +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: '#' diff --git a/pyarg-parsetuple.cocci b/pyarg-parsetuple.cocci index a33e678..111d91a 100644 --- a/pyarg-parsetuple.cocci +++ b/pyarg-parsetuple.cocci @@ -2,7 +2,7 @@ """ Analyze format strings, compare to vararg types actually passed -FIXME: generalize this to varargs +FIXME: generalize this to varargs; can coccinelle do this? """ import sys sys.path.append('.') diff --git a/validate.py b/validate.py index 3f32745..ebe5977 100644 --- a/validate.py +++ b/validate.py @@ -7,9 +7,10 @@ class CExtensionError(Exception): self.location = location def __str__(self): - return '%s:%s: %s' % (self.location.file, - self.location.line, - self._get_desc()) + return '%s:%s:%s:%s' % (self.location.file, + self.location.line, + self.location.current_element, + self._get_desc()) def _get_desc(self): raise NotImplementedError -- cgit