Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ CRSM
CSDK
ctest
DCMOCK
DCOV
decihours
Decihours
DECIHOURS
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
path: ./

formatting:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check formatting
Expand Down
8 changes: 8 additions & 0 deletions MISRA.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ _Ref 4.6.1_
We do not have control over these functions so we are suppressing these
violations.

_Ref 4.6.2_

- MISRA C-2012 Directive 4.6 warns against using types that do not contain size
and sign information. However, in this case, the search function requires a
comparison function pointer that returns a value of type int. To maintain
compatibility with the search function's expected prototype, the comparison
function must return an int type value despite the MISRA guidance.

#### Directive 4.7

_Ref 4.7.1_
Expand Down
28 changes: 14 additions & 14 deletions source/cellular_3gpp_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ static CellularError_t queryNetworkStatus( CellularContext_t * pContext,
atReqGetResult.pAtCmd = pCommand;
atReqGetResult.atCmdType = CELLULAR_AT_MULTI_WITH_PREFIX;
atReqGetResult.pAtRspPrefix = pPrefix;
atReqGetResult.respCallback = _Cellular_RecvFuncGetNetworkReg;
atReqGetResult.respCallback = &_Cellular_RecvFuncGetNetworkReg;
atReqGetResult.pData = &recvRegType;
atReqGetResult.dataLen = ( uint16_t ) sizeof( CellularNetworkRegType_t );

Expand Down Expand Up @@ -1429,7 +1429,7 @@ static CellularError_t atcmdUpdateMccMnc( CellularContext_t * pContext,
atCopsRequest.pAtCmd = "AT+COPS?";
atCopsRequest.atCmdType = CELLULAR_AT_WITH_PREFIX;
atCopsRequest.pAtRspPrefix = "+COPS";
atCopsRequest.respCallback = _Cellular_RecvFuncUpdateMccMnc;
atCopsRequest.respCallback = &_Cellular_RecvFuncUpdateMccMnc;
atCopsRequest.pData = pOperatorInfo;
atCopsRequest.dataLen = ( uint16_t ) sizeof( cellularOperatorInfo_t );
pktStatus = _Cellular_AtcmdRequestWithCallback( pContext, atCopsRequest );
Expand Down Expand Up @@ -1638,7 +1638,7 @@ CellularError_t Cellular_CommonGetEidrxSettings( CellularHandle_t cellularHandle
atReqGetEidrx.pAtCmd = "AT+CEDRXS?";
atReqGetEidrx.atCmdType = CELLULAR_AT_MULTI_WITH_PREFIX;
atReqGetEidrx.pAtRspPrefix = "+CEDRXS";
atReqGetEidrx.respCallback = _Cellular_RecvFuncGetEidrxSettings;
atReqGetEidrx.respCallback = &_Cellular_RecvFuncGetEidrxSettings;
atReqGetEidrx.pData = pEidrxSettingsList;
atReqGetEidrx.dataLen = CELLULAR_EDRX_LIST_MAX_SIZE;

Expand Down Expand Up @@ -1898,7 +1898,7 @@ CellularError_t Cellular_CommonGetNetworkTime( CellularHandle_t cellularHandle,
atReqGetNetworkTime.pAtCmd = "AT+CCLK?";
atReqGetNetworkTime.atCmdType = CELLULAR_AT_WITH_PREFIX;
atReqGetNetworkTime.pAtRspPrefix = "+CCLK";
atReqGetNetworkTime.respCallback = _Cellular_RecvFuncGetNetworkTime;
atReqGetNetworkTime.respCallback = &_Cellular_RecvFuncGetNetworkTime;
atReqGetNetworkTime.pData = pNetworkTime;
atReqGetNetworkTime.dataLen = ( uint16_t ) sizeof( CellularTime_t );

Expand Down Expand Up @@ -1943,28 +1943,28 @@ CellularError_t Cellular_CommonGetModemInfo( CellularHandle_t cellularHandle,
atReqGetFirmwareVersion.pAtCmd = "AT+CGMR";
atReqGetFirmwareVersion.atCmdType = CELLULAR_AT_WO_PREFIX;
atReqGetFirmwareVersion.pAtRspPrefix = NULL;
atReqGetFirmwareVersion.respCallback = _Cellular_RecvFuncGetFirmwareVersion;
atReqGetFirmwareVersion.respCallback = &_Cellular_RecvFuncGetFirmwareVersion;
atReqGetFirmwareVersion.pData = pModemInfo->firmwareVersion;
atReqGetFirmwareVersion.dataLen = CELLULAR_FW_VERSION_MAX_SIZE + 1U;

atReqGetImei.pAtCmd = "AT+CGSN";
atReqGetImei.atCmdType = CELLULAR_AT_WO_PREFIX;
atReqGetImei.pAtRspPrefix = NULL;
atReqGetImei.respCallback = _Cellular_RecvFuncGetImei;
atReqGetImei.respCallback = &_Cellular_RecvFuncGetImei;
atReqGetImei.pData = pModemInfo->imei;
atReqGetImei.dataLen = CELLULAR_IMEI_MAX_SIZE + 1U;

atReqGetModelId.pAtCmd = "AT+CGMM";
atReqGetModelId.atCmdType = CELLULAR_AT_WO_PREFIX;
atReqGetModelId.pAtRspPrefix = NULL;
atReqGetModelId.respCallback = _Cellular_RecvFuncGetModelId;
atReqGetModelId.respCallback = &_Cellular_RecvFuncGetModelId;
atReqGetModelId.pData = pModemInfo->modelId;
atReqGetModelId.dataLen = CELLULAR_MODEL_ID_MAX_SIZE + 1U;

atReqGetManufactureId.pAtCmd = "AT+CGMI";
atReqGetManufactureId.atCmdType = CELLULAR_AT_WO_PREFIX;
atReqGetManufactureId.pAtRspPrefix = NULL;
atReqGetManufactureId.respCallback = _Cellular_RecvFuncGetManufactureId;
atReqGetManufactureId.respCallback = &_Cellular_RecvFuncGetManufactureId;
atReqGetManufactureId.pData = pModemInfo->manufactureId;
atReqGetManufactureId.dataLen = CELLULAR_MANUFACTURE_ID_MAX_SIZE + 1U;

Expand Down Expand Up @@ -2031,7 +2031,7 @@ CellularError_t Cellular_CommonGetIPAddress( CellularHandle_t cellularHandle,
atReqGetIp.pAtCmd = cmdBuf;
atReqGetIp.atCmdType = CELLULAR_AT_WITH_PREFIX;
atReqGetIp.pAtRspPrefix = "+CGPADDR";
atReqGetIp.respCallback = _Cellular_RecvFuncIpAddress;
atReqGetIp.respCallback = &_Cellular_RecvFuncIpAddress;
atReqGetIp.pData = pBuffer;
atReqGetIp.dataLen = ( uint16_t ) bufferLength;

Expand Down Expand Up @@ -2689,7 +2689,7 @@ CellularError_t Cellular_CommonGetSimCardLockStatus( CellularHandle_t cellularHa
atReqGetSimLockStatus.pAtCmd = "AT+CPIN?";
atReqGetSimLockStatus.atCmdType = CELLULAR_AT_WITH_PREFIX;
atReqGetSimLockStatus.pAtRspPrefix = "+CPIN";
atReqGetSimLockStatus.respCallback = _Cellular_RecvFuncGetSimLockStatus;
atReqGetSimLockStatus.respCallback = &_Cellular_RecvFuncGetSimLockStatus;
atReqGetSimLockStatus.pData = &( pSimCardStatus->simCardLockState );
atReqGetSimLockStatus.dataLen = ( uint16_t ) sizeof( CellularSimCardLockState_t );

Expand Down Expand Up @@ -2721,22 +2721,22 @@ CellularError_t Cellular_CommonGetSimCardInfo( CellularHandle_t cellularHandle,
atReqGetIccid.pAtCmd = "AT+CCID";
atReqGetIccid.atCmdType = CELLULAR_AT_WITH_PREFIX;
atReqGetIccid.pAtRspPrefix = "+CCID";
atReqGetIccid.respCallback = _Cellular_RecvFuncGetIccid;
atReqGetIccid.respCallback = &_Cellular_RecvFuncGetIccid;
atReqGetIccid.pData = pSimCardInfo->iccid;
atReqGetIccid.dataLen = CELLULAR_ICCID_MAX_SIZE + 1U;
#endif

atReqGetImsi.pAtCmd = "AT+CIMI";
atReqGetImsi.atCmdType = CELLULAR_AT_WO_PREFIX;
atReqGetImsi.pAtRspPrefix = NULL;
atReqGetImsi.respCallback = _Cellular_RecvFuncGetImsi;
atReqGetImsi.respCallback = &_Cellular_RecvFuncGetImsi;
atReqGetImsi.pData = pSimCardInfo->imsi;
atReqGetImsi.dataLen = CELLULAR_IMSI_MAX_SIZE + 1U;

atReqGetHplmn.pAtCmd = "AT+CRSM=176,28514,0,0,0"; /* READ BINARY command. HPLMN Selector with Access Technology( 6F62 ). */
atReqGetHplmn.atCmdType = CELLULAR_AT_WITH_PREFIX;
atReqGetHplmn.pAtRspPrefix = "+CRSM";
atReqGetHplmn.respCallback = _Cellular_RecvFuncGetHplmn;
atReqGetHplmn.respCallback = &_Cellular_RecvFuncGetHplmn;
atReqGetHplmn.pData = &( pSimCardInfo->plmn );
atReqGetHplmn.dataLen = ( uint16_t ) sizeof( CellularPlmnInfo_t );

Expand Down Expand Up @@ -3025,7 +3025,7 @@ CellularError_t Cellular_CommonGetPsmSettings( CellularHandle_t cellularHandle,
atReqGetPsm.pAtCmd = "AT+CPSMS?";
atReqGetPsm.atCmdType = CELLULAR_AT_WITH_PREFIX;
atReqGetPsm.pAtRspPrefix = "+CPSMS";
atReqGetPsm.respCallback = _Cellular_RecvFuncGetPsmSettings;
atReqGetPsm.respCallback = &_Cellular_RecvFuncGetPsmSettings;
atReqGetPsm.pData = pPsmSettings;
atReqGetPsm.dataLen = ( uint16_t ) sizeof( CellularPsmSettings_t );

Expand Down
18 changes: 7 additions & 11 deletions source/cellular_3gpp_urc_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static CellularPktStatus_t _parseRejectCauseInRegStatus( CellularNetworkRegType_
static CellularPktStatus_t _parseRoutingAreaCodeInRegStatus( const char * pToken,
cellularAtData_t * pLibAtData );
static CellularPktStatus_t _regStatusSwitchParsingFunc( CellularContext_t * pContext,
uint8_t i,
uint8_t regPos,
CellularNetworkRegType_t regType,
const char * pToken,
cellularAtData_t * pLibAtData );
Expand Down Expand Up @@ -746,15 +746,15 @@ CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext,
switch( regType )
{
case CELLULAR_REG_TYPE_CREG:
pRegStatusParsingFunc = _regStatusSwitchParsingFuncCreg;
pRegStatusParsingFunc = &_regStatusSwitchParsingFuncCreg;
break;

case CELLULAR_REG_TYPE_CGREG:
pRegStatusParsingFunc = _regStatusSwitchParsingFuncCgreg;
pRegStatusParsingFunc = &_regStatusSwitchParsingFuncCgreg;
break;

case CELLULAR_REG_TYPE_CEREG:
pRegStatusParsingFunc = _regStatusSwitchParsingFuncCereg;
pRegStatusParsingFunc = &_regStatusSwitchParsingFuncCereg;
break;

default:
Expand Down Expand Up @@ -809,13 +809,9 @@ CellularPktStatus_t _Cellular_ParseRegStatus( CellularContext_t * pContext,

packetStatus = pRegStatusParsingFunc( pContext, i, pToken, pLibAtData );

if( packetStatus != CELLULAR_PKT_STATUS_OK )
{
break;
}

/* Getting next token to parse. */
if( Cellular_ATGetNextTok( &pRegStr, &pToken ) != CELLULAR_AT_SUCCESS )
/* Continue only if status is OK and we can get the next token */
if( ( packetStatus != CELLULAR_PKT_STATUS_OK ) ||
( Cellular_ATGetNextTok( &pRegStr, &pToken ) != CELLULAR_AT_SUCCESS ) )
{
break;
}
Expand Down
4 changes: 2 additions & 2 deletions source/cellular_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ static CellularError_t libOpen( CellularContext_t * pContext )
_Cellular_LockAtDataMutex( pContext );
_Cellular_InitAtData( pContext, 0 );
_Cellular_UnlockAtDataMutex( pContext );
_Cellular_SetShutdownCallback( pContext, _shutdownCallback );
_Cellular_SetShutdownCallback( pContext, &_shutdownCallback );
pktStatus = _Cellular_PktHandlerInit( pContext );

if( pktStatus == CELLULAR_PKT_STATUS_OK )
{
pktStatus = _Cellular_PktioInit( pContext, _Cellular_HandlePacket );
pktStatus = _Cellular_PktioInit( pContext, &_Cellular_HandlePacket );

if( pktStatus != CELLULAR_PKT_STATUS_OK )
{
Expand Down
18 changes: 12 additions & 6 deletions source/cellular_pkthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ static CellularPktStatus_t _Cellular_DataSendWithTimeoutDelayRaw( CellularContex
uint32_t timeoutMs );
static void _Cellular_PktHandlerAcquirePktRequestMutex( CellularContext_t * pContext );
static void _Cellular_PktHandlerReleasePktRequestMutex( CellularContext_t * pContext );
static int32_t _searchCompareFunc( const void * pInputToken,
const void * pBase );
static int _searchCompareFunc( const void * pInputToken,
const void * pBase );
static int32_t _sortCompareFunc( const void * pElem1Ptr,
const void * pElem2Ptr );
static CellularPktStatus_t _atParseGetHandler( CellularContext_t * pContext,
Expand Down Expand Up @@ -360,10 +360,16 @@ static void _Cellular_PktHandlerReleasePktRequestMutex( CellularContext_t * pCon

/*-----------------------------------------------------------*/

static int32_t _searchCompareFunc( const void * pInputToken,
const void * pBase )
/* MISRA Ref 4.6. [Basic numerical type] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#directive-46 */
/* coverity[misra_c_2012_directive_4_6_violation] */
static int _searchCompareFunc( const void * pInputToken,
const void * pBase )
{
int32_t compareValue = 0;
/* MISRA Ref 4.6. [Basic numerical type] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Cellular-Interface/blob/main/MISRA.md#directive-46 */
/* coverity[misra_c_2012_directive_4_6_violation] */
int compareValue = 0;
const char * pToken = ( const char * ) pInputToken;
const CellularAtParseTokenMap_t * pBasePtr = ( const CellularAtParseTokenMap_t * ) pBase;
uint32_t tokenLen = ( uint32_t ) strlen( pInputToken );
Expand Down Expand Up @@ -441,7 +447,7 @@ static CellularPktStatus_t _atParseGetHandler( CellularContext_t * pContext,
( const void * ) pTokenMap,
tokenMapSize,
sizeof( CellularAtParseTokenMap_t ),
_searchCompareFunc );
&_searchCompareFunc );

if( pElementPtr != NULL )
{
Expand Down
4 changes: 2 additions & 2 deletions source/cellular_pktio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ static void _pktioReadThread( void * pUserData )

/* Open main communication port. */
if( ( pContext->pCommIntf != NULL ) &&
( pContext->pCommIntf->open( _Cellular_PktRxCallBack, ( void * ) pContext,
( pContext->pCommIntf->open( &_Cellular_PktRxCallBack, ( void * ) pContext,
&( pContext->hPktioCommIntf ) ) == IOT_COMM_INTERFACE_SUCCESS ) )
{
/* Send thread started event. */
Expand Down Expand Up @@ -1370,7 +1370,7 @@ CellularPktStatus_t _Cellular_PktioInit( CellularContext_t * pContext,
( ( PlatformEventBits_t ) PKTIO_EVT_MASK_ALL_EVENTS ) );

/* Create the Read thread. */
status = Platform_CreateDetachedThread( _pktioReadThread,
status = Platform_CreateDetachedThread( &_pktioReadThread,
( void * ) pContext,
PLATFORM_THREAD_DEFAULT_PRIORITY,
PLATFORM_THREAD_DEFAULT_STACK_SIZE );
Expand Down
4 changes: 2 additions & 2 deletions tools/coverity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Go to the root directory of the library and run the following commands in termin
~~~
2. Create the build files using CMake in a `build` directory
~~~
cmake -B build -S test
cmake -B build -S test -DCOV_ANALYSIS=ON
~~~
3. Go to the build directory and copy the coverity configuration file
~~~
Expand Down Expand Up @@ -62,7 +62,7 @@ Go to the root directory of the library and run the following commands in termin
For your convenience the commands above are below to be copy/pasted into a UNIX command friendly terminal.
~~~
cov-configure --force --compiler cc --comptype gcc;
cmake -B build -S test;
cmake -B build -S test -DCOV_ANALYSIS=ON;
cd build/;
cov-build --emit-complementary-info --dir cov-out make coverity_analysis;
cd cov-out/
Expand Down