From owner-freebsd-bugs@FreeBSD.ORG Mon Feb 13 02:00:25 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5147D16A420 for ; Mon, 13 Feb 2006 02:00:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9195943D45 for ; Mon, 13 Feb 2006 02:00:24 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k1D20OPX022947 for ; Mon, 13 Feb 2006 02:00:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k1D20OAl022946; Mon, 13 Feb 2006 02:00:24 GMT (envelope-from gnats) Date: Mon, 13 Feb 2006 02:00:24 GMT Message-Id: <200602130200.k1D20OAl022946@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Cc: Subject: Re: kern/93230: usbd source issue X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Feb 2006 02:00:25 -0000 The following reply was made to PR kern/93230; it has been noted by GNATS. From: Giorgos Keramidas To: Ceri Davies , 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 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