Zephyr: DISCUSS: usb_device.c: If condition judgment

Created on 4 May 2018  路  3Comments  路  Source: zephyrproject-rtos/zephyr

some if condition in usb_handle_control_transfer is very hard to understand, can we rewrite it?
such as:

if (!(setup->wLength == 0) &&
    !(REQTYPE_GET_DIR(setup->bmRequestType) ==
    REQTYPE_DIR_TO_HOST)) {
            return;
}

convent to:

if ((setup->wLength > 0) && 
    (REQTYPE_GET_DIR(setup->bmRequestType) ==
    REQTYPE_DIR_TO_DEVICE)) {
        return ;
}
USB question

Most helpful comment

Maybe have it like

if (setup->wLength && REQTYPE_GET_DIR(setup->bmRequestType) == REQTYPE_DIR_TO_DEVICE) {
        return ;
}

All 3 comments

@jfischer-phytec-iot @ydamigos what's you idea?

Maybe have it like

if (setup->wLength && REQTYPE_GET_DIR(setup->bmRequestType) == REQTYPE_DIR_TO_DEVICE) {
        return ;
}

ok i will make a pr to rewrite some if conditions

Was this page helpful?
0 / 5 - 0 ratings