Silenced the SMP MISRA shim's implicit conversions (#751)

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>
This commit is contained in:
Frédéric Desbiens
2026-09-28 14:02:49 -04:00
committed by GitHub
parent f65727f585
commit 9bf9978e95
+6 -4
View File
@@ -47,7 +47,7 @@
/**************************************************************************/
VOID _tx_misra_memset(VOID *ptr, UINT value, UINT size)
{
memset(ptr, value, size);
memset(ptr, (INT)value, size);
}
@@ -91,7 +91,7 @@ ULONG _tx_misra_uchar_pointer_dif(UCHAR *ptr1, UCHAR *ptr2)
ULONG value;
value = ptr1 - ptr2;
value = (ULONG)(ptr1 - ptr2);
return(value);
}
@@ -149,7 +149,7 @@ ULONG _tx_misra_ulong_pointer_dif(ULONG *ptr1, ULONG *ptr2)
{
ULONG value;
value = ptr1 - ptr2;
value = (ULONG)(ptr1 - ptr2);
return(value);
}
@@ -219,7 +219,7 @@ ULONG _tx_misra_timer_pointer_dif(TX_TIMER_INTERNAL **ptr1, TX_TIMER_INTERNAL *
ULONG value;
value = ptr1 - ptr2;
value = (ULONG)(ptr1 - ptr2);
return(value);
}
@@ -625,6 +625,8 @@ TX_MUTEX *_tx_misra_void_to_mutex_pointer_convert(VOID *pointer)
UINT _tx_misra_status_get(UINT status)
{
(VOID)status;
/* Return a successful status. */
return(TX_SUCCESS);
}