Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use libusb_get_device_address(), not libusb_get_port_number() #1819

Merged
merged 6 commits into from
Jan 22, 2023

Conversation

efuss
Copy link
Contributor

@efuss efuss commented Jan 17, 2023

In USB device enumeration, when setting curDevice->Device, use libusb_get_device_address(), not libusb_get_port_number().

While there, rename bus to bus_num to avoid ambiguity.

When printf()ing devnum (a size_t), use %zd, which is POSIX, not PRIuSIZE, which is not.

In USB device enumeration, when setting curDevice->Device, use libusb_get_device_address(), not libusb_get_port_number().

While there, rename bus to bus_num to avoid ambiguity.

When printf()ing devnum (a size_t), use %zd, which is POSIX, not PRIuSIZE, which is not.
@jimklimov
Copy link
Member

PRIuSIZE is set by nut_stdint.h according to platform. Not all systems we compile for care about POSIX, alas.

@jimklimov
Copy link
Member

For that matter, %zd is signed and size_t is not (ssize_t is).

@jimklimov jimklimov added the USB label Jan 17, 2023
@jimklimov
Copy link
Member

...and original %i for port number also (PRIu8)

@efuss
Copy link
Contributor Author

efuss commented Jan 17, 2023 via email

@efuss
Copy link
Contributor Author

efuss commented Jan 17, 2023 via email

@jimklimov jimklimov added this to the 2.8.1 milestone Jan 22, 2023
@jimklimov
Copy link
Member

jimklimov commented Jan 22, 2023

@efuss : I bumped the PR with printing changes, and with a name-sync of other libusb1 code to minimize diffs later. And updated nut-scanner to use same facility as drivers would.

To me the core question would be if libusb_get_device_address() fares better on your platform than libusb_get_port_number() (I suppose the latter is more prone to return 0 as error, e.g. where knowing physical topology is not supported, per your older posted issues and hints in docs?)

I cursorily checked that on a physical Linux box I have under hand they returned same numbers (e.g. 002 for my UPS connection).

@efuss
Copy link
Contributor Author

efuss commented Jan 22, 2023 via email

@jimklimov
Copy link
Member

Ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants