summaryrefslogtreecommitdiffstats
path: root/README
blob: aa837ce8c5649d50d717e7ecf0a3600a3e52f7e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
You'll need "spatch", from coccinelle.

You can install this on Fedora using:
   yum install coccinelle

To run, invoke this:
   spatch -sp_file pyarg-parsetuple.cocci buggy.c 

This gives this output:

[david@brick static-analysis]$ spatch -sp_file pyarg-parsetuple.cocci buggy.c
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


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:207:xx_roj:unknown format char in "O#:roj": '#'
[david@brick static-analysis]$ echo $?
1