Subject: Re: uhub not identified anymore
To: None <current-users@netbsd.org>
From: Jukka Salmi <j+nbsd@2005.salmi.ch>
List: current-users
Date: 06/16/2005 14:57:37
--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Jukka Salmi --> current-users (2005-06-16 08:40:49 +0200):
[...]
> Another appearance of the same problem is with usbdevs(8):
> 
> $ usbdevs
> addr 1: product 0x0000, vendor 0x1106
> addr 1: product 0x0000, vendor 0x1106
> addr 1: product 0x0000, vendor 0x1106
> addr 1: product 0x0000, vendor 0x1106
> 
> 
> > What could be the source of this problem?
> 
> It's [1]this commit which causes the problem; building a kernel with
> revision 1.125 of src/sys/dev/usb/usb_subr.c fixes the problem:
> 
> $ usbdevs
> addr 1: UHCI root hub, VIA Technologies
> addr 1: UHCI root hub, VIA Technologies
> addr 1: UHCI root hub, VIA Technologies
> addr 1: EHCI root hub, VIA Technologies

The attached patch fixes the problem, which is usbd_trim_spaces() returning
a pointer pointing after the end of the string to return.


Cheers, Jukka

> [1] http://mail-index.netbsd.org/source-changes/2005/05/30/0019.html

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="usb_subr.c.patch"

Index: sys/dev/usb/usb_subr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/usb_subr.c,v
retrieving revision 1.126
diff -u -r1.126 usb_subr.c
--- sys/dev/usb/usb_subr.c	30 May 2005 04:20:46 -0000	1.126
+++ sys/dev/usb/usb_subr.c	16 Jun 2005 12:55:19 -0000
@@ -196,19 +196,19 @@
 static char *
 usbd_trim_spaces(char *b, size_t s, const char *p)
 {
-	char *q, *e;
+	char *q, *e, *ret;
 
 	if (p == NULL)
 		return NULL;
 	(void)strlcpy(b, p, s);
-	q = e = b;
+	q = e = ret = b;
 	while (*q == ' ')	/* skip leading spaces */
 		q++;
 	while ((*b = *q++))	/* copy string */
 		if (*b++ != ' ') /* remember last non-space */
 			e = b;
 	*e = 0;			/* kill trailing spaces */
-	return b;
+	return ret;
 }
 
 Static void

--gBBFr7Ir9EOA20Yy--