From 1f86a3e2894dd8d3caa7a4ed40bee0ae0372affb Mon Sep 17 00:00:00 2001 From: morris Date: Sat, 22 Mar 2025 23:37:58 +0800 Subject: [PATCH] fix(usb_serial_jtag): wrong return value in usb_serial_jtag_write_bytes Closes https://github.com/espressif/esp-idf/issues/15620 --- components/driver/usb_serial_jtag.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/driver/usb_serial_jtag.c b/components/driver/usb_serial_jtag.c index 3905157a76..8d2c5742cf 100644 --- a/components/driver/usb_serial_jtag.c +++ b/components/driver/usb_serial_jtag.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -198,9 +198,8 @@ int usb_serial_jtag_read_bytes(void* buf, uint32_t length, TickType_t ticks_to_w int usb_serial_jtag_write_bytes(const void* src, size_t size, TickType_t ticks_to_wait) { - ESP_RETURN_ON_FALSE(size != 0, ESP_ERR_INVALID_ARG, USB_SERIAL_JTAG_TAG, "size should be larger than 0"); - ESP_RETURN_ON_FALSE(src != NULL, ESP_ERR_INVALID_ARG, USB_SERIAL_JTAG_TAG, "Invalid buffer pointer."); - ESP_RETURN_ON_FALSE(p_usb_serial_jtag_obj != NULL, ESP_ERR_INVALID_ARG, USB_SERIAL_JTAG_TAG, "The driver hasn't been initialized"); + ESP_RETURN_ON_FALSE(src && size, 0, USB_SERIAL_JTAG_TAG, "invalid buffer or size"); + ESP_RETURN_ON_FALSE(p_usb_serial_jtag_obj != NULL, 0, USB_SERIAL_JTAG_TAG, "driver is not initialized yet"); const uint8_t *buff = (const uint8_t *)src; // Blocking method, Sending data to ringbuffer, and handle the data in ISR.