From nobody@FreeBSD.org  Sun Feb 12 12:11:06 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7ABD016A420
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 12 Feb 2006 12:11:06 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 096D343D45
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 12 Feb 2006 12:11:06 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k1CCB5ut051333
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 12 Feb 2006 12:11:05 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k1CCB58c051332;
	Sun, 12 Feb 2006 12:11:05 GMT
	(envelope-from nobody)
Message-Id: <200602121211.k1CCB58c051332@www.freebsd.org>
Date: Sun, 12 Feb 2006 12:11:05 GMT
From: Yang Ping <start_3.1415926@163.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: usbd source issue
X-Send-Pr-Version: www-2.3

>Number:         93230
>Category:       kern
>Synopsis:       usbd source issue
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 12 12:20:09 GMT 2006
>Closed-Date:    Mon Feb 13 11:33:25 GMT 2006
>Last-Modified:  Mon Feb 13 11:33:25 GMT 2006
>Originator:     Yang Ping
>Release:        6.0-SNAP010
>Organization:
personal
>Environment:
FreeBSD WS01 6.0-STABLE-SNAP010 FreeBSD 6.0-STABLE-SNAP010 #0: Sun Dec  4 18:31:43 UTC 2005     root@opus.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
usbd.c line-no : 963 ,

if (modfind(USB_UHUB) < 0) {
       if (kldload(USB_KLD) < 0 || modfind(USB_UHUB) < ) {
..

above code maybe repeat.
>How-To-Repeat:
              
>Fix:
              
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: ceri 
State-Changed-When: Sun Feb 12 23:53:32 UTC 2006 
State-Changed-Why:  
There doesn't seem to be anything wrong with the code: 

if (modfind(USB_UHUB) < 0) { 
if (kldload(USB_KLD) < 0 || modfind(USB_UHUB) < 0) { 
perror(USB_KLD ": Kernel module not available"); 
return 1; 
} 
} 

What exactly do you perceive to be the issue? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93230 

From: Giorgos Keramidas <keramida@freebsd.org>
To: Ceri Davies <ceri@freebsd.org>, start_3.1415926@163.com
Cc: bug-followup@freebsd.org
Subject: Re: kern/93230: usbd source issue
Date: Mon, 13 Feb 2006 03:57:36 +0200

 On 2006-02-12 23:54, Ceri Davies <ceri@freebsd.org> wrote:
 > State-Changed-From-To: open->feedback
 > State-Changed-By: ceri
 > State-Changed-When: Sun Feb 12 23:53:32 UTC 2006
 > State-Changed-Why:
 > There doesn't seem to be anything wrong with the code:
 >
 >         if (modfind(USB_UHUB) < 0) {
 >                 if (kldload(USB_KLD) < 0 || modfind(USB_UHUB) < 0) {
 >                         perror(USB_KLD ": Kernel module not available");
 >                         return 1;
 >                 }
 >         }
 >
 > What exactly do you perceive to be the issue?
 
 I think he refers to the two calls to modfind().  These are actually ok.
 
 If the first modfind() fails, then the module isn't available.  The
 second if block then tries to load it and re-checks after the attempt to
 see if the kldload() call succeeded.
 
 If this snippet does go under any sort of change, it should probably be
 written in a way that avoids a second nesting level and use the err()
 error-reporting function, instead of a hand-rolled equivalent:
 
         /*
          * Check if the USB_UHUB module is loaded and try to load it
          * if it isn't already available.
          */
         if (modfind(USB_UHUB) < 0 &&
             (kldload(USB_UHUB) < 0 || modfind(USB_UHUB) < 0))
                 err(1, "%s: kernel module not available", USB_KLD)
 
 Other that this, it looks fine to me :)
 
 - Giorgos
 
State-Changed-From-To: feedback->closed 
State-Changed-By: ceri 
State-Changed-When: Mon Feb 13 11:32:55 UTC 2006 
State-Changed-Why:  
As keramida took the time to explain (sorry that I didn't), the code is 
fine. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93230 
>Unformatted:
