cezanne / usbip-win

USB/IP for Windows
GNU General Public License v3.0
1.91k stars 344 forks source link

vhci driver weird code #322

Closed Kogotoro closed 1 year ago

Kogotoro commented 1 year ago

/driver/vhci/vhci_devconf.c function setup_intf(...) intf->InterfaceHandle = TO_INTF_HANDLE(intf->InterfaceNumber, intf->AlternateSetting); considering what `

define TO_INTF_HANDLE(intf_num, altsetting) ((USBD_INTERFACE_HANDLE)((intf_num << 8) + altsetting))

and intf->InterfaceNumber, intf->AlternateSetting` both UCHAR (ie 8bits and there 8 bits left shift on first of them?)

its eq to intf->InterfaceHandle = (USBD_INTERFACE_HANDLE)(intf->AlternateSetting); ???

vadimgrn commented 1 year ago

If you really want to improve usbip client, consider following repo. This project is stagnating.

vadimgrn commented 1 year ago

The author was working on UDE driver, so VHCI driver is abandoned twice.

vadimgrn commented 1 year ago

Regarding your question, read about integral promotions in C. In expression intf_num << 8 a compiler promotes UCHAR to int and does shift.

Kogotoro commented 1 year ago

Regarding your question, read about integral promotions in C. In expression intf_num << 8 a compiler promotes UCHAR to int and does shift.

thx