Sfoglia il codice sorgente

ping_sock: Fix esp_ping_new_session may return ESP_OK when the error occured

Closes https://github.com/espressif/esp-idf/issues/7363
yuanjm 4 anni fa
parent
commit
25a6744ff7
1 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 5 3
      components/lwip/apps/ping/ping_sock.c

+ 5 - 3
components/lwip/apps/ping/ping_sock.c

@@ -214,7 +214,7 @@ static void esp_ping_thread(void *args)
 
 esp_err_t esp_ping_new_session(const esp_ping_config_t *config, const esp_ping_callbacks_t *cbs, esp_ping_handle_t *hdl_out)
 {
-    esp_err_t ret = ESP_OK;
+    esp_err_t ret = ESP_FAIL;
     esp_ping_t *ep = NULL;
     PING_CHECK(config, "ping config can't be null", err, ESP_ERR_INVALID_ARG);
     PING_CHECK(hdl_out, "ping handle can't be null", err, ESP_ERR_INVALID_ARG);
@@ -272,10 +272,12 @@ esp_err_t esp_ping_new_session(const esp_ping_config_t *config, const esp_ping_c
     if(config->interface) {
         struct ifreq iface;
         if(netif_index_to_name(config->interface, iface.ifr_name) == NULL) {
-          goto err;
+            ESP_LOGE(TAG, "fail to find interface name with netif index %d", config->interface);
+            goto err;
         }
         if(setsockopt(ep->sock, SOL_SOCKET, SO_BINDTODEVICE, &iface, sizeof(iface) !=0)) {
-          goto err;
+            ESP_LOGE(TAG, "fail to setsockopt SO_BINDTODEVICE");
+            goto err;
         }
     }
     struct timeval timeout;