Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit e040ca3

Browse files
authored
fix compiler warnings (#158)
1 parent d07870a commit e040ca3

File tree

8 files changed

+28
-27
lines changed

8 files changed

+28
-27
lines changed

STMicroelectronics/STM32L4_L4+/lib/netx_driver/src/es_wifi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ static void AT_ParseIsConnected(char *pdata, uint8_t *isConnected)
692692
static void AT_ParsePing(int32_t res[], uint32_t count,char* pdata)
693693
{
694694
char *ptr;
695-
int i=0;
695+
uint32_t i=0;
696696

697697
ptr= strtok(pdata,",\n\r");
698698
while(ptr)

STMicroelectronics/STM32L4_L4+/lib/netx_driver/src/es_wifi_io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ int wait_cmddata_rdy_high(int timeout)
267267
int tickstart = HAL_GetTick();
268268
while (WIFI_IS_CMDDATA_READY()==0)
269269
{
270-
if((HAL_GetTick() - tickstart ) > timeout)
270+
if(((int)HAL_GetTick() - tickstart ) > timeout)
271271
{
272272
return -1;
273273
}
@@ -285,7 +285,7 @@ int wait_cmddata_rdy_rising_event(int timeout)
285285
int tickstart = HAL_GetTick();
286286
while (cmddata_rdy_rising_event==1)
287287
{
288-
if((HAL_GetTick() - tickstart ) > timeout)
288+
if(((int)HAL_GetTick() - tickstart ) > timeout)
289289
{
290290
return -1;
291291
}
@@ -302,7 +302,7 @@ int wait_spi_rx_event(int timeout)
302302
int tickstart = HAL_GetTick();
303303
while (spi_rx_event==1)
304304
{
305-
if((HAL_GetTick() - tickstart ) > timeout)
305+
if(((int)HAL_GetTick() - tickstart ) > timeout)
306306
{
307307
return -1;
308308
}
@@ -319,7 +319,7 @@ int wait_spi_tx_event(int timeout)
319319
int tickstart = HAL_GetTick();
320320
while (spi_tx_event==1)
321321
{
322-
if((HAL_GetTick() - tickstart ) > timeout)
322+
if(((int)HAL_GetTick() - tickstart ) > timeout)
323323
{
324324
return -1;
325325
}

cmake/arm-gcc-cortex-toolchain.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
6868
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
6969
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
7070

71-
set(CMAKE_COMMON_FLAGS "--specs=nano.specs -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin -fshort-enums -Wunused -Wuninitialized -Wall -Wshadow -Wdouble-promotion -Werror")
71+
set(CMAKE_COMMON_FLAGS "--specs=nano.specs -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin -fshort-enums -Wall -Wextra -Wuninitialized -Wshadow -Wdouble-promotion -Werror -Wno-unused-parameter")
7272
set(CMAKE_C_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} ${CMAKE_COMMON_FLAGS}")
7373
set(CMAKE_CXX_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} ${CMAKE_COMMON_FLAGS}")
7474
set(CMAKE_ASM_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS}")

core/src/azure_iot_mqtt/azure_iot_dps_mqtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static VOID mqtt_notify_cb(NXD_MQTT_CLIENT* client_ptr, UINT number_of_messages)
115115

116116
AZURE_IOT_MQTT* azure_iot_mqtt = (AZURE_IOT_MQTT*)client_ptr->nxd_mqtt_packet_receive_context;
117117

118-
for (int count = 0; count < number_of_messages; ++count)
118+
for (UINT count = 0; count < number_of_messages; ++count)
119119
{
120120
// Get the mqtt client message
121121
status = nxd_mqtt_client_message_get(client_ptr,

core/src/azure_iot_mqtt/azure_iot_mqtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static VOID mqtt_notify_cb(NXD_MQTT_CLIENT* client_ptr, UINT number_of_messages)
348348

349349
AZURE_IOT_MQTT* azure_iot_mqtt = (AZURE_IOT_MQTT*)client_ptr->nxd_mqtt_packet_receive_context;
350350

351-
for (int count = 0; count < number_of_messages; ++count)
351+
for (UINT count = 0; count < number_of_messages; ++count)
352352
{
353353
// Get the mqtt client message
354354
status = nxd_mqtt_client_message_get(client_ptr,

core/src/azure_iot_nx/azure_iot_nx_client.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#define MODULE_ID ""
2222
#define DPS_PAYLOAD "{\"modelId\":\"%s\"}"
2323

24+
#define DPS_PAYLOAD_SIZE 200
25+
#define PUBLISH_BUFFER_SIZE 64
26+
2427
static VOID connection_status_callback(NX_AZURE_IOT_HUB_CLIENT* hub_client_ptr, UINT status)
2528
{
2629
if (status)
@@ -95,7 +98,7 @@ static VOID process_device_twin_get(AZURE_IOT_NX_CONTEXT* nx_context)
9598
UINT status;
9699
NX_PACKET* packet_ptr;
97100
NX_AZURE_IOT_JSON_READER json_reader;
98-
UCHAR buffer[128];
101+
UCHAR buffer[PUBLISH_BUFFER_SIZE];
99102

100103
if ((status = nx_azure_iot_hub_client_device_twin_properties_receive(
101104
&nx_context->iothub_client, &packet_ptr, NX_WAIT_FOREVER)))
@@ -127,7 +130,7 @@ static VOID process_device_twin_get(AZURE_IOT_NX_CONTEXT* nx_context)
127130
NX_NULL,
128131
0,
129132
buffer,
130-
sizeof(buffer),
133+
PUBLISH_BUFFER_SIZE,
131134
nx_context->device_twin_get_cb,
132135
nx_context)))
133136
{
@@ -430,7 +433,7 @@ UINT azure_iot_nx_client_dps_create(AZURE_IOT_NX_CONTEXT* context,
430433
CHAR* device_model_id)
431434
{
432435
UINT status;
433-
CHAR payload[200];
436+
CHAR payload[DPS_PAYLOAD_SIZE];
434437
UINT iot_hub_hostname_len = AZURE_IOT_HOST_NAME_SIZE;
435438
UINT iot_device_id_len = AZURE_IOT_DEVICE_ID_SIZE;
436439

@@ -453,7 +456,7 @@ UINT azure_iot_nx_client_dps_create(AZURE_IOT_NX_CONTEXT* context,
453456

454457
memset(context, 0, sizeof(AZURE_IOT_NX_CONTEXT));
455458

456-
if (snprintf(payload, sizeof(payload), DPS_PAYLOAD, device_model_id) > sizeof(payload) - 1)
459+
if (snprintf(payload, sizeof(payload), DPS_PAYLOAD, device_model_id) > DPS_PAYLOAD_SIZE - 1)
457460
{
458461
printf("ERROR: insufficient buffer size to create DPS payload\r\n");
459462
return NX_SIZE_ERROR;
@@ -610,13 +613,13 @@ UINT azure_iot_nx_client_disconnect(AZURE_IOT_NX_CONTEXT* context)
610613
UINT azure_iot_nx_client_publish_float_telemetry(AZURE_IOT_NX_CONTEXT* context, CHAR* key, float value)
611614
{
612615
UINT status;
613-
CHAR buffer[30];
616+
CHAR buffer[PUBLISH_BUFFER_SIZE];
614617
NX_PACKET* packet_ptr;
615618

616-
int intvalue = value;
619+
int intvalue = value;
617620
int fracvalue = abs(100 * (value - (long)value));
618621

619-
if (snprintf(buffer, sizeof(buffer), "{\"%s\":%d.%2d}", key, intvalue, fracvalue) > sizeof(buffer) - 1)
622+
if (snprintf(buffer, PUBLISH_BUFFER_SIZE, "{\"%s\":%d.%2d}", key, intvalue, fracvalue) > PUBLISH_BUFFER_SIZE - 1)
620623
{
621624
printf("ERROR: insufficient buffer size to publish float telemetry\r\n");
622625
return NX_SIZE_ERROR;
@@ -649,12 +652,12 @@ UINT azure_iot_nx_client_publish_float_property(AZURE_IOT_NX_CONTEXT* context, C
649652
UINT response_status;
650653
UINT request_id;
651654
ULONG version;
652-
CHAR buffer[30];
655+
CHAR buffer[PUBLISH_BUFFER_SIZE];
653656

654-
int intvalue = value;
657+
int intvalue = value;
655658
int fracvalue = abs(100 * (value - (long)value));
656659

657-
if (snprintf(buffer, sizeof(buffer), "{\"%s\":%d.%2d}", key, intvalue, fracvalue) > sizeof(buffer) - 1)
660+
if (snprintf(buffer, PUBLISH_BUFFER_SIZE, "{\"%s\":%d.%2d}", key, intvalue, fracvalue) > PUBLISH_BUFFER_SIZE - 1)
658661
{
659662
printf("ERROR: insufficient buffer size to publish float property\r\n");
660663
return NX_SIZE_ERROR;
@@ -689,9 +692,9 @@ UINT azure_iot_nx_client_publish_bool_property(AZURE_IOT_NX_CONTEXT* context, CH
689692
UINT response_status;
690693
UINT request_id;
691694
ULONG version;
692-
CHAR buffer[64];
695+
CHAR buffer[PUBLISH_BUFFER_SIZE];
693696

694-
if (snprintf(buffer, sizeof(buffer), "{\"%s\":%s}", key, (value ? "true" : "false")) > sizeof(buffer) - 1)
697+
if (snprintf(buffer, PUBLISH_BUFFER_SIZE, "{\"%s\":%s}", key, (value ? "true" : "false")) > PUBLISH_BUFFER_SIZE - 1)
695698
{
696699
printf("ERROR: Unsufficient buffer size to publish bool property\r\n");
697700
return NX_SIZE_ERROR;
@@ -727,17 +730,17 @@ UINT azure_nx_client_respond_int_writeable_property(
727730
UINT response_status;
728731
UINT request_id;
729732
ULONG version_dt;
730-
CHAR message[100];
733+
CHAR message[PUBLISH_BUFFER_SIZE];
731734

732735
printf("Responding to writeable property %s = %d\r\n", property, value);
733736

734737
if (snprintf(message,
735-
sizeof(message),
738+
PUBLISH_BUFFER_SIZE,
736739
"{\"%s\":{\"value\":%d,\"ac\":%d,\"av\":%d}}",
737740
property,
738741
value,
739742
http_status,
740-
version) > sizeof(message) - 1)
743+
version) > PUBLISH_BUFFER_SIZE - 1)
741744
{
742745
printf("ERROR: insufficient buffer size to respond to writeable property\r\n");
743746
return NX_SIZE_ERROR;

core/src/json_utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bool findJsonInt(const char* json, jsmntok_t* tokens, int tokens_count, const ch
1313
{
1414
if (tokens[i].type == JSMN_STRING && tokens[i + 1].type == JSMN_PRIMITIVE)
1515
{
16-
if ((strlen(s) == tokens[i].end - tokens[i].start) &&
16+
if (((int)strlen(s) == tokens[i].end - tokens[i].start) &&
1717
(strncmp(json + tokens[i].start, s, tokens[i].end - tokens[i].start) == 0))
1818
{
1919
*value = atoi(json + tokens[i + 1].start);
@@ -35,7 +35,7 @@ bool findJsonString(const char* json, jsmntok_t* tokens, int tokens_count, const
3535
if (tokens[i].type == JSMN_STRING && tokens[i + 1].type == JSMN_STRING)
3636
{
3737
key_len = tokens[i].end - tokens[i].start;
38-
if ((strlen(s) == key_len) && (strncmp(json + tokens[i].start, s, key_len) == 0))
38+
if (((int)strlen(s) == key_len) && (strncmp(json + tokens[i].start, s, key_len) == 0))
3939
{
4040
value_len = tokens[i + 1].end - tokens[i + 1].start;
4141
strncpy(value, json + tokens[i + 1].start, value_len);

core/src/newlib_nano.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ void _exit(int status)
6464

6565
void _kill(int pid, int sig)
6666
{
67-
(void)pid;
68-
(void)sig;
6967
return;
7068
}
7169

0 commit comments

Comments
 (0)