nasa / osal

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

Additional errors reported by new cppcheck #1325

Closed jphickey closed 1 year ago

jphickey commented 2 years ago

Describe the bug The latest version of cppcheck reports the following errors/concerns in the OSAL source code:

src/os/portable/os-impl-posix-dl-symtab.c:140:35: style: Variable 'local_status' is assigned a value that is never used. [unreadVariable]
    int32            local_status = OS_ERROR;
                                  ^
src/os/posix/src/os-impl-console.c:83:26: style: Variable 'local_arg.opaque_arg' is assigned a value that is never used. [unreadVariable]
    local_arg.opaque_arg = arg;
                         ^
src/os/posix/src/os-impl-console.c:128:30: style: Variable 'local_arg.id' is assigned a value that is never used. [unreadVariable]
                local_arg.id = OS_ObjectIdFromToken(token);
                             ^
src/os/posix/src/os-impl-tasks.c:117:26: style: Variable 'local_arg.opaque_arg' is assigned a value that is never used. [unreadVariable]
    local_arg.opaque_arg = arg;
                         ^
src/os/posix/src/os-impl-tasks.c:578:20: style: Variable 'arg.id' is assigned a value that is never used. [unreadVariable]
    arg.id         = OS_ObjectIdFromToken(token);
                   ^
src/os/posix/src/os-impl-tasks.c:791:20: style: Variable 'arg.id' is assigned a value that is never used. [unreadVariable]
    arg.id         = global_task_id;
                   ^
src/os/posix/src/os-impl-tasks.c:817:28: style: Variable 'self_record.opaque_arg' is assigned a value that is never used. [unreadVariable]
    self_record.opaque_arg = pthread_getspecific(POSIX_GlobalVars.ThreadKey);
                           ^
src/os/posix/src/os-impl-timebase.c:308:26: style: Variable 'local_arg.opaque_arg' is assigned a value that is never used. [unreadVariable]
    local_arg.opaque_arg = arg;
                         ^
src/os/posix/src/os-impl-timebase.c:345:20: style: Variable 'arg.id' is assigned a value that is never used. [unreadVariable]
    arg.id         = OS_ObjectIdFromToken(token);
                   ^
src/os/rtems/src/os-impl-filesys.c:175:25: style: Variable 'return_code' is reassigned a value before the old one has been used. [redundantAssignment]
            return_code = OS_SUCCESS;
                        ^
src/os/rtems/src/os-impl-filesys.c:169:29: note: return_code is assigned
                return_code = OS_ERROR;
                            ^
src/os/rtems/src/os-impl-filesys.c:175:25: note: return_code is overwritten
            return_code = OS_SUCCESS;
                        ^
src/os/rtems/src/os-impl-timebase.c:475:34: style: Variable 'user_data.id' is assigned a value that is never used. [unreadVariable]
            user_data.id         = OS_ObjectIdFromToken(token);

To Reproduce Execute the following cppcheck command in OSAL (same as what is used in the static analysis workflow "strict" setting): cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive src/bsp/ src/os/

Expected behavior Should pass cleanly

System observed on: Ubuntu 22.04 (cppcheck version 2.7)

Reporter Info Joseph Hickey, Vantage Systems, Inc.

thnkslprpt commented 2 years ago

FYI @jphickey - I'm seeing these new errors in the cppcheck workflow now as well:

src/os/shared/src/osapi-printf.c:269:30: error: syntax error [syntaxError]
    BUGCHECK((String) != NULL, )
                             ^
src/unit-test-coverage/vxworks/ut-stubs/src/vxworks-os-impl-common-stubs.c:32:1: error: There is an unknown macro here somewhere. Configuration is required. If UT_DEFAULT_STUB is a macro then please configure it. [unknownMacro]
UT_DEFAULT_STUB(OS_API_Impl_Init, (osal_objtype_t idtype))
^

https://github.com/thnkslprpt/osal/actions/runs/3416460591/jobs/5686627983

skliper commented 1 year ago

Errors from the CI run w/ Ubuntu 20.04: https://github.com/nasa/osal/actions/runs/3463520016