app_trace: fix fwrite/fread return value

This commit is contained in:
Alexey Lapshin
2023-03-14 15:49:23 +08:00
parent f3a32bc687
commit 8c7c653a7f

View File

@@ -229,7 +229,7 @@ size_t esp_apptrace_fwrite(esp_apptrace_dest_t dest, const void *ptr, size_t siz
return 0; return 0;
} }
return resp; return resp/size; // return the number of items written
} }
static void esp_apptrace_fread_args_prepare(uint8_t *buf, void *priv) static void esp_apptrace_fread_args_prepare(uint8_t *buf, void *priv)
@@ -266,14 +266,16 @@ size_t esp_apptrace_fread(esp_apptrace_dest_t dest, void *ptr, size_t size, size
ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret); ESP_EARLY_LOGE(TAG, "Failed to read response (%d)!", ret);
return 0; return 0;
} }
if (resp > 0) { if (resp == 0) {
ret = esp_apptrace_file_rsp_recv(dest, ptr, resp); return 0;
if (ret != ESP_OK) {
ESP_EARLY_LOGE(TAG, "Failed to read file data (%d)!", ret);
return 0;
}
} }
return resp;
ret = esp_apptrace_file_rsp_recv(dest, ptr, resp);
if (ret != ESP_OK) {
ESP_EARLY_LOGE(TAG, "Failed to read file data (%d)!", ret);
return 0;
}
return resp/size; // return the number of items read
} }
static void esp_apptrace_fseek_args_prepare(uint8_t *buf, void *priv) static void esp_apptrace_fseek_args_prepare(uint8_t *buf, void *priv)