Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Feb 2006 10:04:28 +0100
From:      Andre Oppermann <andre@freebsd.org>
To:        Gleb Smirnoff <glebius@FreeBSD.org>
Cc:        arch@FreeBSD.org, yar@FreeBSD.org, jlemon@FreeBSD.org
Subject:   Re: changing EINVAL for SIOCSIFCAP to something else
Message-ID:  <4402C09C.C3FB0064@freebsd.org>
References:  <20060227083815.GW55275@cell.sick.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Gleb Smirnoff wrote:
> 
>   Colleagues,
> 
>   I'd like to replace the unpleasant one-for-all error code
> EINVAL to something else in this part of code of
> src/sys/net/if.c:ifhwioctl()
> 
>         case SIOCSIFCAP:
>                 error = suser(td);
>                 if (error)
>                         return (error);
>                 if (ifp->if_ioctl == NULL)
>                         return (EOPNOTSUPP);
>                 if (ifr->ifr_reqcap & ~ifp->if_capabilities)
>                         return (EINVAL);
>                 IFF_LOCKGIANT(ifp);
>                 error = (*ifp->if_ioctl)(ifp, cmd, data);
>                 IFF_UNLOCKGIANT(ifp);
>                 if (error == 0)
>                         getmicrotime(&ifp->if_lastchange);
>                 break;
> 
> The possible variants are:
> 
> #define ENODEV          19              /* Operation not supported by device */
> #define ENOTTY          25              /* Inappropriate ioctl for device */
> #define ENOPROTOOPT     42              /* Protocol not available */
> #define EPROTONOSUPPORT 43              /* Protocol not supported */
> 
> I prefer this variant:
> 
>                 if (ifp->if_ioctl == NULL)
>                         return (ENOTTY);
>                 if (ifr->ifr_reqcap & ~ifp->if_capabilities)
>                         return (ENODEV);
> 
> Any objections?

I don't think ENOTTY is appropriate here even though the comment to this
error code would fit.  But the define still says no TTY which is totally
unrelated and confusing.

-- 
Andre



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4402C09C.C3FB0064>