From ca44460359f83e2ba9bd51681f95f14c8b3b0737 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Thu, 2 Feb 2023 16:27:29 +0100 Subject: [PATCH] esp_netif: Fix Wno-format issues --- components/esp_netif/CMakeLists.txt | 1 - components/esp_netif/esp_netif_handlers.c | 20 +++++++++---------- components/esp_netif/esp_netif_objects.c | 4 ++-- components/esp_netif/lwip/esp_netif_br_glue.c | 16 +++++++-------- components/esp_netif/lwip/esp_netif_lwip.c | 17 ++++++++-------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/components/esp_netif/CMakeLists.txt b/components/esp_netif/CMakeLists.txt index ceb1d30a5c..77a10dad84 100644 --- a/components/esp_netif/CMakeLists.txt +++ b/components/esp_netif/CMakeLists.txt @@ -65,5 +65,4 @@ if(CONFIG_ESP_NETIF_L2_TAP OR CONFIG_ESP_NETIF_BRIDGE_EN) endif() -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") target_compile_definitions(${COMPONENT_LIB} PRIVATE ESP_NETIF_COMPONENT_BUILD) diff --git a/components/esp_netif/esp_netif_handlers.c b/components/esp_netif/esp_netif_handlers.c index 4752106250..2163e74cb4 100644 --- a/components/esp_netif/esp_netif_handlers.c +++ b/components/esp_netif/esp_netif_handlers.c @@ -22,20 +22,20 @@ static const char *TAG = "esp_netif_handlers"; void esp_netif_action_start(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action has started with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action has started with netif%p from event_id=%" PRId32, esp_netif, event_id); esp_netif_start(esp_netif); } void esp_netif_action_stop(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action stopped with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action stopped with netif%p from event_id=%" PRId32, esp_netif, event_id); esp_netif_stop(esp_netif); } void esp_netif_action_connected(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action connected with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action connected with netif%p from event_id=%" PRId32, esp_netif, event_id); esp_netif_up(esp_netif); if (!(esp_netif_get_flags(esp_netif) & ESP_NETIF_DHCP_CLIENT)) { @@ -71,7 +71,7 @@ void esp_netif_action_connected(void *esp_netif, esp_event_base_t base, int32_t ESP_NETIF_CALL_CHECK("esp_event_post in esp_netif_action_connected", esp_event_post(IP_EVENT, esp_netif_get_event_id(esp_netif, ESP_NETIF_IP_EVENT_GOT_IP) , &evt, sizeof(evt), 0), ESP_OK); - ESP_LOGD(TAG, "static ip: ip changed=%d", evt.ip_changed); + ESP_LOGD(TAG, "static ip: ip changed=%s", evt.ip_changed ? "true":"false"); } else { ESP_LOGE(TAG, "invalid static ip"); } @@ -81,14 +81,14 @@ void esp_netif_action_connected(void *esp_netif, esp_event_base_t base, int32_t void esp_netif_action_disconnected(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action disconnected with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action disconnected with netif%p from event_id=%" PRId32, esp_netif, event_id); esp_netif_down(esp_netif); } void esp_netif_action_got_ip(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action got_ip with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action got_ip with netif%p from event_id=%" PRId32, esp_netif, event_id); const ip_event_got_ip_t *event = (const ip_event_got_ip_t *) data; ESP_LOGI(TAG, "%s ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR, esp_netif_get_desc(esp_netif), IP2STR(&event->ip_info.ip), @@ -98,28 +98,28 @@ void esp_netif_action_got_ip(void *esp_netif, esp_event_base_t base, int32_t eve void esp_netif_action_join_ip6_multicast_group(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action join_ip6_multicast group with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action join_ip6_multicast group with netif%p from event_id=%" PRId32, esp_netif, event_id); const esp_ip6_addr_t *addr = (const esp_ip6_addr_t *)data; esp_netif_join_ip6_multicast_group(esp_netif, addr); } void esp_netif_action_leave_ip6_multicast_group(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action leave_ip6_multicast_group with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action leave_ip6_multicast_group with netif%p from event_id=%" PRId32, esp_netif, event_id); const esp_ip6_addr_t *addr = (const esp_ip6_addr_t *)data; esp_netif_leave_ip6_multicast_group(esp_netif, addr); } void esp_netif_action_add_ip6_address(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action add_ip6_address with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action add_ip6_address with netif%p from event_id=%" PRId32, esp_netif, event_id); const ip_event_add_ip6_t *addr = (const ip_event_add_ip6_t *)data; esp_netif_add_ip6_address(esp_netif, addr); } void esp_netif_action_remove_ip6_address(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) { - ESP_LOGD(TAG, "esp_netif action remove_ip6_address with netif%p from event_id=%d", esp_netif, event_id); + ESP_LOGD(TAG, "esp_netif action remove_ip6_address with netif%p from event_id=%" PRId32, esp_netif, event_id); const esp_ip6_addr_t *addr = (const esp_ip6_addr_t *)data; esp_netif_remove_ip6_address(esp_netif, addr); } diff --git a/components/esp_netif/esp_netif_objects.c b/components/esp_netif/esp_netif_objects.c index 490a91c7e0..0a19c8f1a0 100644 --- a/components/esp_netif/esp_netif_objects.c +++ b/components/esp_netif/esp_netif_objects.c @@ -74,7 +74,7 @@ esp_err_t esp_netif_add_to_list(esp_netif_t *netif) SLIST_INSERT_HEAD(&s_head, item, next); ++s_esp_netif_counter; - ESP_LOGD(TAG, "%s netif added successfully (total netifs: %d)", __func__, s_esp_netif_counter); + ESP_LOGD(TAG, "%s netif added successfully (total netifs: %" PRIu32 ")", __func__, (uint32_t)s_esp_netif_counter); esp_netif_list_unlock(); return ESP_OK; } @@ -94,7 +94,7 @@ esp_err_t esp_netif_remove_from_list(esp_netif_t *netif) SLIST_REMOVE(&s_head, item, slist_netifs_s, next); assert(s_esp_netif_counter > 0); --s_esp_netif_counter; - ESP_LOGD(TAG, "%s netif successfully removed (total netifs: %d)", __func__, s_esp_netif_counter); + ESP_LOGD(TAG, "%s netif successfully removed (total netifs: %" PRIu32 ")", __func__, (uint32_t)s_esp_netif_counter); free(item); esp_netif_list_unlock(); return ESP_OK; diff --git a/components/esp_netif/lwip/esp_netif_br_glue.c b/components/esp_netif/lwip/esp_netif_br_glue.c index c26b3e1ece..156f64a069 100644 --- a/components/esp_netif/lwip/esp_netif_br_glue.c +++ b/components/esp_netif/lwip/esp_netif_br_glue.c @@ -98,12 +98,12 @@ static void port_action_start(void *handler_args, esp_event_base_t base, int32_t esp_netif_br_glue_t *netif_glue = handler_args; if (base == WIFI_EVENT) { - ESP_LOGD(TAG, "wifi_action_start: %p, %p, %d, %p", netif_glue, base, event_id, event_data); + ESP_LOGD(TAG, "wifi_action_start: %p, %p, %" PRId32 ", %p", netif_glue, base, event_id, event_data); start_br_if_stopped(netif_glue); esp_netif_bridge_add_port(netif_glue->base.netif, netif_glue->wifi_esp_netif); } else if (base == ETH_EVENT) { esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data; - ESP_LOGD(TAG, "eth_action_start: %p, %p, %d, %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data); + ESP_LOGD(TAG, "eth_action_start: %p, %p, %" PRId32 ", %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data); for (int i = 0; i < netif_glue->port_cnt; i++) { if (eth_handle == esp_netif_get_io_driver(netif_glue->ports_esp_netifs[i])) { start_br_if_stopped(netif_glue); @@ -120,11 +120,11 @@ static void port_action_stop(void *handler_args, esp_event_base_t base, int32_t // if one of the bridge's ports is stopped, we need to stop the bridge too, since port's lwip_netif is removed and so it would become // an invalid reference in the bridge's internal structure (there is no way how to remove single port from bridge in current LwIP) if (base == WIFI_EVENT) { - ESP_LOGD(TAG, "wifi_action_stop: %p, %p, %d, %p", netif_glue, base, event_id, event_data); + ESP_LOGD(TAG, "wifi_action_stop: %p, %p, %" PRId32 ", %p", netif_glue, base, event_id, event_data); stop_br_if_started(netif_glue); } else if (base == ETH_EVENT) { esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data; - ESP_LOGD(TAG, "eth_action_stop: %p, %p, %d, %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data); + ESP_LOGD(TAG, "eth_action_stop: %p, %p, %" PRId32 ", %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data); for (int i = 0; i < netif_glue->port_cnt; i++) { if (eth_handle == esp_netif_get_io_driver(netif_glue->ports_esp_netifs[i])) { stop_br_if_started(netif_glue); @@ -144,11 +144,11 @@ static void port_action_connected(void *handler_args, esp_event_base_t base, int } if (base == WIFI_EVENT) { - ESP_LOGD(TAG, "wifi_action_connected: %p, %p, %d, %p", netif_glue, base, event_id, event_data); + ESP_LOGD(TAG, "wifi_action_connected: %p, %p, %" PRId32 ", %p", netif_glue, base, event_id, event_data); esp_netif_action_connected(netif_glue->base.netif, 0, 0, NULL); } else if (base == ETH_EVENT) { esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data; - ESP_LOGD(TAG, "eth_action_connected: %p, %p, %d, %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data); + ESP_LOGD(TAG, "eth_action_connected: %p, %p, %" PRId32 ", %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data); for (int i = 0; i < netif_glue->port_cnt; i++) { if (eth_handle == esp_netif_get_io_driver(netif_glue->ports_esp_netifs[i])) { esp_netif_action_connected(netif_glue->base.netif, 0, 0, NULL); @@ -166,7 +166,7 @@ static void port_action_connected(void *handler_args, esp_event_base_t base, int static void port_action_disconnected(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) { esp_netif_br_glue_t *netif_glue = handler_args; - ESP_LOGD(TAG, "action_disconnected: %p, %p, %d, %p", netif_glue, base, event_id, event_data); + ESP_LOGD(TAG, "action_disconnected: %p, %p, %" PRId32 ", %p", netif_glue, base, event_id, event_data); // if all ports are disconnected, set bridge as disconnected too if (are_ports_disconnected(netif_glue)) { esp_netif_action_disconnected(netif_glue->base.netif, base, event_id, event_data); @@ -178,7 +178,7 @@ static void br_action_got_ip(void *handler_args, esp_event_base_t base, int32_t { ip_event_got_ip_t *ip_event = (ip_event_got_ip_t *)event_data; esp_netif_br_glue_t *netif_glue = handler_args; - ESP_LOGD(TAG, "br_action_got_ip: %p, %p, %d, %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data); + ESP_LOGD(TAG, "br_action_got_ip: %p, %p, %" PRIu32 ", %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data); if (netif_glue->base.netif == ip_event->esp_netif) { esp_netif_action_got_ip(ip_event->esp_netif, base, event_id, event_data); } diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index d084c64188..2d7ffb0ad2 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -721,7 +722,7 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config) // Create parent esp-netif object esp_netif_t *esp_netif = calloc(1, sizeof(struct esp_netif_obj)); if (!esp_netif) { - ESP_LOGE(TAG, "Failed to allocate %d bytes (free heap size %d)", sizeof(struct esp_netif_obj), + ESP_LOGE(TAG, "Failed to allocate %" PRIu32 " bytes (free heap size %" PRIu32 ")", (uint32_t)sizeof(struct esp_netif_obj), esp_get_free_heap_size()); return NULL; } @@ -729,7 +730,7 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config) // Create ip info esp_netif_ip_info_t *ip_info = calloc(1, sizeof(esp_netif_ip_info_t)); if (!ip_info) { - ESP_LOGE(TAG, "Failed to allocate %d bytes (free heap size %d)", sizeof(esp_netif_ip_info_t), + ESP_LOGE(TAG, "Failed to allocate %" PRIu32 " bytes (free heap size %" PRIu32 ")", (uint32_t)sizeof(esp_netif_ip_info_t), esp_get_free_heap_size()); free(esp_netif); return NULL; @@ -739,7 +740,7 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config) // creating another ip info (to store old ip) ip_info = calloc(1, sizeof(esp_netif_ip_info_t)); if (!ip_info) { - ESP_LOGE(TAG, "Failed to allocate %d bytes (free heap size %d)", sizeof(esp_netif_ip_info_t), + ESP_LOGE(TAG, "Failed to allocate %" PRIu32 " bytes (free heap size %" PRIu32 ")", (uint32_t)sizeof(esp_netif_ip_info_t), esp_get_free_heap_size()); free(esp_netif->ip_info); free(esp_netif); @@ -758,7 +759,7 @@ esp_netif_t *esp_netif_new(const esp_netif_config_t *esp_netif_config) struct netif * lwip_netif = calloc(1, sizeof(struct netif)); if (!lwip_netif) { - ESP_LOGE(TAG, "Failed to allocate %d bytes (free heap size %d)", sizeof(struct netif), + ESP_LOGE(TAG, "Failed to allocate %" PRIu32 " bytes (free heap size %" PRIu32 ")", (uint32_t)sizeof(struct netif), esp_get_free_heap_size()); free(esp_netif->ip_info_old); free(esp_netif->ip_info); @@ -836,7 +837,7 @@ static esp_err_t esp_netif_lwip_add(esp_netif_t *esp_netif) #if CONFIG_PPP_SUPPORT err_t err = esp_netif->lwip_init_fn(NULL); if (err != ERR_OK) { - ESP_LOGE(TAG, "Init netif failed with %d", err); + ESP_LOGE(TAG, "Init netif failed with %" PRId8 "", err); return ESP_ERR_ESP_NETIF_INIT_FAILED; } #else @@ -1342,8 +1343,8 @@ static esp_err_t esp_netif_start_ip_lost_timer(esp_netif_t *esp_netif) return ESP_OK; } - ESP_LOGD(TAG, "if%p start ip lost tmr: no need start because netif=%p interval=%d ip=%x", - esp_netif, netif, CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL, ip_info_old->ip.addr); + ESP_LOGD(TAG, "if%p start ip lost tmr: no need start because netif=%p interval=%d ip=%" PRIx32, + esp_netif, netif, (CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL), ip_info_old->ip.addr); return ESP_OK; } @@ -1863,7 +1864,7 @@ static esp_err_t esp_netif_set_dns_info_api(esp_netif_api_msg_t *msg) esp_netif_dns_type_t type = dns_param->dns_type; esp_netif_dns_info_t *dns = dns_param->dns_info; - ESP_LOGD(TAG, "esp_netif_set_dns_info: if=%p type=%d dns=%x", esp_netif, type, dns->ip.u_addr.ip4.addr); + ESP_LOGD(TAG, "esp_netif_set_dns_info: if=%p type=%d dns=%" PRIx32, esp_netif, type, dns->ip.u_addr.ip4.addr); ip_addr_t lwip_ip = {}; ESPIP_TO_IP(&dns->ip, &lwip_ip);