Skip to content

The SMP MISRA shim reports five conversion warnings the monoprocessor copy does not #750

Description

@fdesbiens

common_smp/src/tx_misra.c and common/src/tx_misra.c are the same shim, but the SMP copy performs four implicit conversions the monoprocessor copy makes explicit, and ignores a parameter the monoprocessor copy casts to void.

Compiled at -m32 -std=c99 with TX_MISRA_ENABLE defined and the warning set common_smp is built with (-Wall -Wextra -pedantic -Wconversion -Wmissing-declarations -Wunused -Wuninitialized -Wpointer-arith -Wlogical-op -Waggregate-return -Wfloat-equal), on gcc 14.2.0:

common_smp/src/tx_misra.c:49:17  conversion to 'int' from 'UINT' may change the sign of the result [-Wsign-conversion]
common_smp/src/tx_misra.c:93:14  conversion to 'ULONG' from 'int' may change the sign of the result [-Wsign-conversion]
common_smp/src/tx_misra.c:151:14 conversion to 'ULONG' from 'int' may change the sign of the result [-Wsign-conversion]
common_smp/src/tx_misra.c:221:14 conversion to 'ULONG' from 'int' may change the sign of the result [-Wsign-conversion]
common_smp/src/tx_misra.c:624:33 unused parameter 'status' [-Wunused-parameter]

common/src/tx_misra.c reports none of them, because it already writes memset(ptr, (INT)value, size), value = (ULONG)(ptr1 - ptr2) at all three sites, and (VOID)status;. The difference looks like drift rather than a deliberate divergence.

It is worth fixing because of which file it is. The shim exists so that the kernel's pointer conversions go through functions a MISRA analysis can account for, and an implicit signed-to-unsigned conversion inside it is the class of construct it was written to remove.

The reason this has not surfaced before is that the two test trees disagree. test/tx/cmake/CMakeLists.txt builds the kernel with -Werror, so the monoprocessor copy could not have regressed this way. test/smp/cmake/CMakeLists.txt has -Werror commented out in both add_compile_options and target_compile_options, so the SMP copy warns and builds. Neither tree defines TX_MISRA_ENABLE in any build configuration, so the file is normally compiled to nothing and the warnings never appear at all.

Fix in the linked pull request: apply the monoprocessor form to all five sites. Object code is byte identical before and after, compared with objcopy --strip-debug.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions