Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler error when -O2 optimzation is enabled #500

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 4 additions & 0 deletions source/ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,15 @@ static DocParseErr_t extractAndStoreArray( const char * pKey,
static DocParseErr_t verifyRequiredParamsExtracted( const JsonDocParam_t * pModelParam,
const JsonDocModel_t * pDocModel );

#if ( otaconfigAllowDowngrade == 0U )
/**
* @brief Validate the version of the update received.
*
* @param[in] pFileContext Information of file to be streamed.
* @return OtaErr_t OtaErrNone if successful, other error codes if failure.
*/
static OtaErr_t validateUpdateVersion( const OtaFileContext_t * pFileContext );
#endif /* #if ( otaconfigAllowDowngrade == 0U ) */

/**
* @brief Check if the JSON can be parsed through the app callback if initial parsing fails.
Expand Down Expand Up @@ -1968,6 +1970,7 @@ static DocParseErr_t initDocModel( JsonDocModel_t * pDocModel,
return err;
}

#if ( otaconfigAllowDowngrade == 0U )
/*
* Validate the version of the update received.
*/
Expand Down Expand Up @@ -2018,6 +2021,7 @@ static OtaErr_t validateUpdateVersion( const OtaFileContext_t * pFileContext )

return err;
}
#endif /* #if ( otaconfigAllowDowngrade == 0U ) */

/* If there is an error in parsing the json, check if it can be handled by external callback. */
static OtaJobParseErr_t handleCustomJob( const char * pJson,
Expand Down
5 changes: 2 additions & 3 deletions source/ota_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,6 @@ OtaErr_t requestJob_Mqtt( const OtaAgentContext_t * pAgentCtx )

pTopicParts[ 1 ] = ( const char * ) pAgentCtx->pThingName;

/* Client token max length is 64. It is a combination of request counter (max 10 characters), a separator colon, and the ThingName. */
xThingNameLength = ( uint32_t ) strnlen( ( const char * ) pAgentCtx->pThingName, OTA_CLIENT_TOKEN_MAX_THINGNAME_LEN );

reqCounterStringLength = ( uint32_t ) stringBuilderUInt32Decimal( reqCounterString, sizeof( reqCounterString ), reqCounter );

/* Assemble the string by copying the pieces into the buffer. This is done manually since we know the size of the thingname. */
Expand All @@ -903,6 +900,8 @@ OtaErr_t requestJob_Mqtt( const OtaAgentContext_t * pAgentCtx )
msgSize += reqCounterStringLength - 1;
strncpy( &pMsg[ msgSize ], ":", MSG_GET_NEXT_BUFFER_SIZE - msgSize );
msgSize++;
/* Client token max length is 64. It is a combination of request counter (max 10 characters), a separator colon, and the ThingName. */
xThingNameLength = ( uint32_t ) strnlen( ( const char * ) pAgentCtx->pThingName, MSG_GET_NEXT_BUFFER_SIZE - msgSize );
strncpy( &pMsg[ msgSize ], ( const char * ) pAgentCtx->pThingName, xThingNameLength );
msgSize += xThingNameLength;
strncpy( &pMsg[ msgSize ], "\"}", MSG_GET_NEXT_BUFFER_SIZE - msgSize );
Expand Down
Loading