![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
Functions | |
| _strip_comments (text) | |
| _body_of (text, open_brace) | |
| _returns_pointer (ret) | |
| scan (path) | |
| main () | |
Variables | |
| DEF_RE | |
| dict | SKIP_DIRS = {'external', 'attic'} |
Find `return FALSE` in a function that returns a pointer, and its mirror.
The compiler cannot help here. GLib defines `FALSE` as `0`, and `0` is a valid null
pointer constant in C -- so `return FALSE;` from a `char *` function compiles silently and
means exactly `return NULL;`. It is only wrong to a reader, which is the worst kind of
wrong: it says "this function answers a yes/no question" about a function that hands back
an object.
The mirror cases are already covered by the compiler: `return TRUE;` from a pointer
function and `return NULL;` from an integer one both trip -Wint-conversion. This script
deliberately reports ONLY the FALSE-for-NULL direction, because it is the only one nothing
else catches -- and because the mirror cannot be checked textually anyway. `cmsHPROFILE`,
`cl_mem` and `gpointer` are pointers with no `*` in the spelling, so a check for
"`return NULL` in a non-pointer function" reports seventeen correct lines in this tree and
nothing else. A gate that cries wolf gets switched off.
tools/check_return_types.py [path ...] # default: src/
Exits non-zero if anything is found.
|
protected |
Return (body, offset_of_body_start) for the block opening at `open_brace`.
Definition at line 74 of file check_return_types.py.
Referenced by scan().
|
protected |
Definition at line 93 of file check_return_types.py.
Referenced by scan().
|
protected |
Blank out comments, preserving every byte offset and line number. Necessary, not cosmetic: an apostrophe in a comment -- "can't", "doesn't", which this codebase is full of -- reads as an opening character literal to the scanner below, and everything up to the next apostrophe gets skipped, braces included. The first version of this script reported five confident findings in mipmap_cache.c that were all that bug swallowing a function boundary.
Definition at line 38 of file check_return_types.py.
References min.
Referenced by scan().
| check_return_types.main | ( | void | ) |
Scan the given paths (default src/) and print what does not line up.
Definition at line 136 of file check_return_types.py.
References main(), and scan().
Referenced by main().
| check_return_types.scan | ( | path | ) |
Report every return-value/return-type mismatch in one file.
Definition at line 101 of file check_return_types.py.
References _body_of(), _returns_pointer(), and _strip_comments().
Referenced by main().
| check_return_types.DEF_RE |
Definition at line 29 of file check_return_types.py.
| dict check_return_types.SKIP_DIRS = {'external', 'attic'} |
Definition at line 35 of file check_return_types.py.