Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional errors reported by new cppcheck #1325

Closed
jphickey opened this issue Nov 1, 2022 · 2 comments · Fixed by #1336
Closed

Additional errors reported by new cppcheck #1325

jphickey opened this issue Nov 1, 2022 · 2 comments · Fixed by #1336
Assignees
Milestone

Comments

@jphickey
Copy link
Contributor

jphickey commented Nov 1, 2022

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.

@jphickey jphickey self-assigned this Nov 1, 2022
@thnkslprpt
Copy link
Contributor

thnkslprpt commented Nov 8, 2022

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
Copy link
Contributor

skliper commented Nov 14, 2022

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

jphickey added a commit to jphickey/osal that referenced this issue Nov 17, 2022
Resolves a number of issues reported by cppcheck
jphickey added a commit to jphickey/osal that referenced this issue Nov 17, 2022
Resolves a number of issues reported by cppcheck
dzbaker added a commit that referenced this issue Nov 17, 2022
dzbaker added a commit that referenced this issue Nov 23, 2022
Fix #1333, Fix #1325, Update CI to use Ubuntu 20.04
@dmknutsen dmknutsen added this to the Draco milestone Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants