nasa / osal

The Core Flight System (cFS) Operating System Abstraction Layer (OSAL)
Apache License 2.0
546 stars 213 forks source link

New compile warnings with GCC 11.x #1199

Closed jphickey closed 2 years ago

jphickey commented 2 years ago

Describe the bug The newer versions of GCC report new warnings. These appear to be mostly false alarms, but easy to fix nonetheless.

To Reproduce Build OSAL using recent GCC

Expected behavior Should compile without warnings or errors

Code snips

osal/src/unit-test-coverage/vxworks/src/coveragetest-tasks.c: In function ‘Test_OS_TaskDetach_Impl’:
src/unit-test-coverage/vxworks/src/coveragetest-tasks.c:151:28: error: ‘token’ may be used uninitialized [-Werror=maybe-uninitialized]
src/unit-test-coverage/shared/src/coveragetest-clock.c: In function ‘Test_OS_SetLocalTime’:
src/unit-test-coverage/shared/src/coveragetest-clock.c:55:26: error: ‘time_struct’ may be used uninitialized [-Werror=maybe-uninitialized]
osal/src/unit-tests/oscore-test/ut_oscore_task_test.c: In function ‘UT_os_task_getid_by_sysdata_test’:
osal/src/unit-tests/inc/ut_os_support.h:112:28: error: ‘sysdata’ may be used uninitialized [-Werror=maybe-uninitialized]

System observed on: Ubuntu 21.10, gcc 11.2.0

Reporter Info Joseph Hickey, Vantage Systems, Inc.

kurtjd commented 2 years ago

I wouldn't mind tackling this, however I am having trouble replicating the issue. I'm using the same version of GCC on Pop!_OS, but building OSAL standalone doesn't seem to output any errors. My method of building is the one listed in the OSAL Configuration Guide:

$ mkdir build
$ cd build
$ cmake \
    -DCMAKE_BUILD_TYPE=debug \
    -DENABLE_UNIT_TESTS=true \
    -DOSAL_SYSTEM_BSPTYPE=generic-linux \
    -DOSAL_CONFIG_DEBUG_PERMISSIVE_MODE=true \
     /path/to/osal/source
$ make

I also tried adding -DOSAL_USER_C_FLAGS=-Werror but this didn't seem to provide any error output either.

skliper commented 2 years ago

My guess is these warnings were observed when compiling OSAL from within the bundle context (https://github.com/nasa/cFS). There's additional warnings enabled here (if/when you copy in the sample_defs to the bundle context): https://github.com/nasa/cFE/blob/c161cf04fe7c5fd2f2a533ac1d7522b31191eab6/cmake/sample_defs/arch_build_custom.cmake#L28-L37

jphickey commented 2 years ago

It requires a very recent version of GCC (11+). IIRC Pop OS is based on 20.04 so that's too old.

I actually have fix already, I patched it up so I could build on this system (Ubuntu 21.10), but haven't made a PR yet.

kurtjd commented 2 years ago

Oh ok, yeah I have the latest version of GCC but I wasn't building as part of the bundle. Thanks for the clarification!