[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB020AC7B@AcuExch.aculab.com>
Date: Wed, 26 Oct 2016 11:12:38 +0000
From: David Laight <David.Laight@...LAB.COM>
To: "'fgao@...ai8.com'" <fgao@...ai8.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"jasowang@...hat.com" <jasowang@...hat.com>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"pabeni@...hat.com" <pabeni@...hat.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: "gfree.wind@...il.com" <gfree.wind@...il.com>
Subject: RE: [PATCH net-next 1/1] driver: tun: Use new macro SOCK_IOC_MAGIC
instead of literal number 0x89
From: fgao@...ai8.com
> Sent: 25 October 2016 13:56
> The current codes use _IOC_TYPE(cmd) == 0x89 to check if the cmd is one
> socket ioctl command like SIOCGIFHWADDR. But the literal number 0x89 may
> confuse readers. So create one macro SOCK_IOC_MAGIC like SPI_IOC_MAGIC to
> enhance the readability.
>
> Signed-off-by: Gao Feng <fgao@...ai8.com>
> ---
> drivers/net/tun.c | 2 +-
> include/uapi/linux/sockios.h | 2 ++
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 9328568..9efd185 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1985,7 +1985,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
> int le;
> int ret;
>
> - if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
> + if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == SOCK_IOC_MAGIC) {
> if (copy_from_user(&ifr, argp, ifreq_len))
> return -EFAULT;
> } else {
> diff --git a/include/uapi/linux/sockios.h b/include/uapi/linux/sockios.h
> index 8e7890b..b8f42f2 100644
> --- a/include/uapi/linux/sockios.h
> +++ b/include/uapi/linux/sockios.h
> @@ -24,6 +24,8 @@
> #define SIOCINQ FIONREAD
> #define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */
>
> +#define SOCK_IOC_MAGIC 0x89
> +
> /* Routing table calls. */
> #define SIOCADDRT 0x890B /* add routing table entry */
> #define SIOCDELRT 0x890C /* delete routing table entry */
Shouldn't these constants be defined in terms of SOCK_IOC_MAGIC?
And there must be a better name!
David
Powered by blists - more mailing lists