selinux/libsepol/tests
Nicolas Iooss 120681c1a3 libsepol, libsemanage: add a macro to silence static analyzer warnings in tests
Several static analyzers (clang's one, Facebook Infer, etc.) warn about
NULL pointer dereferences after a call to CU_ASSERT_PTR_NOT_NULL_FATAL()
in the test code written using CUnit framework. This is because this
CUnit macro is too complex for them to understand that the pointer
cannot be NULL: it is translated to a call to CU_assertImplementation()
with an argument as TRUE in order to mean that the call is fatal if the
asserted condition failed (cf.
http://cunit.sourceforge.net/doxdocs/group__Framework.html).

A possible solution could consist in replacing the
CU_ASSERT_..._FATAL() calls by assert() ones, as most static analyzers
know about assert(). Nevertheless this seems to go against CUnit's API.

An alternative solution consists in overriding CU_ASSERT_..._FATAL()
macros in order to expand to assert() after a call to the matching
CU_ASSERT_...() non-fatal macro. This appears to work fine and to remove
many false-positive warnings from various static analyzers.

As this substitution should only occur when using static analyzer, put
it under #ifdef __CHECKER__, which is the macro used by sparse when
analyzing the Linux kernel.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-30 08:43:41 -04:00
..
policies Fix many misspellings 2019-09-18 22:47:35 +02:00
.gitignore
Makefile libsepol/tests: override CPPFLAGS too 2017-06-30 08:56:43 -04:00
debug.c
debug.h
helpers.c libsepol/tests: fix -Wwrite-strings warnings 2017-02-06 11:06:04 -05:00
helpers.h libsepol, libsemanage: add a macro to silence static analyzer warnings in tests 2019-09-30 08:43:41 -04:00
libsepol-tests.c
test-common.c libsepol, libsemanage: add a macro to silence static analyzer warnings in tests 2019-09-30 08:43:41 -04:00
test-common.h libsepol/tests: fix -Wwrite-strings warnings 2017-02-06 11:06:04 -05:00
test-cond.c
test-cond.h
test-deps.c libsepol, libsemanage: add a macro to silence static analyzer warnings in tests 2019-09-30 08:43:41 -04:00
test-deps.h
test-downgrade.c Fix many misspellings 2019-09-18 22:47:35 +02:00
test-downgrade.h Fix many misspellings 2019-09-18 22:47:35 +02:00
test-expander-attr-map.c libsepol, libsemanage: add a macro to silence static analyzer warnings in tests 2019-09-30 08:43:41 -04:00
test-expander-attr-map.h
test-expander-roles.c libsepol, libsemanage: add a macro to silence static analyzer warnings in tests 2019-09-30 08:43:41 -04:00
test-expander-roles.h
test-expander-users.c libsepol, libsemanage: add a macro to silence static analyzer warnings in tests 2019-09-30 08:43:41 -04:00
test-expander-users.h
test-expander.c libsepol/tests: fix -Wwrite-strings warnings 2017-02-06 11:06:04 -05:00
test-expander.h
test-linker-cond-map.c Fix many misspellings 2019-09-18 22:47:35 +02:00
test-linker-cond-map.h
test-linker-roles.c libsepol: add ebitmap_for_each_set_bit macro 2019-05-20 14:00:32 -04:00
test-linker-roles.h
test-linker-types.c libsepol/tests: fix -Wwrite-strings warnings 2017-02-06 11:06:04 -05:00
test-linker-types.h
test-linker.c
test-linker.h