there's a cppcheck - tool for static C/C++ code analysis...

Dirk Hohndel dirk at
Tue Sep 18 17:11:16 PDT 2012

Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at> writes:

> ...I grew to love ;)  Few false positives, IMO.
> After watching the "subsurface crashes on me" later mails, I thought I
> might just as well use it.  And this is what it (v1.56) reports:

Wow, what a treasure trove. I ignored some of them as not all that
relevant right now, saw a couple of false positives and a couple of
minor style nits, but at least to potentially serious bugs were
found. One of them happens to work out correctly, anyway, but the other
one I think could be the culprit of our issues...

> [dive.h:371]: (style) Checking if unsigned variable 'nr' is less than zero.

This is a real bug. But the reason why this almost certainly didn't
cause us any major pain is that -1 (or any other negative index) would
turn into a large unsigned integer and therefore trigger the 
">" case - and still return NULL.

Of course I still fixed this.

> [gtk-gui.c:229]: (error) Mismatching allocation and deallocation: label_text

And this is the one that I think might cause havoc with glib's memory
management. I'm eager to see if this addresses the bug on Ubuntu...

I'll do some more sanity testing and then push out my fixes. Stay tuned.


More information about the subsurface mailing list