Skip to content

Commit d66a519

Browse files
Fix MISRA issues for ThreadX SMP (#263)
* Fixed MISRA2012 rule 10.4_a The operands `pool_ptr->tx_byte_pool_fragments' and `2' have essential type categories unsigned 32-bit int and signed 8-bit int, which do not match. * Fixed MISRA2012 rule 10.4_a The operands `next_priority' and `TX_MAX_PRIORITIES' have essential type categories unsigned 32-bit int and signed 8-bit int, which do not match. * Fixed MISRA2012 rule 8.3 Declaration/definition of `_tx_thread_smp_preemptable_threads_get' is inconsistent with previous declaration/definition in types and/or type qualifiers
1 parent 6b8ece0 commit d66a519

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

common_smp/inc/tx_thread.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* COMPONENT DEFINITION RELEASE */
2727
/* */
2828
/* tx_thread.h PORTABLE SMP */
29-
/* 6.1 */
29+
/* 6.x */
3030
/* AUTHOR */
3131
/* */
3232
/* William E. Lamie, Microsoft Corporation */
@@ -42,6 +42,8 @@
4242
/* DATE NAME DESCRIPTION */
4343
/* */
4444
/* 09-30-2020 William E. Lamie Initial Version 6.1 */
45+
/* xx-xx-xxxx Tiejun Zhou Fixed MISRA2012 rule 8.3, */
46+
/* resulting in version 6.x */
4547
/* */
4648
/**************************************************************************/
4749

@@ -1349,7 +1351,7 @@ TX_THREAD *thread_remap_list[TX_THREAD_SMP_MAX_CORES];
13491351
}
13501352

13511353

1352-
static INLINE_DECLARE ULONG _tx_thread_smp_preemptable_threads_get(UINT priority, TX_THREAD *possible_preemption_list[])
1354+
static INLINE_DECLARE ULONG _tx_thread_smp_preemptable_threads_get(UINT priority, TX_THREAD *possible_preemption_list[TX_THREAD_SMP_MAX_CORES])
13531355
{
13541356

13551357
UINT i, j, k;
@@ -1668,7 +1670,7 @@ ULONG _tx_thread_smp_available_cores_get(void);
16681670
ULONG _tx_thread_smp_possible_cores_get(void);
16691671
UINT _tx_thread_smp_lowest_priority_get(void);
16701672
UINT _tx_thread_smp_remap_solution_find(TX_THREAD *schedule_thread, ULONG available_cores, ULONG thread_possible_cores, ULONG test_possible_cores);
1671-
ULONG _tx_thread_smp_preemptable_threads_get(UINT priority, TX_THREAD *possible_preemption_list[]);
1673+
ULONG _tx_thread_smp_preemptable_threads_get(UINT priority, TX_THREAD *possible_preemption_list[TX_THREAD_SMP_MAX_CORES]);
16721674
VOID _tx_thread_smp_simple_priority_change(TX_THREAD *thread_ptr, UINT new_priority);
16731675

16741676
#endif

common_smp/src/tx_byte_pool_search.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
/* FUNCTION RELEASE */
3636
/* */
3737
/* _tx_byte_pool_search PORTABLE SMP */
38-
/* 6.1.7 */
38+
/* 6.x */
3939
/* AUTHOR */
4040
/* */
4141
/* William E. Lamie, Microsoft Corporation */
@@ -81,6 +81,8 @@
8181
/* calculation, and reduced */
8282
/* number of search resets, */
8383
/* resulting in version 6.1.7 */
84+
/* xx-xx-xxxx Tiejun Zhou Fixed MISRA2012 rule 10.4_a, */
85+
/* resulting in version 6.x */
8486
/* */
8587
/**************************************************************************/
8688
UCHAR *_tx_byte_pool_search(TX_BYTE_POOL *pool_ptr, ULONG memory_size)
@@ -110,7 +112,7 @@ UINT blocks_searched = ((UINT) 0);
110112

111113
/* First, determine if there are enough bytes in the pool. */
112114
/* Theoretical bytes available = free bytes + ((fragments-2) * overhead of each block) */
113-
total_theoretical_available = pool_ptr -> tx_byte_pool_available + ((pool_ptr -> tx_byte_pool_fragments - 2) * ((sizeof(UCHAR *)) + (sizeof(ALIGN_TYPE))));
115+
total_theoretical_available = pool_ptr -> tx_byte_pool_available + ((pool_ptr -> tx_byte_pool_fragments - 2U) * ((sizeof(UCHAR *)) + (sizeof(ALIGN_TYPE))));
114116
if (memory_size >= total_theoretical_available)
115117
{
116118

common_smp/src/tx_thread_smp_utilities.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ TX_THREAD *thread_remap_list[TX_THREAD_SMP_MAX_CORES];
826826
}
827827

828828

829-
ULONG _tx_thread_smp_preemptable_threads_get(UINT priority, TX_THREAD *possible_preemption_list[])
829+
ULONG _tx_thread_smp_preemptable_threads_get(UINT priority, TX_THREAD *possible_preemption_list[TX_THREAD_SMP_MAX_CORES])
830830
{
831831

832832
UINT i, j, k;

common_smp/src/tx_thread_system_suspend.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
/* FUNCTION RELEASE */
3939
/* */
4040
/* _tx_thread_system_suspend PORTABLE SMP */
41-
/* 6.1.11 */
41+
/* 6.x */
4242
/* AUTHOR */
4343
/* */
4444
/* William E. Lamie, Microsoft Corporation */
@@ -91,6 +91,8 @@
9191
/* 04-25-2022 Scott Larson Modified comments and fixed */
9292
/* loop to find next thread, */
9393
/* resulting in version 6.1.11 */
94+
/* xx-xx-xxxx Tiejun Zhou Fixed MISRA2012 rule 10.4_a, */
95+
/* resulting in version 6.x */
9496
/* */
9597
/**************************************************************************/
9698
VOID _tx_thread_system_suspend(TX_THREAD *thread_ptr)
@@ -671,7 +673,7 @@ UINT processing_complete;
671673
complex_path_possible = possible_cores & available_cores;
672674

673675
/* Check if we need to loop to find the next highest priority thread. */
674-
if (next_priority == TX_MAX_PRIORITIES)
676+
if (next_priority == (ULONG)TX_MAX_PRIORITIES)
675677
{
676678
loop_finished = TX_TRUE;
677679
}

0 commit comments

Comments
 (0)