Subject: Re: minor kqueue bug?
To: Emmanuel Dreyfus <manu@netbsd.org>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 09/21/2003 10:16:39
On Sun, 21 Sep 2003, Emmanuel Dreyfus wrote:
> I see no reason for (*cdev->d_tty)() to always return a tty.
True.
> For now if a wsscreen has no tty attached, it will return a garbage
> pointer, I'm working on a patch to fix that, but of course then
> (*cdev->d_tty)() will return NULL. Therefore I'd suggest this:
>
> if (((cdev = cdevsw_lookup(dev)) == NULL) ||
> ((tp = (*cdev->d_tty)(dev)) == NULL)))
> return (ENXIO);
>
> What do you think? It could be inappropriate if you can assume that
> ttykqfilter will never be called for an unallocated wsscreen, but is it
> the case?
No, it seems quite appropriate. I can think of a number of cases where
there isn't a tty, so this code should deal with it.
> Additionnally, shouldn't we check (cdev->d_tty != NULL)? Is d_tty
> mandatory for any character device? If it's not, we would do this:
>
> if (((cdev = cdevsw_lookup(dev)) == NULL) ||
> ((cdev->d_tty == NULL)) ||
> ((tp = (*cdev->d_tty)(dev)) == NULL)))
> return (ENXIO);
Sounds good.
Take care,
Bill