kern/93230: usbd source issue
Giorgos Keramidas
keramida at freebsd.org
Sun Feb 12 18:00:25 PST 2006
The following reply was made to PR kern/93230; it has been noted by GNATS.
From: Giorgos Keramidas <keramida at freebsd.org>
To: Ceri Davies <ceri at freebsd.org>, start_3.1415926 at 163.com
Cc: bug-followup at 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 at 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
More information about the freebsd-bugs
mailing list