Page MenuHomeFreeBSD

libusb: let LIBUSB_DEBUG environment variable override libusb_set_debug
ClosedPublic

Authored by kevans on Wed, Oct 2, 1:43 PM.

Details

Summary

The debug level generally just controls verbosity of libusb for debugging libusb devices/usage. We allow the environment to set the debug level independent of the application, but the application will always override this if it explicitly sets the debug level.

Changing the environment is easy, but patching the software to change the debug level isn't necessarily easy or possible. Further, there's this write-only debug_fixed variable that would seem to imply that the debug level should be fixed, but it isn't currently used. Change the logic to use strtol() so we can detect real 0 vs. conversion failure, then honor debug_fixed in libusb_set_debug.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kevans created this revision.Wed, Oct 2, 1:43 PM
kevans edited the summary of this revision. (Show Details)Wed, Oct 2, 1:47 PM
hselasky added inline comments.Wed, Oct 2, 2:07 PM
lib/libusb/libusb10.c
151 ↗(On Diff #62829)

I think it is enough to check if *ep == '\0' ?

kevans added inline comments.Wed, Oct 2, 2:12 PM
lib/libusb/libusb10.c
151 ↗(On Diff #62829)

You have to check errno, too, because if you have all valid digits but simply hit overflow then *ep == '\0' but errno == ERANGE.

hselasky accepted this revision.Wed, Oct 2, 2:34 PM

Don't forget to MFC.

This revision is now accepted and ready to land.Wed, Oct 2, 2:34 PM