Date: Mon, 13 Feb 2006 02:00:24 GMT From: Giorgos Keramidas <keramida@freebsd.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/93230: usbd source issue Message-ID: <200602130200.k1D20OAl022946@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/93230; it has been noted by GNATS. 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602130200.k1D20OAl022946>