selinux/libsepol/tests
Nicolas Iooss c3b8d4aa61 libsepol/tests: fix -Wsometimes-uninitialized clang warnings
When compiling libsepol tests, clang complains about some uninitialized
variables:

    test-common.c:171:14: error: variable 'my_primary' is used
    uninitialized whenever 'if' condition is false
    [-Werror,-Wsometimes-uninitialized]
                    } else if (my_flavor == TYPE_ALIAS) {
                               ^~~~~~~~~~~~~~~~~~~~~~~
    test-common.c:179:30: note: uninitialized use occurs here
                    CU_ASSERT(type->primary == my_primary);
                                               ^~~~~~~~~~
    /usr/include/CUnit/CUnit.h:123:30: note: expanded from macro
    'CU_ASSERT'
      { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_...
                                 ^
    test-common.c:171:10: note: remove the 'if' if its condition is
    always true
                    } else if (my_flavor == TYPE_ALIAS) {
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    test-common.c:153:25: note: initialize the variable 'my_primary' to
    silence this warning
            unsigned int my_primary, my_flavor, my_value;
                                   ^
                                    = 0
    test-common.c:171:14: error: variable 'my_value' is used
    uninitialized whenever 'if' condition is false
    [-Werror,-Wsometimes-uninitialized]
                    } else if (my_flavor == TYPE_ALIAS) {
                               ^~~~~~~~~~~~~~~~~~~~~~~
    test-common.c:181:30: note: uninitialized use occurs here
                    CU_ASSERT(type->s.value == my_value);
                                               ^~~~~~~~
    /usr/include/CUnit/CUnit.h:123:30: note: expanded from macro
    'CU_ASSERT'
      { CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_...
                                 ^
    test-common.c:171:10: note: remove the 'if' if its condition is
    always true
                    } else if (my_flavor == TYPE_ALIAS) {
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    test-common.c:153:46: note: initialize the variable 'my_value' to
    silence this warning
            unsigned int my_primary, my_flavor, my_value;
                                                        ^
                                                         = 0

This is because the call to CU_FAIL("not an alias") is not fatal in
test_alias_datum(), and variables my_primary and my_value are indeed
used uninitialized in a CU_ASSERT statement later.

Silent the warning by moving the elseif condition to a CU_ASSERT
statement which replaces the CU_FAIL.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-01-06 12:59:01 -05:00
..
policies Update .gitignore files 2016-05-09 08:14:54 -04:00
.gitignore Update .gitignore files 2016-05-09 08:14:54 -04:00
debug.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
debug.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
helpers.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
helpers.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
libsepol-tests.c libsepol: make "make test" fails when a CUnit test fails 2016-09-06 10:49:56 -04:00
Makefile libsepol/tests: use LDFLAGS when linking 2016-11-29 08:45:26 -05:00
test-common.c libsepol/tests: fix -Wsometimes-uninitialized clang warnings 2017-01-06 12:59:01 -05:00
test-common.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-cond.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-cond.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-deps.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-deps.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-downgrade.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-downgrade.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-expander-attr-map.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-expander-attr-map.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-expander-roles.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-expander-roles.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-expander-users.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-expander-users.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-expander.c reactivate attribute mapping unit test 2010-03-24 13:55:23 -04:00
test-expander.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-linker-cond-map.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-linker-cond-map.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-linker-roles.c libsepol: tests: fix g_b_role_2 test 2016-09-06 10:49:56 -04:00
test-linker-roles.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-linker-types.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-linker-types.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-linker.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
test-linker.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00