1
0
Fork 0

Fix null pointer dereference warnings

This commit is contained in:
Julien PEYREGNE 2021-03-19 09:20:21 +01:00
parent 66d0e14ef4
commit b6f04d65f8
3 changed files with 11 additions and 8 deletions

View file

@ -679,6 +679,10 @@ CO_SDO_return_t CO_SDOserver_process(CO_SDOserver_t *SDO,
uint32_t timeDifference_us,
uint32_t *timerNext_us)
{
if (SDO == NULL) {
return CO_SDO_RT_wrongArguments;
}
(void)timerNext_us; /* may be unused */
CO_SDO_return_t ret = CO_SDO_RT_waitingResponse;
@ -686,10 +690,7 @@ CO_SDO_return_t CO_SDOserver_process(CO_SDOserver_t *SDO,
bool_t isNew = CO_FLAG_READ(SDO->CANrxNew);
if (SDO == NULL) {
ret = CO_SDO_RT_wrongArguments;
}
else if (SDO->valid && SDO->state == CO_SDO_ST_IDLE && !isNew) {
if (SDO->valid && SDO->state == CO_SDO_ST_IDLE && !isNew) {
/* Idle and nothing new */
ret = CO_SDO_RT_ok_communicationEnd;
}

View file

@ -1213,8 +1213,11 @@ CO_ReturnError_t CO_CANopenInitPDO(CO_t *co,
uint8_t nodeId,
uint32_t *errInfo)
{
if (co == NULL || nodeId < 1 || nodeId > 127 || co->nodeIdUnconfigured) {
return (co != NULL || co->nodeIdUnconfigured)
if (co == NULL) {
return CO_ERROR_ILLEGAL_ARGUMENT;
}
if (nodeId < 1 || nodeId > 127 || co->nodeIdUnconfigured) {
return (co->nodeIdUnconfigured)
? CO_ERROR_NODE_ID_UNCONFIGURED_LSS : CO_ERROR_ILLEGAL_ARGUMENT;
}

View file

@ -182,9 +182,8 @@ void CO_CANsetNormalMode(CO_CANmodule_t *CANmodule)
{
CO_ReturnError_t ret;
CANmodule->CANnormal = false;
if(CANmodule != NULL) {
CANmodule->CANnormal = false;
ret = setRxFilters(CANmodule);
if (ret == CO_ERROR_NO) {
/* Put CAN module in normal mode */