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

Add support for FreeBSD's libusb reimplementation #993

Merged
merged 2 commits into from
Jun 21, 2020

Conversation

Crest
Copy link
Contributor

@Crest Crest commented Jun 21, 2020

FreeBSD reimplemented the libusb API, but their
implementation of libusb_set_debug() expects an
enum libusb_debug_level instead of an
enum libusb_log_level. This causes excessive
logging on FreeBSD drowning out all expected
output.

To keep the changes to other platforms minimal
the FreeBSD specific code is kept inside an
ifdef block and the enum values are recreated
as magic numbers just like the log levels for
other platforms.

FreeBSD reimplemented the libusb API, but their
implementation of libusb_set_debug() expects an
enum libusb_debug_level instead of an
enum libusb_log_level. This causes excessive
logging on FreeBSD drowning out all expected
output.

To keep the changes to other platforms minimal
the FreeBSD specific code is kept inside an
ifdef block and the enum values are recreated
as magic numbers just like the log levels for
other platforms.
@chenguokai
Copy link
Collaborator

If I got this, the previous #if failed to set attributes that it intended to set. Am I right?

@Crest
Copy link
Contributor Author

Crest commented Jun 21, 2020

The __FreeBSD__ define is the official way to check if code is compiled for FreeBSD. It is defined as the target FreeBSD major version (some integer greater than 0), but undefined on other platforms. I used the wrong preprocessor directive to check if the code is compiled for FreeBSD. It works on FreeBSD because __FreeBSD__ evaluates to 12 which is true, but fails to build on other platforms because __FreeBSD__ is undefined. The correct condition to check for is defined(__FreeBSD__) which can be shortened to #ifdef __FreeBSD__.

@Nightwalker-87 Nightwalker-87 merged commit eeb3190 into stlink-org:develop Jun 21, 2020
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Limit logging output on FreeBSD to something reasonable.
3 participants