Skip to content

Commit fbf2f6c

Browse files
authored
Fix uintptr compile error (#62)
* Fix compile error in cellular_pktio.c * Fix cellular_pktio.c unit-test
1 parent 907af03 commit fbf2f6c

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

source/cellular_pktio.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ static CellularCommInterfaceError_t _Cellular_PktRxCallBack( void * pUserData,
466466
( void ) commInterfaceHandle; /* Comm if is not used in this function. */
467467

468468
/* The context of this function is a ISR. */
469-
if( pContext->pPktioCommEvent == ( uintptr_t ) ( uintptr_t * ) NULL )
469+
if( pContext->pPktioCommEvent == NULL )
470470
{
471471
retComm = IOT_COMM_INTERFACE_BAD_PARAMETER;
472472
}
@@ -1108,7 +1108,7 @@ CellularPktStatus_t _Cellular_PktioInit( CellularContext_t * pContext,
11081108
/* coverity[misra_c_2012_directive_4_6_violation] */
11091109
pContext->pPktioCommEvent = ( PlatformEventGroupHandle_t ) PlatformEventGroup_Create();
11101110

1111-
if( pContext->pPktioCommEvent == ( uintptr_t ) ( uintptr_t * ) NULL )
1111+
if( pContext->pPktioCommEvent == NULL )
11121112
{
11131113
LogError( ( "Can't create event group" ) );
11141114
pktStatus = CELLULAR_PKT_STATUS_CREATION_FAIL;
@@ -1157,7 +1157,7 @@ CellularPktStatus_t _Cellular_PktioInit( CellularContext_t * pContext,
11571157
{
11581158
pContext->pPktioHandlepktCB = NULL;
11591159

1160-
if( pContext->pPktioCommEvent != ( uintptr_t ) ( uintptr_t * ) NULL )
1160+
if( pContext->pPktioCommEvent != NULL )
11611161
{
11621162
/* It's platform-dependent declaration. */
11631163
/* coverity[misra_c_2012_directive_4_6_violation] */
@@ -1264,7 +1264,7 @@ void _Cellular_PktioShutdown( CellularContext_t * pContext )
12641264

12651265
if( ( pContext != NULL ) && ( pContext->bPktioUp ) )
12661266
{
1267-
if( pContext->pPktioCommEvent != ( uintptr_t ) ( uintptr_t * ) NULL )
1267+
if( pContext->pPktioCommEvent != NULL )
12681268
{
12691269
( void ) PlatformEventGroup_SetBits( ( PlatformEventGroupHandle_t ) pContext->pPktioCommEvent, ( EventBits_t ) PKTIO_EVT_MASK_ABORT );
12701270
/* It's platform-dependent declaration. */

test/unit-test/cellular_pktio_utest.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ struct _cellularCommContext
8282
};
8383

8484
static uint16_t pktioEvtMask = 0x0000U;
85-
static uint16_t evtGroupCreate = 0x0001U;
8685

86+
static MockPlatformEventGroup_t evtGroup = { 0 };
87+
static MockPlatformEventGroupHandle_t evtGroupHandle = NULL;
8788

8889
static int recvCount = 0;
8990
static int testInfiniteLoop = 0;
@@ -202,6 +203,7 @@ void setUp()
202203
recvCommFail = 0;
203204
setpktDataPrefixCBReturn = 0;
204205
testInfiniteLoop = 0;
206+
evtGroupHandle = &evtGroup;
205207
}
206208

207209
/* Called after each test method. */
@@ -246,9 +248,9 @@ uint16_t MockPlatformEventGroup_ClearBits( PlatformEventGroupHandle_t xEventGrou
246248
return 0;
247249
}
248250

249-
uint16_t MockPlatformEventGroup_Create( void )
251+
MockPlatformEventGroupHandle_t MockPlatformEventGroup_Create( void )
250252
{
251-
return evtGroupCreate;
253+
return evtGroupHandle;
252254
}
253255

254256
uint16_t MockPlatformEventGroup_WaitBits( PlatformEventGroupHandle_t groupEvent,
@@ -362,6 +364,7 @@ static CellularCommInterfaceError_t _prvCommIntfOpen( CellularCommInterfaceRecei
362364

363365
( void ) receiveCallback;
364366
CellularContext_t * pContext = ( CellularContext_t * ) pUserData;
367+
365368
( void ) pCommInterfaceHandle;
366369

367370
commIntRet = receiveCallback( pContext, NULL );
@@ -377,6 +380,7 @@ static CellularCommInterfaceError_t _prvCommIntfOpenCallrecvCallbackNullContext(
377380

378381
( void ) receiveCallback;
379382
CellularContext_t * pContext = ( CellularContext_t * ) pUserData;
383+
380384
( void ) pCommInterfaceHandle;
381385

382386
memset( pContext, 0, sizeof( CellularContext_t ) );
@@ -731,6 +735,7 @@ void test__Cellular_PktioInit_Thread_ReceiveCallback_xHigherPriorityTaskWoken_Fa
731735
/* Make PlatformEventGroup_SetBitsFromISR return true. */
732736
setBitFromIsrReturn = 1;
733737
higherPriorityTaskWokenReturn = 0;
738+
734739
/* Check that CELLULAR_PKT_STATUS_OK is returned. */
735740
pktStatus = _Cellular_PktioInit( &context, PktioHandlePacketCallback_t );
736741
TEST_ASSERT_EQUAL( CELLULAR_PKT_STATUS_OK, pktStatus );
@@ -1516,7 +1521,6 @@ void test__Cellular_PktioInit_Event_Aborted( void )
15161521

15171522
/* Test the aborted event. */
15181523
pktioEvtMask = PKTIO_EVT_MASK_ABORTED;
1519-
evtGroupCreate = 1U;
15201524
recvCount = 1;
15211525
/* Check that CELLULAR_PKT_STATUS_OK is returned. */
15221526
pktStatus = _Cellular_PktioInit( &context, PktioHandlePacketCallback_t );
@@ -1534,8 +1538,8 @@ void test__Cellular_PktioInit_Event_Group_Create_Null( void )
15341538
memset( &context, 0, sizeof( CellularContext_t ) );
15351539

15361540
/* Test the pPktioCommEvent NULL case. */
1537-
context.pPktioCommEvent = ( PlatformEventGroupHandle_t ) 0U;
1538-
evtGroupCreate = ( uintptr_t ) ( uintptr_t * ) NULL;
1541+
context.pPktioCommEvent = NULL;
1542+
evtGroupHandle = NULL;
15391543
/* Check that CELLULAR_PKT_STATUS_CREATION_FAIL is returned. */
15401544
pktStatus = _Cellular_PktioInit( &context, PktioHandlePacketCallback_t );
15411545
TEST_ASSERT_EQUAL( CELLULAR_PKT_STATUS_CREATION_FAIL, pktStatus );
@@ -1553,7 +1557,6 @@ void test__Cellular_PktioInit_Create_Thread_Fail( void )
15531557

15541558
/* Test the Platform_CreateDetachedThread fail case. */
15551559
threadReturn = false;
1556-
evtGroupCreate = 1U;
15571560
/* Check that CELLULAR_PKT_STATUS_CREATION_FAIL is returned. */
15581561
pktStatus = _Cellular_PktioInit( &context, PktioHandlePacketCallback_t );
15591562
TEST_ASSERT_EQUAL( CELLULAR_PKT_STATUS_CREATION_FAIL, pktStatus );
@@ -1818,7 +1821,7 @@ void test__Cellular_PktioShutdown_Null_PktioCommEvent( void )
18181821
desiredPktioEvtMask = PKTIO_EVT_MASK_ABORTED;
18191822
context.bPktioUp = true;
18201823

1821-
context.pPktioCommEvent = ( PlatformEventGroupHandle_t ) 0;
1824+
context.pPktioCommEvent = NULL;
18221825
_Cellular_PktioShutdown( &context );
18231826

18241827
TEST_ASSERT_EQUAL( false, context.bPktioUp );
@@ -1833,7 +1836,6 @@ void test__Cellular_PktioShutdown_Happy_Path( void )
18331836

18341837
memset( &context, 0, sizeof( CellularContext_t ) );
18351838
eventDesiredCount = 2;
1836-
evtGroupCreate = 1U;
18371839
desiredPktioEvtMask = PKTIO_EVT_MASK_ABORTED;
18381840
context.bPktioUp = true;
18391841

test/unit-test/cellular_platform.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#define taskENTER_CRITICAL dummyTaskENTER_CRITICAL
4444
#define taskEXIT_CRITICAL dummyTaskEXIT_CRITICAL
4545

46-
#define PlatformEventGroupHandle_t uint16_t
46+
#define PlatformEventGroupHandle_t MockPlatformEventGroupHandle_t
4747
#define PlatformEventGroup_Delete MockPlatformEventGroup_Delete
4848
#define PlatformEventGroup_ClearBits MockPlatformEventGroup_ClearBits
4949
#define PlatformEventGroup_Create MockPlatformEventGroup_Create
@@ -170,6 +170,15 @@ typedef struct PlatformMutex
170170
*/
171171
typedef TickType_t EventBits_t;
172172

173+
/*
174+
* @brief The structure to hold the mocked event group structure.
175+
*/
176+
typedef struct MockPlatformEventGroup
177+
{
178+
uint16_t mockedEventGroupValue;
179+
} MockPlatformEventGroup_t;
180+
typedef MockPlatformEventGroup_t * MockPlatformEventGroupHandle_t;
181+
173182
/*-----------------------------------------------------------*/
174183

175184
/**
@@ -223,7 +232,7 @@ uint16_t MockPlatformEventGroup_WaitBits( PlatformEventGroupHandle_t groupEvent,
223232
BaseType_t xWaitForAllBits,
224233
TickType_t xTicksToWait );
225234

226-
uint16_t MockPlatformEventGroup_Create( void );
235+
MockPlatformEventGroupHandle_t MockPlatformEventGroup_Create( void );
227236

228237
uint16_t MockPlatformEventGroup_Delete( PlatformEventGroupHandle_t groupEvent );
229238

0 commit comments

Comments
 (0)