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 warnings in ARM GCC, MCUX, MDK #35

Merged
merged 12 commits into from
Apr 21, 2023
45 changes: 23 additions & 22 deletions Middleware/FreeRTOS/transport_mbedtls/using_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ static CK_RV initializeClientKeys( SSLContext_t * pxCtx,
*
* @return Zero on success.
*/
static int32_t privateKeySigningCallback( void * pvContext,
mbedtls_md_type_t xMdAlg,
const unsigned char * pucHash,
size_t xHashLen,
unsigned char * pucSig,
size_t * pxSigLen,
int32_t ( * piRng )( void *,
unsigned char *,
size_t ),
void * pvRng );
static int privateKeySigningCallback( void * pvContext,
mbedtls_md_type_t xMdAlg,
const unsigned char * pucHash,
size_t xHashLen,
unsigned char * pucSig,
size_t * pxSigLen,
int ( * piRng )( void *,
unsigned char *,
size_t ),
void * pvRng );

/**
* @brief Setup TLS by initializing contexts and setting configurations.
Expand Down Expand Up @@ -480,19 +480,19 @@ static CK_RV initializeClientKeys( SSLContext_t * pxCtx,

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

static int32_t privateKeySigningCallback( void * pvContext,
mbedtls_md_type_t xMdAlg,
const unsigned char * pucHash,
size_t xHashLen,
unsigned char * pucSig,
size_t * pxSigLen,
int32_t ( * piRng )( void *,
unsigned char *,
size_t ),
void * pvRng )
static int privateKeySigningCallback( void * pvContext,
mbedtls_md_type_t xMdAlg,
const unsigned char * pucHash,
size_t xHashLen,
unsigned char * pucSig,
size_t * pxSigLen,
int ( * piRng )( void *,
unsigned char *,
size_t ),
void * pvRng )
{
CK_RV xResult = CKR_OK;
int32_t lFinalResult = 0;
int iFinalResult = 0;
SSLContext_t * pxTLSContext = ( SSLContext_t * ) pvContext;
CK_MECHANISM xMech = { 0 };
CK_BYTE xToBeSigned[ 256 ];
Expand Down Expand Up @@ -568,9 +568,10 @@ static int32_t privateKeySigningCallback( void * pvContext,
if( xResult != CKR_OK )
{
LogError( ( "Failed to sign message using PKCS #11 with error code %02X.", xResult ) );
iFinalResult = -1;
}

return lFinalResult;
return iFinalResult;
}


Expand Down
4 changes: 3 additions & 1 deletion Middleware/NXP/mbedtls_port/mbedtls_freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
/* FreeRTOS includes. */
#include "FreeRTOS.h"

/* C Library includes. */
#include <string.h> /* memset */

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

/**
Expand Down Expand Up @@ -77,4 +80,3 @@ void mbedtls_platform_free( void * ptr )
{
vPortFree( ptr );
}

17 changes: 11 additions & 6 deletions examples/common/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
*
* 1 tab == 4 spaces!
*/
#include <string.h>

/* FreeRTOS Includes */
#include "FreeRTOS.h"
#include "task.h"

#include "FreeRTOS_CLI_Console.h"
#include "FreeRTOS_CLI.h"
#include "kvstore.h"
Expand All @@ -35,6 +36,10 @@
#include "mbedtls/x509_crt.h"
#include "mbedtls/pem.h"

/* C Library Includes*/
#include <string.h>
#include <stdio.h>

/**
* @brief Maximum length of the buffer used to send a command output to console.
* The implementation uses this buffer to return success or failure code along with
Expand Down Expand Up @@ -267,7 +272,7 @@ static int prvWriteCertPemToConsole( const unsigned char * int_ca_cert_der,
const char end[] = "-----END CERTIFICATE-----\r\n";

#define CERT_PER_LINE 64
static char cCertPem[ 4096 ] = { 0 };
static unsigned char cCertPem[ 4096 ] = { 0 };
size_t offset = 0U, certLength = 0U;

ret = mbedtls_pem_write_buffer( start,
Expand All @@ -289,7 +294,7 @@ static int prvWriteCertPemToConsole( const unsigned char * int_ca_cert_der,
}
else
{
uartConsoleIO.write( &cCertPem[ offset ], 1U );
uartConsoleIO.write( ( const char * ) &cCertPem[ offset ], 1U );
}
}
}
Expand Down Expand Up @@ -559,7 +564,7 @@ static BaseType_t prvPKICommandHandler( char * pcWriteBuffer,

if( pkcs11Status != CKR_OK )
{
snprintf( pcWriteBuffer, xWriteBufferLen, "PKCS11 ERR %x", pkcs11Status );
snprintf( pcWriteBuffer, xWriteBufferLen, "PKCS11 ERR %lx", pkcs11Status );
}
else
{
Expand All @@ -585,11 +590,11 @@ static BaseType_t prvPKICommandHandler( char * pcWriteBuffer,
{
if( strncmp( pObjectType, "pub_key", objectTypeLength ) == 0 )
{
pkcs11Status = prvReadAndProvisionPublicKey( pObjectLabel, labelLength );
pkcs11Status = prvReadAndProvisionPublicKey( ( uint8_t * ) pObjectLabel, labelLength );

if( pkcs11Status != CKR_OK )
{
snprintf( pcWriteBuffer, xWriteBufferLen, "PKCS11 ERR %x", pkcs11Status );
snprintf( pcWriteBuffer, xWriteBufferLen, "PKCS11 ERR %lx", pkcs11Status );
}
else
{
Expand Down
13 changes: 12 additions & 1 deletion examples/common/cli/cli_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
#include "FreeRTOS_CLI_Console.h"
#include "fsl_debug_console.h"

/**
* @brief Reads a single byte from the UART console.
* @return Byte read. -1 on failure.
*/
static int32_t prvUARTConsoleGetChar( void );

/**
* @brief UART console blocking read for requested number of bytes.
* Function blocks reading from UART console until the requested
Expand All @@ -46,11 +52,16 @@ static void prvUARTConsoleWrite( const char * const pcOutputBuffer,

xConsoleIO_t uartConsoleIO =
{
.getChar = DbgConsole_Getchar,
.getChar = prvUARTConsoleGetChar,
.read = prvUARTConsoleRead,
.write = prvUARTConsoleWrite
};

static int32_t prvUARTConsoleGetChar( void )
{
return ( int32_t ) DbgConsole_Getchar();
}

int32_t prvUARTConsoleRead( char * const pcInputBuffer,
uint32_t ulInputBufferLen,
uint32_t * pulBytesRead )
Expand Down
2 changes: 0 additions & 2 deletions examples/common/kvstore/kvstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ typedef struct
};
} KVStoreDefaultEntry_t;

typedef enum KVStoreKey KVStoreKey_t;

/* Public function definitions */
BaseType_t KVStore_init( void );

Expand Down
16 changes: 10 additions & 6 deletions examples/common/mqtt_agent/mqtt_agent_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
* @brief The MQTT agent manages the MQTT contexts. This set the handle to the
* context used by this demo.
*/
#define mqttexampleMQTT_CONTEXT_HANDLE ( ( MQTTContextHandle_t ) 0 ) ''
#define mqttexampleMQTT_CONTEXT_HANDLE ( ( MQTTContextHandle_t ) 0 )

/**
* @brief Event Bit corresponding to an MQTT agent state.
Expand Down Expand Up @@ -620,7 +620,7 @@ static MQTTStatus_t prvHandleResubscribe( void )

/* These variables need to stay in scope until command completes. */
static MQTTAgentSubscribeArgs_t xSubArgs = { 0 };
static MQTTSubscribeInfo_t xSubInfo[ MQTT_AGENT_MAX_SUBSCRIPTIONS ] = { 0 };
static MQTTSubscribeInfo_t xSubInfo[ MQTT_AGENT_MAX_SUBSCRIPTIONS ] = { MQTTQoS0 };
static MQTTAgentCommandInfo_t xCommandParams = { 0 };

/* Loop through each subscription in the subscription list and add a subscribe
Expand Down Expand Up @@ -716,7 +716,8 @@ static void prvIncomingPublishCallback( MQTTAgentContext_t * pMqttAgentContext,
MQTTPublishInfo_t * pxPublishInfo )
{
bool xPublishHandled = false;
char cOriginalChar, * pcLocation;
char cOriginalChar;
char * pcLocation;

( void ) packetId;

Expand Down Expand Up @@ -993,7 +994,8 @@ static uint32_t prvGetTimeMs( void )
static bool prvMatchTopicFilterSubscriptions( MQTTPublishInfo_t * pxPublishInfo )
{
uint32_t ulIndex = 0;
bool isMatched = false, publishHandled = false;
bool isMatched = false;
bool publishHandled = false;

xSemaphoreTake( xSubscriptionsMutex, portMAX_DELAY );
{
Expand Down Expand Up @@ -1082,7 +1084,8 @@ MQTTAgentState_t xGetMQTTAgentState( void )
BaseType_t xWaitForMQTTAgentState( MQTTAgentState_t xState,
TickType_t xTicksToWait )
{
EventBits_t xBitsSet, xBitsToWaitFor;
EventBits_t xBitsSet;
EventBits_t xBitsToWaitFor;
BaseType_t xResult = pdFAIL;

if( xState != MQTT_AGENT_STATE_NONE )
Expand All @@ -1108,7 +1111,8 @@ BaseType_t xAddMQTTTopicFilterCallback( const char * pcTopicFilter,
BaseType_t xManageResubscription )
{
BaseType_t xResult = pdFAIL;
uint32_t ulIndex = 0U, ulAvailableIndex = MQTT_AGENT_MAX_SUBSCRIPTIONS;
uint32_t ulIndex = 0U;
uint32_t ulAvailableIndex = MQTT_AGENT_MAX_SUBSCRIPTIONS;

xSemaphoreTake( xSubscriptionsMutex, portMAX_DELAY );
{
Expand Down
34 changes: 0 additions & 34 deletions examples/common/ota/mcuboot_app_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,40 +94,6 @@ static status_t boot_swap_test( void )
return status;
}

static status_t boot_swap_perm( void )
{
uint32_t off;
status_t status;

uint32_t buf[ MFLASH_PAGE_SIZE / 4 ]; /* ensure the buffer is word aligned */
struct image_trailer * image_trailer_p =
( struct image_trailer * ) ( ( uint8_t * ) buf + MFLASH_PAGE_SIZE - sizeof( struct image_trailer ) );

off = FLASH_AREA_IMAGE_2_OFFSET + FLASH_AREA_IMAGE_2_SIZE - MFLASH_PAGE_SIZE;

memset( buf, 0xff, MFLASH_PAGE_SIZE );
memcpy( image_trailer_p->magic, boot_img_magic, sizeof( boot_img_magic ) );
image_trailer_p->image_ok = BOOT_FLAG_SET;

status = mflash_drv_sector_erase( FLASH_AREA_IMAGE_2_OFFSET + FLASH_AREA_IMAGE_2_SIZE - MFLASH_SECTOR_SIZE );

if( status != kStatus_Success )
{
PRINTF( "boot_setstate_perm: failed to erase trailer2\r\n" );
return status;
}

status = mflash_drv_page_program( off, buf );

if( status != kStatus_Success )
{
PRINTF( "boot_setstate_perm: failed to write trailer2\r\n" );
return status;
}

return status;
}

static status_t boot_swap_ok( void )
{
uint32_t off;
Expand Down
16 changes: 10 additions & 6 deletions examples/common/ota/ota_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static void prvOTAAgentTask( void * pvParam )
* @return None.
*/
static void otaAppCallback( OtaJobEvent_t event,
const void * pData )
void * pData )
{
OtaErr_t err = OtaErrUninitialized;

Expand Down Expand Up @@ -768,7 +768,8 @@ static BaseType_t prvMatchClientIdentifierInTopic( const char * pTopic,
size_t clientIdentifierLength )
{
BaseType_t isMatch = pdFALSE;
size_t idx, matchIdx = 0;
size_t idx;
size_t matchIdx = 0;

for( idx = OTA_TOPIC_CLIENT_IDENTIFIER_START_IDX; idx < topicNameLength; idx++ )
{
Expand Down Expand Up @@ -940,14 +941,16 @@ static OtaMqttStatus_t prvMQTTPublish( const char * const pacTopic,
OtaMqttStatus_t otaRet = OtaMqttSuccess;
BaseType_t result;
MQTTStatus_t mqttStatus = MQTTBadParameter;
MQTTPublishInfo_t publishInfo = { 0 };
MQTTPublishInfo_t publishInfo = { MQTTQoS0 };
MQTTAgentCommandInfo_t xCommandParams = { 0 };
MQTTAgentCommandContext_t xCommandContext = { 0 };
uint32_t ulNotifiedValue;

configASSERT( qos <= MQTTQoS2 );

publishInfo.pTopicName = pacTopic;
publishInfo.topicNameLength = topicLen;
publishInfo.qos = qos;
publishInfo.qos = ( MQTTQoS_t ) qos;
publishInfo.pPayload = pMsg;
publishInfo.payloadLength = msgSize;

Expand Down Expand Up @@ -1011,18 +1014,19 @@ static OtaMqttStatus_t prvMQTTUnsubscribe( const char * pTopicFilter,
MQTTStatus_t mqttStatus;
uint32_t ulNotifiedValue;
MQTTAgentSubscribeArgs_t xSubscribeArgs = { 0 };
MQTTSubscribeInfo_t xSubscribeInfo = { 0 };
MQTTSubscribeInfo_t xSubscribeInfo = { MQTTQoS0 };
BaseType_t result;
MQTTAgentCommandInfo_t xCommandParams = { 0 };
MQTTAgentCommandContext_t xCommandContext = { 0 };
OtaMqttStatus_t otaRet = OtaMqttSuccess;

configASSERT( pTopicFilter != NULL );
configASSERT( topicFilterLength > 0 );
configASSERT( ucQoS <= MQTTQoS2 );

xSubscribeInfo.pTopicFilter = pTopicFilter;
xSubscribeInfo.topicFilterLength = topicFilterLength;
xSubscribeInfo.qos = ucQoS;
xSubscribeInfo.qos = ( MQTTQoS_t ) ucQoS;
xSubscribeArgs.pSubscribeInfo = &xSubscribeInfo;
xSubscribeArgs.numSubscriptions = 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
#define FLASH_CONFIG_PAGESIZE 512
#define FLASH_CONFIG_SECTORSIZE 256u * 1024u

#endif // defined ISSI_AT25SFxxxA
#endif /* defined ISSI_AT25SFxxxA */

/* Lookup table related definitions */
#define CMD_INDEX_READ 0
Expand Down Expand Up @@ -124,9 +124,6 @@
#define FLEXSPI_4PAD 2
#define FLEXSPI_8PAD 3

#define FLEXSPI_LUT_SEQ( cmd0, pad0, op0, cmd1, pad1, op1 ) \
( FLEXSPI_LUT_OPERAND0( op0 ) | FLEXSPI_LUT_NUM_PADS0( pad0 ) | FLEXSPI_LUT_OPCODE0( cmd0 ) | FLEXSPI_LUT_OPERAND1( op1 ) | \
FLEXSPI_LUT_NUM_PADS1( pad1 ) | FLEXSPI_LUT_OPCODE1( cmd1 ) )

/*!@brief Definitions for FlexSPI Serial Clock Frequency */
typedef enum _FlexSpiSerialClockFreq
Expand Down
4 changes: 2 additions & 2 deletions examples/evkbmimxrt1060/shadow/shadow_device_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ static void prvGetRejectedCallback( void * pxSubscriptionContext,

static bool prvGetShadowFromCloud( void )
{
static MQTTPublishInfo_t xPublishInfo = { 0 };
static MQTTPublishInfo_t xPublishInfo = { MQTTQoS0 };
MQTTAgentCommandInfo_t xCommandParams = { 0 };
MQTTStatus_t xCommandStatus = MQTTSendFailed;
bool xReturnStatus = false;
Expand Down Expand Up @@ -1128,7 +1128,7 @@ static bool prvGetShadowFromCloud( void )

static bool prvUpdateShadowDocument( void )
{
static MQTTPublishInfo_t xPublishInfo = { 0 };
static MQTTPublishInfo_t xPublishInfo = { MQTTQoS1 };
MQTTAgentCommandInfo_t xCommandParams = { 0 };
MQTTStatus_t xCommandStatus = MQTTSendFailed;
bool xReturnStatus = false;
Expand Down
2 changes: 1 addition & 1 deletion examples/evkbmimxrt1060/shadow/shadow_update_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ void vShadowUpdateTask( void * pvParameters )
{
bool xStatus = true;
uint32_t ulNotificationValue;
static MQTTPublishInfo_t xPublishInfo = { 0 };
static MQTTPublishInfo_t xPublishInfo = { MQTTQoS0 };
MQTTAgentCommandInfo_t xCommandParams = { 0 };
MQTTStatus_t xCommandAdded;
uint32_t desiredState = 0;
Expand Down
Loading