Re: can: ucan: Use usb_endpoint_type() rather than duplicating its implementation

From: Markus Elfring
Date: Thu Jun 26 2025 - 03:23:05 EST


>> I am unsure if the check reordering would be desirable for this function implementation.
>
> Ah, you want to confirm whether
>
> usb_endpoint_dir_in(ep) && usb_endpoint_xfer_bulk(ep)
>
> is the same as
>
> usb_endpoint_xfer_bulk(ep) && usb_endpoint_dir_in(ep)
>
> ?

Exactly, yes.

Commutativity can probably be applied in this case.
But the different execution order will influence the corresponding run time characteristics.
https://en.wikipedia.org/wiki/Short-circuit_evaluation
https://en.wikipedia.org/wiki/Commutative_property

The data processing order from known API function implementations might get priority
also at discussed source code places in the near future.

Regards,
Markus