Skip to content

Commit

Permalink
Use parenthesis to specify operator precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
chinglee-iot committed Mar 14, 2024
1 parent 61f612e commit cce929b
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 107 deletions.
34 changes: 17 additions & 17 deletions source/cellular_3gpp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ static bool _parseCopsNetworkNameToken( const char * pToken,
{
( void ) strncpy( pOperatorInfo->plmnInfo.mcc, pToken, CELLULAR_MCC_MAX_SIZE );
pOperatorInfo->plmnInfo.mcc[ CELLULAR_MCC_MAX_SIZE ] = '\0';
( void ) strncpy( pOperatorInfo->plmnInfo.mnc, &pToken[ CELLULAR_MCC_MAX_SIZE ],
( void ) strncpy( pOperatorInfo->plmnInfo.mnc, &( pToken[ CELLULAR_MCC_MAX_SIZE ] ),
( uint32_t ) ( mccMncLen - CELLULAR_MCC_MAX_SIZE + 1u ) );
pOperatorInfo->plmnInfo.mnc[ CELLULAR_MNC_MAX_SIZE ] = '\0';
}
Expand Down Expand Up @@ -1482,7 +1482,7 @@ static CellularError_t atcmdQueryRegStatus( CellularContext_t * pContext,
/* Get the service status from lib AT data. */
if( cellularStatus == CELLULAR_SUCCESS )
{
pLibAtData = &pContext->libAtData;
pLibAtData = &( pContext->libAtData );
_Cellular_LockAtDataMutex( pContext );
pServiceStatus->rat = pLibAtData->rat;
pServiceStatus->csRegistrationStatus = pLibAtData->csRegStatus;
Expand Down Expand Up @@ -2080,7 +2080,7 @@ void _Cellular_DestroyAtDataMutex( CellularContext_t * pContext )
{
configASSERT( pContext != NULL );

PlatformMutex_Destroy( &pContext->libAtDataMutex );
PlatformMutex_Destroy( &( pContext->libAtDataMutex ) );
}

/*-----------------------------------------------------------*/
Expand All @@ -2091,7 +2091,7 @@ bool _Cellular_CreateAtDataMutex( CellularContext_t * pContext )

configASSERT( pContext != NULL );

status = PlatformMutex_Create( &pContext->libAtDataMutex, false );
status = PlatformMutex_Create( &( pContext->libAtDataMutex ), false );

return status;
}
Expand All @@ -2102,7 +2102,7 @@ void _Cellular_LockAtDataMutex( CellularContext_t * pContext )
{
configASSERT( pContext != NULL );

PlatformMutex_Lock( &pContext->libAtDataMutex );
PlatformMutex_Lock( &( pContext->libAtDataMutex ) );
}

/*-----------------------------------------------------------*/
Expand All @@ -2111,7 +2111,7 @@ void _Cellular_UnlockAtDataMutex( CellularContext_t * pContext )
{
configASSERT( pContext != NULL );

PlatformMutex_Unlock( &pContext->libAtDataMutex );
PlatformMutex_Unlock( &( pContext->libAtDataMutex ) );
}

/*-----------------------------------------------------------*/
Expand All @@ -2125,7 +2125,7 @@ void _Cellular_InitAtData( CellularContext_t * pContext,

configASSERT( pContext != NULL );

pLibAtData = &pContext->libAtData;
pLibAtData = &( pContext->libAtData );

if( mode == 0u )
{
Expand Down Expand Up @@ -2690,7 +2690,7 @@ CellularError_t Cellular_CommonGetSimCardLockStatus( CellularHandle_t cellularHa
atReqGetSimLockStatus.atCmdType = CELLULAR_AT_WITH_PREFIX;
atReqGetSimLockStatus.pAtRspPrefix = "+CPIN";
atReqGetSimLockStatus.respCallback = _Cellular_RecvFuncGetSimLockStatus;
atReqGetSimLockStatus.pData = &pSimCardStatus->simCardLockState;
atReqGetSimLockStatus.pData = &( pSimCardStatus->simCardLockState );
atReqGetSimLockStatus.dataLen = ( uint16_t ) sizeof( CellularSimCardLockState_t );

pktStatus = _Cellular_AtcmdRequestWithCallback( pContext, atReqGetSimLockStatus );
Expand Down Expand Up @@ -2737,7 +2737,7 @@ CellularError_t Cellular_CommonGetSimCardInfo( CellularHandle_t cellularHandle,
atReqGetHplmn.atCmdType = CELLULAR_AT_WITH_PREFIX;
atReqGetHplmn.pAtRspPrefix = "+CRSM";
atReqGetHplmn.respCallback = _Cellular_RecvFuncGetHplmn;
atReqGetHplmn.pData = &pSimCardInfo->plmn;
atReqGetHplmn.pData = &( pSimCardInfo->plmn );
atReqGetHplmn.dataLen = ( uint16_t ) sizeof( CellularPlmnInfo_t );

/* pContext is checked in _Cellular_CheckLibraryStatus function. */
Expand Down Expand Up @@ -2853,13 +2853,13 @@ CellularError_t Cellular_CommonSetPsmSettings( CellularHandle_t cellularHandle,
/* coverity[misra_c_2012_rule_21_6_violation]. */
( void ) snprintf( cmdBuf, CELLULAR_AT_CMD_MAX_SIZE, "AT+CPSMS=%d,", pPsmSettings->mode );
cmdBufLen = ( uint32_t ) strlen( cmdBuf );
cmdBufLen = cmdBufLen + appendBinaryPattern( &cmdBuf[ cmdBufLen ], ( CELLULAR_AT_CMD_MAX_SIZE - cmdBufLen ),
cmdBufLen = cmdBufLen + appendBinaryPattern( &( cmdBuf[ cmdBufLen ] ), ( CELLULAR_AT_CMD_MAX_SIZE - cmdBufLen ),
pPsmSettings->periodicRauValue, false );
cmdBufLen = cmdBufLen + appendBinaryPattern( &cmdBuf[ cmdBufLen ], ( CELLULAR_AT_CMD_MAX_SIZE - cmdBufLen ),
cmdBufLen = cmdBufLen + appendBinaryPattern( &( cmdBuf[ cmdBufLen ] ), ( CELLULAR_AT_CMD_MAX_SIZE - cmdBufLen ),
pPsmSettings->gprsReadyTimer, false );
cmdBufLen = cmdBufLen + appendBinaryPattern( &cmdBuf[ cmdBufLen ], ( CELLULAR_AT_CMD_MAX_SIZE - cmdBufLen ),
cmdBufLen = cmdBufLen + appendBinaryPattern( &( cmdBuf[ cmdBufLen ] ), ( CELLULAR_AT_CMD_MAX_SIZE - cmdBufLen ),
pPsmSettings->periodicTauValue, false );
( void ) appendBinaryPattern( &cmdBuf[ cmdBufLen ], ( CELLULAR_AT_CMD_MAX_SIZE - cmdBufLen ),
( void ) appendBinaryPattern( &( cmdBuf[ cmdBufLen ] ), ( CELLULAR_AT_CMD_MAX_SIZE - cmdBufLen ),
pPsmSettings->activeTimeValue, true );

LogDebug( ( "PSM setting: %s ", cmdBuf ) );
Expand Down Expand Up @@ -2916,19 +2916,19 @@ static CellularATError_t parseGetPsmToken( char * pToken,
break;

case CPSMS_POS_RAU:
atCoreStatus = parseT3412TimerValue( pToken, &pPsmSettings->periodicRauValue );
atCoreStatus = parseT3412TimerValue( pToken, &( pPsmSettings->periodicRauValue ) );
break;

case CPSMS_POS_RDY_TIMER:
atCoreStatus = parseT3324TimerValue( pToken, &pPsmSettings->gprsReadyTimer );
atCoreStatus = parseT3324TimerValue( pToken, &( pPsmSettings->gprsReadyTimer ) );
break;

case CPSMS_POS_TAU:
atCoreStatus = parseT3412TimerValue( pToken, &pPsmSettings->periodicTauValue );
atCoreStatus = parseT3412TimerValue( pToken, &( pPsmSettings->periodicTauValue ) );
break;

case CPSMS_POS_ACTIVE_TIME:
atCoreStatus = parseT3324TimerValue( pToken, &pPsmSettings->activeTimeValue );
atCoreStatus = parseT3324TimerValue( pToken, &( pPsmSettings->activeTimeValue ) );
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion source/cellular_3gpp_urc_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext,
}
else
{
pLibAtData = &pContext->libAtData;
pLibAtData = &( pContext->libAtData );

if( isUrc == true )
{
Expand Down
8 changes: 4 additions & 4 deletions source/cellular_at_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ CellularATError_t Cellular_ATRemoveTrailingWhiteSpaces( char * pString )
* when the string length is greater than 2. */
if( stringLen > 2U )
{
p = &pString[ stringLen ];
p = &( pString[ stringLen ] );

do
{
Expand Down Expand Up @@ -571,11 +571,11 @@ CellularATError_t Cellular_ATGetSpecificNextTok( char ** ppString,

if( ( tokStrLen < dataStrlen ) && ( ( *ppString )[ tokStrLen + 1U ] != '\0' ) )
{
*ppString = &tok[ strlen( tok ) + 1U ];
*ppString = &( tok[ strlen( tok ) + 1U ] );
}
else
{
*ppString = &tok[ strlen( tok ) ];
*ppString = &( tok[ strlen( tok ) ] );
}

*ppTokOutput = tok;
Expand Down Expand Up @@ -665,7 +665,7 @@ CellularATError_t Cellular_ATHexStrToHex( const char * pString,
( pHexData )[ i ] = firstNibble | secondNibble;
}

p = &p[ 2 ];
p = &( p[ 2 ] );
}
}

Expand Down
38 changes: 19 additions & 19 deletions source/cellular_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static CellularContext_t * _Cellular_AllocContext( void )
{
#if ( CELLULAR_CONFIG_STATIC_ALLOCATION_CONTEXT == 1 )
{
pContext = &cellularStaticContextTable[ i ];
pContext = &( cellularStaticContextTable[ i ] );
}
#else
{
Expand Down Expand Up @@ -190,7 +190,7 @@ static CellularError_t libOpen( CellularContext_t * pContext )

configASSERT( pContext != NULL );

PlatformMutex_Lock( &pContext->libStatusMutex );
PlatformMutex_Lock( &( pContext->libStatusMutex ) );

( CellularPktStatus_t ) _Cellular_AtParseInit( pContext );
_Cellular_LockAtDataMutex( pContext );
Expand Down Expand Up @@ -223,7 +223,7 @@ static CellularError_t libOpen( CellularContext_t * pContext )
pContext->bLibShutdown = false;
}

PlatformMutex_Unlock( &pContext->libStatusMutex );
PlatformMutex_Unlock( &( pContext->libStatusMutex ) );

return cellularStatus;
}
Expand All @@ -237,12 +237,12 @@ static void libClose( CellularContext_t * pContext )

configASSERT( pContext != NULL );

PlatformMutex_Lock( &pContext->libStatusMutex );
PlatformMutex_Lock( &( pContext->libStatusMutex ) );
bOpened = pContext->bLibOpened;

/* Indicate that CellularLib is in the process of closing. */
pContext->bLibClosing = true;
PlatformMutex_Unlock( &pContext->libStatusMutex );
PlatformMutex_Unlock( &( pContext->libStatusMutex ) );

if( bOpened == true )
{
Expand All @@ -251,7 +251,7 @@ static void libClose( CellularContext_t * pContext )
_Cellular_PktHandlerCleanup( pContext );
}

PlatformMutex_Lock( &pContext->libStatusMutex );
PlatformMutex_Lock( &( pContext->libStatusMutex ) );
pContext->bLibShutdown = false;
pContext->bLibOpened = false;
pContext->bLibClosing = false;
Expand All @@ -270,7 +270,7 @@ static void libClose( CellularContext_t * pContext )
}
}

PlatformMutex_Unlock( &pContext->libStatusMutex );
PlatformMutex_Unlock( &( pContext->libStatusMutex ) );
LogDebug( ( "CELLULARLib closed" ) );
}

Expand All @@ -280,7 +280,7 @@ static bool _Cellular_CreateLibStatusMutex( CellularContext_t * pContext )
{
bool status = false;

status = PlatformMutex_Create( &pContext->libStatusMutex, false );
status = PlatformMutex_Create( &( pContext->libStatusMutex ), false );

return status;
}
Expand All @@ -289,7 +289,7 @@ static bool _Cellular_CreateLibStatusMutex( CellularContext_t * pContext )

static void _Cellular_DestroyLibStatusMutex( CellularContext_t * pContext )
{
PlatformMutex_Destroy( &pContext->libStatusMutex );
PlatformMutex_Destroy( &( pContext->libStatusMutex ) );
}

/*-----------------------------------------------------------*/
Expand Down Expand Up @@ -440,27 +440,27 @@ CellularError_t _Cellular_CheckLibraryStatus( CellularContext_t * pContext )
}
else
{
PlatformMutex_Lock( &pContext->libStatusMutex );
PlatformMutex_Lock( &( pContext->libStatusMutex ) );

if( pContext->bLibOpened == false )
{
cellularStatus = CELLULAR_LIBRARY_NOT_OPEN;
}

PlatformMutex_Unlock( &pContext->libStatusMutex );
PlatformMutex_Unlock( &( pContext->libStatusMutex ) );
}

if( cellularStatus == CELLULAR_SUCCESS )
{
PlatformMutex_Lock( &pContext->libStatusMutex );
PlatformMutex_Lock( &( pContext->libStatusMutex ) );

if( ( pContext->bLibShutdown == true ) || ( pContext->bLibClosing == true ) )
{
LogError( ( "Cellular Lib indicated a failure[%d][%d]", pContext->bLibShutdown, pContext->bLibClosing ) );
cellularStatus = CELLULAR_INTERNAL_FAILURE;
}

PlatformMutex_Unlock( &pContext->libStatusMutex );
PlatformMutex_Unlock( &( pContext->libStatusMutex ) );
}

return cellularStatus;
Expand Down Expand Up @@ -546,7 +546,7 @@ CellularError_t _Cellular_CreateSocketData( CellularContext_t * pContext,
{
#if ( CELLULAR_CONFIG_STATIC_SOCKET_CONTEXT_ALLOCATION == 1 )
{
pSocketData = &cellularStaticSocketDataTable[ socketId ];
pSocketData = &( cellularStaticSocketDataTable[ socketId ] );
}
#else
{
Expand Down Expand Up @@ -961,7 +961,7 @@ CellularError_t _Cellular_LibInit( CellularHandle_t * pCellularHandle,
pContext->pCommIntf = pCommInterface;

/* copy the token table. */
( void ) memcpy( &pContext->tokenTable, pTokenTable, sizeof( CellularTokenTable_t ) );
( void ) memcpy( &( pContext->tokenTable ), pTokenTable, sizeof( CellularTokenTable_t ) );
}
}

Expand Down Expand Up @@ -1118,7 +1118,7 @@ CellularError_t _Cellular_RegisterUndefinedRespCallback( CellularContext_t * pCo
else
{
/* undefinedRespCallback can be set to NULL to unregister the callback. */
PlatformMutex_Lock( &pContext->PktRespMutex );
PlatformMutex_Lock( &( pContext->PktRespMutex ) );
pContext->undefinedRespCallback = undefinedRespCallback;

if( pContext->undefinedRespCallback != NULL )
Expand All @@ -1130,7 +1130,7 @@ CellularError_t _Cellular_RegisterUndefinedRespCallback( CellularContext_t * pCo
pContext->pUndefinedRespCBContext = NULL;
}

PlatformMutex_Unlock( &pContext->PktRespMutex );
PlatformMutex_Unlock( &( pContext->PktRespMutex ) );
}

return cellularStatus;
Expand All @@ -1152,7 +1152,7 @@ CellularError_t _Cellular_RegisterInputBufferCallback( CellularContext_t * pCont
else
{
/* inputBufferCallback can be set to NULL to unregister the callback. */
PlatformMutex_Lock( &pContext->PktRespMutex );
PlatformMutex_Lock( &( pContext->PktRespMutex ) );
pContext->inputBufferCallback = inputBufferCallback;

if( pContext->inputBufferCallback != NULL )
Expand All @@ -1164,7 +1164,7 @@ CellularError_t _Cellular_RegisterInputBufferCallback( CellularContext_t * pCont
pContext->pInputBufferCallbackContext = NULL;
}

PlatformMutex_Unlock( &pContext->PktRespMutex );
PlatformMutex_Unlock( &( pContext->PktRespMutex ) );
}

return cellularStatus;
Expand Down
Loading

0 comments on commit cce929b

Please sign in to comment.