Skip to content

New NO_DEVICE_DISCOVERY option to replace WEAK_AUTHORITY option - #935

Closed
tormodvolden wants to merge 1 commit into
libusb:masterfrom
tormodvolden:opt_no_enum
Closed

tormodvolden wants to merge 1 commit into
libusb:masterfrom
tormodvolden:opt_no_enum

Conversation

@tormodvolden

Copy link
Copy Markdown
Contributor

All that the old option was doing, was skipping the device enumeration.
Since this has a much broader usage scope than "weak authority", give
the option a name reflecting exactly what it does.

For now, keep the old option name working as an alias.

Signed-off-by: Tormod Volden [email protected]

@tormodvolden

Copy link
Copy Markdown
Contributor Author

It would be good if those who introduced the original WEAK_AUTHORITY could comment on this, and in particular its deprecation. Maybe I missed something? Any plans for extending WEAK_AUTHORITY to do more than NO_ENUMERATION?

@mcuee

mcuee commented Jun 16, 2021

Copy link
Copy Markdown
Member

Commit 89b810e adds the option LIBUSB_OPTION_WEAK_AUTHORITY to Android.

Original pull-request
#760

@mcuee

mcuee commented Jun 16, 2021 •

Copy link
Copy Markdown
Member

@chrisju @Peter-St @xloem Please review this if you got the time. Thanks.

@Peter-St

Copy link
Copy Markdown
Contributor

For my part I approve with tormodvolden. If there were no negations, we could merge this PR too.

@xloem

xloem commented Jun 16, 2021 •

Copy link
Copy Markdown
Contributor

It looks like most of the changes happened in #925 . It's notable that there could be race conditions since a static flag was used here, but that was already the case. #874 will likely be further delayed to be changed for these but the improved code organisation is great.

I do believe this flag changes more than just disabling device enumeration. For example, it also disables hotplug.

@tormodvolden

Copy link
Copy Markdown
Contributor Author

Yes, it prevents the hotplug event monitoring from starting. I think this makes sense, since the hotplug add event handling depends on enumeration of the device, AFAICS. We could also call the new option NO_DEVICE_DISCOVERY - it would be less specific to the mechanism of enumeration, clearly cover hotplug deactivation, and maybe be more explanatory for the user?

@LudovicRousseau

Copy link
Copy Markdown
Member

I vote for NO_DEVICE_DISCOVERY.
I suggest to add in the documentation that this option will also disable the hotplug mechanism.

One question @tormodvolden: why do you change the value of LIBUSB_OPTION_WEAK_AUTHORITY from 2 to 3 instead of having LIBUSB_OPTION_WEAK_AUTHORITY and LIBUSB_OPTION_NO_ENUMERATION both defined as 2?

@tormodvolden

Copy link
Copy Markdown
Contributor Author

@LudovicRousseau I was thinking in case we wanted to display a deprecation message for WEAK_AUTHORITY later.

@tormodvolden

Copy link
Copy Markdown
Contributor Author

As soon as there is agreement on the naming, I will change that too. Would you like me to squash and repush in the end, or do you do that anyway with the NANO bump process?

@mcuee

mcuee commented Jun 16, 2021

Copy link
Copy Markdown
Member

I am fine with NO_DEVICE_DISCOVERY as well.

@Peter-St

Peter-St commented Jun 16, 2021 •

Copy link
Copy Markdown
Contributor

Yep,
NO_DEVICE_DISCOVERY is preferable to NO_ENUMERATION.

The option disables device enumeration (and hotplug, which depends on
enumeration). Since this has a much broader usage scope than "weak
authority", give the option a name reflecting what it does.

For now, keep the old option name working as an alias.

Signed-off-by: Tormod Volden <[email protected]>
@tormodvolden

tormodvolden commented Jun 16, 2021 •

Copy link
Copy Markdown
Contributor Author

I see the potential issue if someone is using 1.0.25 and WEAK_AUTHORITY, the application will set option 3. If the same binary is later run-time linked against a newer libusb where we use 3 for something different after having dropped WEAK_AUTHORITY, unexpected things will happen. I don't know if we guarantee backwards binary compatibility for minor releases? Or we will have to keep number 3 reserved until next major release.

Alternatively we use 2 for both now, and we won't be able to give a run-time warning. A build-time warning would be better anyway but I don't see how to do that.

Or we do it the brutal way and drop it now, so compile will fail. The option hasn't been in much use yet, only on the experimental(?) Android platform. If an application must be able to compile smoothly against both 1.0.24 and 1.0.25 the preprocessor will have to check libusb version and pick name accordingly.

@xloem

xloem commented Jun 16, 2021

Copy link
Copy Markdown
Contributor

If this is merged with additional option 3, I'll try to make time to merge with #874 (which currently uses options 3 and 4) so anybody using my other pr will discover the new numbering sooner rather than later.

@xloem

xloem commented Jun 27, 2021 •

Copy link
Copy Markdown
Contributor

Edit: sorry for spam. The issue I mentioned had already been addressed.

There are 3 PRs outstanding for this option now, be good to merge them quickly so conflicts can be resolved.

@xloem xloem mentioned this pull request Jul 5, 2021
6 of 15 tasks
@chrisju

chrisju commented Jul 8, 2021

Copy link
Copy Markdown

LIBUSB_OPTION_WEAK_AUTHORITY is used when there is no permission to directly access the usb port, such as cannot scan the usb port and hot plug detect.

@tormodvolden

tormodvolden commented Sep 24, 2021 •

Copy link
Copy Markdown
Contributor Author

I just wonder if it would be better to leave the deprecated LIBUSB_OPTION_WEAK_AUTHORITY at value 2 as well. We wouldn't be able to issue a deprecation warning then, but it prevents some possible future issues with binary compatibility and technical debt. And as soon as we drop LIBUSB_OPTION_WEAK_AUTHORITY altogether, the word should be well out already, and a broken application build can be fixed promptly. Comments?

@tormodvolden tormodvolden changed the title New NO_ENUMERATION option to replace WEAK_AUTHORITY option New NO_DEVICE_DISCOVERY option to replace WEAK_AUTHORITY option Sep 24, 2021
tormodvolden added a commit to tormodvolden/libusb that referenced this pull request Oct 2, 2021
If the value is always the same we retain binary compatibility.

References libusb#935

Signed-off-by: Tormod Volden <[email protected]>
hjelmn pushed a commit that referenced this pull request Nov 27, 2021
If the value is always the same we retain binary compatibility.

References #935

Signed-off-by: Tormod Volden <[email protected]>
Signed-off-by: Nathan Hjelm <[email protected]>
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.

6 participants