Skip to content

Redundant error check of function usb_set_config() in subsys/usb/class/usb_dfu.c #29822

@lc3412

Description

@lc3412

Hi,

The definition of function usb_set_config() is shown in the following code, and only the 0 code is returned.

zephyr/subsys/usb/usb_device.c

Lines 1447 to 1466 in fbc487c

int usb_set_config(const uint8_t *device_descriptor)
{
/* register descriptors */
usb_register_descriptors(device_descriptor);
/* register standard request handler */
usb_register_request_handler(REQTYPE_TYPE_STANDARD,
usb_handle_standard_request);
/* register class request handlers for each interface*/
usb_register_request_handler(REQTYPE_TYPE_CLASS, class_handler);
/* register vendor request handler */
usb_register_request_handler(REQTYPE_TYPE_VENDOR, vendor_handler);
/* register class request handlers for each interface*/
usb_register_custom_req_handler(custom_handler);
return 0;
}

However, in the subsys/usb/class/usb_dfu.c, there exists an error check towards function usb_set_config(). See the following code, the error check condition is != 0, which will never happen according to the function usb_set_config() definition, resulting in the redundant error check code.

if (usb_set_config(dfu_config.usb_device_description) != 0) {
LOG_ERR("usb_set_config failed in DFU_DETACH");
return -EIO;
}

Metadata

Metadata

Assignees

Labels

Stalearea: USBUniversal Serial BusbugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions