diff --git a/components/protocomm/CMakeLists.txt b/components/protocomm/CMakeLists.txt index 4c35f55eb5..d98541d8f1 100644 --- a/components/protocomm/CMakeLists.txt +++ b/components/protocomm/CMakeLists.txt @@ -48,5 +48,3 @@ idf_component_register(SRCS "${srcs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" PRIV_REQUIRES protobuf-c mbedtls console esp_http_server driver REQUIRES bt) - -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/protocomm/src/common/protocomm.c b/components/protocomm/src/common/protocomm.c index 8a6433170e..c8e0012db5 100644 --- a/components/protocomm/src/common/protocomm.c +++ b/components/protocomm/src/common/protocomm.c @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -149,7 +150,7 @@ esp_err_t protocomm_open_session(protocomm_t *pc, uint32_t session_id) if (pc->sec && pc->sec->new_transport_session) { esp_err_t ret = pc->sec->new_transport_session(pc->sec_inst, session_id); if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to launch new session with ID: %d", session_id); + ESP_LOGE(TAG, "Failed to launch new session with ID: %" PRId32, session_id); return ret; } } @@ -165,7 +166,7 @@ esp_err_t protocomm_close_session(protocomm_t *pc, uint32_t session_id) if (pc->sec && pc->sec->close_transport_session) { esp_err_t ret = pc->sec->close_transport_session(pc->sec_inst, session_id); if (ret != ESP_OK) { - ESP_LOGE(TAG, "Error while closing session with ID: %d", session_id); + ESP_LOGE(TAG, "Error while closing session with ID: %" PRId32, session_id); return ret; } } diff --git a/components/protocomm/src/security/security1.c b/components/protocomm/src/security/security1.c index f530055fab..dbc62383fc 100644 --- a/components/protocomm/src/security/security1.c +++ b/components/protocomm/src/security/security1.c @@ -9,6 +9,7 @@ #include #include #include +#include /* TODO: Currently MBEDTLS_ECDH_LEGACY_CONTEXT is enabled by default * when MBEDTLS_ECP_RESTARTABLE is enabled. @@ -459,7 +460,7 @@ static esp_err_t sec1_new_session(protocomm_security_handle_t handle, uint32_t s if (cur_session->id != -1) { /* Only one session is allowed at a time */ - ESP_LOGE(TAG, "Closing old session with id %u", cur_session->id); + ESP_LOGE(TAG, "Closing old session with id %" PRIu32, cur_session->id); sec1_close_session(cur_session, session_id); } @@ -503,7 +504,7 @@ static esp_err_t sec1_decrypt(protocomm_security_handle_t handle, } if (!cur_session || cur_session->id != session_id) { - ESP_LOGE(TAG, "Session with ID %d not found", session_id); + ESP_LOGE(TAG, "Session with ID %" PRId32 "not found", session_id); return ESP_ERR_INVALID_STATE; } @@ -542,7 +543,7 @@ static esp_err_t sec1_req_handler(protocomm_security_handle_t handle, } if (session_id != cur_session->id) { - ESP_LOGE(TAG, "Invalid session ID : %d (expected %d)", session_id, cur_session->id); + ESP_LOGE(TAG, "Invalid session ID:%" PRId32 "(expected %" PRId32 ")", session_id, cur_session->id); return ESP_ERR_INVALID_STATE; } diff --git a/components/protocomm/src/security/security2.c b/components/protocomm/src/security/security2.c index 19e33f8ee2..fe1250019a 100644 --- a/components/protocomm/src/security/security2.c +++ b/components/protocomm/src/security/security2.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -367,7 +368,7 @@ static esp_err_t sec2_new_session(protocomm_security_handle_t handle, uint32_t s if (cur_session->id != -1) { /* Only one session is allowed at a time */ - ESP_LOGE(TAG, "Closing old session with id %u", cur_session->id); + ESP_LOGE(TAG, "Closing old session with id %" PRIu32, cur_session->id); sec2_close_session(cur_session, session_id); } @@ -411,7 +412,7 @@ static esp_err_t sec2_encrypt(protocomm_security_handle_t handle, } if (!cur_session || cur_session->id != session_id) { - ESP_LOGE(TAG, "Session with ID %d not found", session_id); + ESP_LOGE(TAG, "Session with ID %" PRId32 "not found", session_id); return ESP_ERR_INVALID_STATE; } @@ -451,7 +452,7 @@ static esp_err_t sec2_decrypt(protocomm_security_handle_t handle, } if (!cur_session || cur_session->id != session_id) { - ESP_LOGE(TAG, "Session with ID %d not found", session_id); + ESP_LOGE(TAG, "Session with ID %" PRId32 "not found", session_id); return ESP_ERR_INVALID_STATE; } @@ -490,7 +491,7 @@ static esp_err_t sec2_req_handler(protocomm_security_handle_t handle, } if (session_id != cur_session->id) { - ESP_LOGE(TAG, "Invalid session ID : %d (expected %d)", session_id, cur_session->id); + ESP_LOGE(TAG, "Invalid session ID:%" PRId32 "(expected %" PRId32 ")", session_id, cur_session->id); return ESP_ERR_INVALID_STATE; } diff --git a/components/protocomm/src/simple_ble/simple_ble.c b/components/protocomm/src/simple_ble/simple_ble.c index e59f05ec18..ec210408d2 100644 --- a/components/protocomm/src/simple_ble/simple_ble.c +++ b/components/protocomm/src/simple_ble/simple_ble.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include #include @@ -209,7 +210,7 @@ esp_err_t simple_ble_deinit(void) esp_err_t simple_ble_start(simple_ble_cfg_t *cfg) { g_ble_cfg_p = cfg; - ESP_LOGD(TAG, "Free mem at start of simple_ble_init %d", esp_get_free_heap_size()); + ESP_LOGD(TAG, "Free mem at start of simple_ble_init %" PRIu32, esp_get_free_heap_size()); esp_err_t ret; esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); @@ -267,7 +268,7 @@ esp_err_t simple_ble_start(simple_ble_cfg_t *cfg) if (local_mtu_ret) { ESP_LOGE(TAG, "set local MTU failed, error code = 0x%x", local_mtu_ret); } - ESP_LOGD(TAG, "Free mem at end of simple_ble_init %d", esp_get_free_heap_size()); + ESP_LOGD(TAG, "Free mem at end of simple_ble_init %" PRIu32, esp_get_free_heap_size()); /* set the security iocap & auth_req & key size & init key response key parameters to the stack*/ esp_ble_auth_req_t auth_req= ESP_LE_AUTH_REQ_MITM; @@ -294,7 +295,7 @@ esp_err_t simple_ble_start(simple_ble_cfg_t *cfg) esp_err_t simple_ble_stop(void) { esp_err_t err; - ESP_LOGD(TAG, "Free mem at start of simple_ble_stop %d", esp_get_free_heap_size()); + ESP_LOGD(TAG, "Free mem at start of simple_ble_stop %" PRIu32, esp_get_free_heap_size()); err = esp_bluedroid_disable(); if (err != ESP_OK) { return ESP_FAIL; @@ -320,7 +321,7 @@ esp_err_t simple_ble_stop(void) } ESP_LOGD(TAG, "esp_bt_controller_deinit called successfully"); - ESP_LOGD(TAG, "Free mem at end of simple_ble_stop %d", esp_get_free_heap_size()); + ESP_LOGD(TAG, "Free mem at end of simple_ble_stop %" PRIu32, esp_get_free_heap_size()); return ESP_OK; } diff --git a/components/protocomm/src/transports/protocomm_httpd.c b/components/protocomm/src/transports/protocomm_httpd.c index 33a4337141..eaa0019577 100644 --- a/components/protocomm/src/transports/protocomm_httpd.c +++ b/components/protocomm/src/transports/protocomm_httpd.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "esp_random.h" #include @@ -34,7 +35,7 @@ static void protocomm_httpd_session_close(void *ctx) * request is for the same session. */ if (sock_session_id != PROTOCOMM_NO_SESSION_ID) { - ESP_LOGW(TAG, "Resetting socket session id as socket %d was closed", sock_session_id); + ESP_LOGW(TAG, "Resetting socket session id as socket %" PRId32 "was closed", sock_session_id); sock_session_id = PROTOCOMM_NO_SESSION_ID; } } @@ -56,12 +57,12 @@ static esp_err_t common_post_handler(httpd_req_t *req) if (httpd_req_get_hdr_value_str(req, "Cookie", cookie_buf, sizeof(cookie_buf)) == ESP_OK) { ESP_LOGD(TAG, "Received cookie %s", cookie_buf); char session_cookie[20] = {0}; - snprintf(session_cookie, sizeof(session_cookie), "session=%u", cookie_session_id); + snprintf(session_cookie, sizeof(session_cookie), "session=%" PRIu32, cookie_session_id); /* If a cookie is found, check it against the session id. If it matches, * it means that this is a continuation of the same session. */ if (strcmp(session_cookie, cookie_buf) == 0) { - ESP_LOGD(TAG, "Continuing Session %u", cookie_session_id); + ESP_LOGD(TAG, "Continuing Session %" PRIu32, cookie_session_id); /* If we reach here, it means that the client supports cookies and so the * socket session id would no more be required for checking. */ @@ -70,7 +71,7 @@ static esp_err_t common_post_handler(httpd_req_t *req) } } else if (cur_sock_session_id == sock_session_id) { /* If the socket number matches, we assume it to be the same session */ - ESP_LOGD(TAG, "Continuing Socket Session %u", sock_session_id); + ESP_LOGD(TAG, "Continuing Socket Session %" PRIu32, sock_session_id); same_session = true; } if (!same_session) { @@ -78,11 +79,11 @@ static esp_err_t common_post_handler(httpd_req_t *req) * first close any existing sessions as applicable. */ if (cookie_session_id != PROTOCOMM_NO_SESSION_ID) { - ESP_LOGW(TAG, "Closing session with ID: %u", cookie_session_id); + ESP_LOGW(TAG, "Closing session with ID: %" PRIu32, cookie_session_id); if (pc_httpd->sec && pc_httpd->sec->close_transport_session) { ret = pc_httpd->sec->close_transport_session(pc_httpd->sec_inst, cookie_session_id); if (ret != ESP_OK) { - ESP_LOGW(TAG, "Error closing session with ID: %u", cookie_session_id); + ESP_LOGW(TAG, "Error closing session with ID: %" PRIu32, cookie_session_id); } } cookie_session_id = PROTOCOMM_NO_SESSION_ID; @@ -104,7 +105,7 @@ static esp_err_t common_post_handler(httpd_req_t *req) } cookie_session_id = cur_cookie_session_id; sock_session_id = cur_sock_session_id; - ESP_LOGD(TAG, "New socket session ID: %d", sock_session_id); + ESP_LOGD(TAG, "New socket session ID: %" PRId32, sock_session_id); } if (req->content_len <= 0) { @@ -147,7 +148,7 @@ static esp_err_t common_post_handler(httpd_req_t *req) } /* If this is a new session, send the session id in a cookie */ if (!same_session) { - snprintf(cookie_buf, sizeof(cookie_buf), "session=%u", cookie_session_id); + snprintf(cookie_buf, sizeof(cookie_buf), "session=%" PRIu32, cookie_session_id); ESP_LOGD(TAG, "Setting cookie %s", cookie_buf); httpd_resp_set_hdr(req, "Set-Cookie", cookie_buf); } diff --git a/components/protocomm/src/transports/protocomm_nimble.c b/components/protocomm/src/transports/protocomm_nimble.c index f3b894f3de..d8f9e2f91c 100644 --- a/components/protocomm/src/transports/protocomm_nimble.c +++ b/components/protocomm/src/transports/protocomm_nimble.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -208,7 +209,7 @@ simple_ble_advertise(void) return; } /* Take note of free heap space */ - ESP_LOGD(TAG, "Minimum free heap size = %d, free Heap size = %d", + ESP_LOGD(TAG, "Minimum free heap size = %" PRIu32 ", free Heap size = %" PRIu32, esp_get_minimum_free_heap_size(), esp_get_free_heap_size()); } @@ -488,7 +489,7 @@ static int simple_ble_start(const simple_ble_cfg_t *cfg) { ble_cfg_p = (void *)cfg; int rc; - ESP_LOGD(TAG, "Free memory at start of simple_ble_init %d", esp_get_free_heap_size()); + ESP_LOGD(TAG, "Free memory at start of simple_ble_init %" PRIu32, esp_get_free_heap_size()); nimble_port_init(); @@ -948,7 +949,7 @@ esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *con } esp_err_t err = simple_ble_start(ble_config); - ESP_LOGD(TAG, "Free Heap size after simple_ble_start= %d", esp_get_free_heap_size()); + ESP_LOGD(TAG, "Free Heap size after simple_ble_start= %" PRIu32, esp_get_free_heap_size()); if (err != ESP_OK) { ESP_LOGE(TAG, "simple_ble_start failed w/ error code 0x%x", err);