Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Nov 2008 23:18:45 GMT
From:      Rene Ladan <r.c.ladan@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/128549: devel/libusb : fix runtime error
Message-ID:  <200811022318.mA2NIjXd031874@www.freebsd.org>
Resent-Message-ID: <200811022320.mA2NK1hZ045174@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         128549
>Category:       ports
>Synopsis:       devel/libusb : fix runtime error
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 02 23:20:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Rene Ladan
>Release:        7.0-RELEASE-p5 amd64
>Organization:
>Environment:
FreeBSD self.rene-ladan.nl 7.0-RELEASE-p5 FreeBSD 7.0-RELEASE-p5 #0: Thu Oct  2 15:01:07 CEST 2008     root@self.rene-ladan.nl:/usr/obj/usr/src70/sys/RENE  amd64

>Description:
>From the libusb-devel mailing list:

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -ruN /usr/ports/devel/libusb/Makefile ./Makefile
--- /usr/ports/devel/libusb/Makefile	2008-10-13 19:52:01.000000000 +0200
+++ ./Makefile	2008-11-03 00:06:10.000000000 +0100
@@ -7,7 +7,7 @@
 
 PORTNAME=	libusb
 PORTVERSION=	0.1.12
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	devel
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	${PORTNAME}
diff -ruN /usr/ports/devel/libusb/files/patch-bsd.c ./files/patch-bsd.c
--- /usr/ports/devel/libusb/files/patch-bsd.c	2008-10-13 19:52:01.000000000 +0200
+++ ./files/patch-bsd.c	2008-11-03 00:09:17.000000000 +0100
@@ -1,14 +1,23 @@
---- bsd.c.orig	Sun Jul 30 11:18:07 2006
-+++ bsd.c	Sun Jul 30 11:20:30 2006
+--- bsd.c.orig	2006-03-04 03:52:46.000000000 +0100
++++ bsd.c	2008-11-03 00:08:15.000000000 +0100
 @@ -408,7 +408,7 @@
    /* Ensure the endpoint address is correct */
    ep |= USB_ENDPOINT_IN;
-
+ 
 -  fd = ensure_ep_open(dev, ep, O_RDONLY);
 +  fd = ensure_ep_open(dev, ep, O_RDONLY | O_NONBLOCK);
    if (fd < 0) {
-       if (usb_debug >= 2) {
-  #ifdef __FreeBSD_kernel__
+     if (usb_debug >= 2) {
+ #ifdef __FreeBSD_kernel__
+@@ -477,7 +477,7 @@
+     USB_ERROR_STR(-errno, "error sending control message: %s",
+                   strerror(errno));
+ 
+-  return UGETW(req.ucr_request.wLength);
++  return req.ucr_actlen;
+ }
+ 
+ int usb_os_find_busses(struct usb_bus **busses)
 @@ -623,9 +623,21 @@
  
  int usb_clear_halt(usb_dev_handle *dev, unsigned int ep)
@@ -16,8 +25,7 @@
 -  /* Not yet done, because I haven't needed it. */
 +  int ret;
 +  struct usb_ctl_request ctl_req;
- 
--  USB_ERROR_STR(-ENOSYS, "usb_clear_halt called, unimplemented on BSD");
++
 +  ctl_req.ucr_addr = 0; // Not used for this type of request
 +  ctl_req.ucr_request.bmRequestType = UT_WRITE_ENDPOINT;
 +  ctl_req.ucr_request.bRequest = UR_CLEAR_FEATURE;
@@ -28,7 +36,8 @@
 +
 +  if ((ret = ioctl(dev->fd, USB_DO_REQUEST, &ctl_req)) < 0)
 +      USB_ERROR_STR(-errno, "clear_halt:  failed for %d", ep);
-+
+ 
+-  USB_ERROR_STR(-ENOSYS, "usb_clear_halt called, unimplemented on BSD");
 +  return ret;
  }
  


>Release-Note:
>Audit-Trail:
>Unformatted:
 >> The current FreeBSD port compiles fine, so does it fail at run-time
 >> for a particular use case?
 
 > Yes, this is a runtime failure. While usb_control_msg is supposed to return
 > the actual number of bytes received, the freebsd version returns the
 > receiving buffer size instead. Applications inspecting the returned length
 > for error checking will fail. My patch is based on this excerpt from
 > FreeBSDs /usr/src/sys/dev/usb/usb.h.
 
 
 The patched port passes 'make'.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811022318.mA2NIjXd031874>