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

Update usb.c to address Bug 1886 ("sr: usb: Failed to get libusb file descriptors.") on Windows #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,15 @@ static GSource *usb_source_new(struct sr_session *session,
const struct libusb_pollfd **upollfds, **upfd;

upollfds = libusb_get_pollfds(usb_ctx);

/* There are no filehandles in Windows */
#if !defined(__MINGW32__)
if (!upollfds) {
sr_err("Failed to get libusb file descriptors.");
return NULL;
}
#endif

source = g_source_new(&usb_source_funcs, sizeof(struct usb_source));
usource = (struct usb_source *)source;

Expand All @@ -281,7 +286,9 @@ static GSource *usb_source_new(struct sr_session *session,
usource->session = session;
usource->usb_ctx = usb_ctx;
usource->pollfds = g_ptr_array_new_full(8, &usb_source_free_pollfd);


/* There are no filehandles in Windows */
#if !defined(__MINGW32__)
for (upfd = upollfds; *upfd != NULL; upfd++)
usb_pollfd_added((*upfd)->fd, (*upfd)->events, usource);

Expand All @@ -292,7 +299,7 @@ static GSource *usb_source_new(struct sr_session *session,
#endif
libusb_set_pollfd_notifiers(usb_ctx,
&usb_pollfd_added, &usb_pollfd_removed, usource);

#endif
return source;
}

Expand Down