[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] with these, clang vs. libvirt reports no errors



I've been running clang regularly, and there have been a few
pesky false-positives that just won't go away.
It's not productive to reexamine them each time, so I've wanted
a way to educate clang without polluting the code with work-arounds
that we'll be stuck maintaining and asking questions about long
after clang becomes smart enough that those work-arounds are no
longer required.

My solution is to mark the work-arounds with a new macro, sa_assert
(for "static analysis assert"), which acts just like the classical
"assert", but is only enabled when compiled by a static analyzer
like clang or coverity.  The advantage of using an assert-like
macro is that people already know that it must have no side-effects
and that will make it easy to remove later, when clang grows up.

One question you may ask is why add a new symbol, when
"assert" itself can already do this via NDEBUG (defined, any
assertions are disabled, not defined, they are enabled).
There are a few assertions in the code now, and I prefer
not to touch them, and to make it clear that these are
helping us cater to static analyzers.

[PATCH 1/7] sa_assert: new assert-like macro, enabled only for use with static analyzers
[PATCH 2/7] build: set STATIC_ANALYSIS when running via clang or coverity
[PATCH 3/7] nwfilter_ebiptables_driver.c: avoid NULL dereference
[PATCH 4/7] virGetHostnameLocalhost: avoid FP NULL-ptr-deref from clang
[PATCH 5/7] qemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang
[PATCH 6/7] xend_internal.c: assure clang that we do not dereference NULL
[PATCH 7/7] qemudDomainAttachSCSIDisk: avoid FP NULL-ptr-deref from clang


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]