tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: scanning ...wiconfig: ioctl: No such file or directory



On Sat, Jun 20, 2009 at 10:56:17AM +0100, Iain Hibbert wrote:
> 
> Good catch, though imo its unclean to use errno in this way as it only
> indicates what error occurred, not the presence of an error. Although the
> change is bigger, is it better to do
> 
...
>       while (ioctl(s, SIOCGWAVELAN, &ifr) == -1) {
>               retries--;
> !             if (retries < 0) {
> !                     set_if_flags(s, iface, flags);
> !                     close(s);
> !                     err(1, "ioctl");
> !             }
> 
> !             printf(".");
> !             fflush(stdout);
> !             sleep(1);
>       }

That is still (ate least IMHO) buggy sine the err() call needs to
be made before the set_if_flags() and close() since either could,
at least potentially, change errno.

I've also just had a wicked thought that a signal handler might
also run and change errno!
I wonder how that affects the checking of errno for some libc functions!

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index