From fa5b466b3634c3e6382f45aef9f2cb074a4941bd Mon Sep 17 00:00:00 2001 From: Sojan James Date: Mon, 23 Oct 2023 10:55:43 +0530 Subject: [PATCH] fix(websocket): Return error code correctly --- .../esp_websocket_client/esp_websocket_client.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c index a7e0bb91ea..841cdc7348 100644 --- a/components/esp_websocket_client/esp_websocket_client.c +++ b/components/esp_websocket_client/esp_websocket_client.c @@ -1200,7 +1200,7 @@ int esp_websocket_client_send_fin(esp_websocket_client_handle_t client, TickType int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t client, ws_transport_opcodes_t opcode, const uint8_t *data, int len, TickType_t timeout) { - int error = ESP_OK; + int ret = ESP_OK; if (client == NULL || len < 0 || (data == NULL && len > 0)) { ESP_LOGE(TAG, "Invalid arguments"); return ESP_FAIL; @@ -1213,28 +1213,28 @@ int esp_websocket_client_send_with_opcode(esp_websocket_client_handle_t client, if (!esp_websocket_client_is_connected(client)) { ESP_LOGE(TAG, "Websocket client is not connected"); - error = ESP_FAIL; + ret = ESP_FAIL; goto unlock_and_return; } if (client->transport == NULL) { ESP_LOGE(TAG, "Invalid transport"); - error = ESP_FAIL; + ret = ESP_FAIL; goto unlock_and_return; } if (esp_websocket_new_buf(client, true) != ESP_OK) { ESP_LOGE(TAG, "Failed to setup tx buffer"); - error = ESP_FAIL; + ret = ESP_FAIL; goto unlock_and_return; } if (esp_websocket_client_send_with_exact_opcode(client, opcode | WS_TRANSPORT_OPCODES_FIN, data, len, timeout) != true) { ESP_LOGE(TAG, "Failed to send the buffer"); - error = ESP_FAIL; + ret = ESP_FAIL; goto unlock_and_return; } unlock_and_return: xSemaphoreGiveRecursive(client->lock); - return error; + return ret; } bool esp_websocket_client_is_connected(esp_websocket_client_handle_t client)