Skip to content

Silenced the SMP MISRA shim's implicit conversions - #751

Open
fdesbiens wants to merge 1 commit into
eclipse-threadx:devfrom
fdesbiens:fix-smp-misra-shim-conversions
Open

fdesbiens wants to merge 1 commit into
eclipse-threadx:devfrom
fdesbiens:fix-smp-misra-shim-conversions

Conversation

@fdesbiens

Copy link
Copy Markdown
Contributor

Fixes #750

common_smp/src/tx_misra.c performs four implicit conversions that its monoprocessor twin makes explicit, and ignores a parameter the twin casts to void. Built with the warning set common_smp uses, the file reports five diagnostics that common/src/tx_misra.c does not: a sign conversion on the memset value at line 49, three more on the pointer differences at lines 93, 151 and 221, and an unused status parameter at line 624. The two files are otherwise the same shim, so this is drift rather than a deliberate difference.

That the shim is the file reporting them is the reason to fix it. It exists to route the kernel's pointer conversions 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 test trees are why it went unnoticed: test/tx builds the kernel with -Werror and test/smp has it commented out, and neither defines TX_MISRA_ENABLE in any build configuration, so the file is normally compiled to nothing.

This applies the monoprocessor form to all five sites and changes nothing else. Compiled at -m32 -std=c99 with TX_MISRA_ENABLE defined on gcc 14.2.0, the five diagnostics go to zero; the only one left is the pre-existing redefinition of typedef 'TX_THREAD' from tx_api.h, which every file in the tree reports. Object code is byte identical before and after, compared with objcopy --strip-debug — md5 26173619244ca5c4351aeda236e8db35 either way — so this changes diagnostics and nothing else.

Not run: the SMP regression suite, which does not build this file in any of its configurations.

common_smp/src/tx_misra.c performs four implicit conversions that its
monoprocessor twin makes explicit, and ignores a parameter the twin casts to
void. Built with the warning set common_smp uses, the file reports five
diagnostics that common/src/tx_misra.c does not:

  tx_misra.c:49  conversion to 'int' from 'UINT' may change the sign of the result
  tx_misra.c:93  conversion to 'ULONG' from 'int' may change the sign of the result
  tx_misra.c:151 the same
  tx_misra.c:221 the same
  tx_misra.c:624 unused parameter 'status'

The two files are otherwise the same shim, so this is drift rather than a
deliberate difference: common/src already carries (INT) on the memset value,
(ULONG) on the three pointer differences, and (VOID)status.

That the shim is the file reporting them is the reason to fix it. It exists to
route the kernel's pointer conversions 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 test trees hide it. test/tx builds the kernel with -Werror, so the
monoprocessor copy could never have regressed this way; test/smp has -Werror
commented out, so the SMP copy warns and builds.

Applying the monoprocessor form to all five sites. Object code is byte
identical before and after, compared with --strip-debug at -m32 -std=c99 with
TX_MISRA_ENABLE defined, so this changes diagnostics and nothing else.

Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant