Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver: tun: Use new macro SOCK_IOC_TYPE instead of literal number 0x89

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_TYPE to enhance the readability.

Signed-off-by: Gao Feng <fgao@ikuai8.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Gao Feng and committed by
David S. Miller
20861f26 c62cce2c

+3 -1
+1 -1
drivers/net/tun.c
··· 1985 1985 int le; 1986 1986 int ret; 1987 1987 1988 - if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) { 1988 + if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == SOCK_IOC_TYPE) { 1989 1989 if (copy_from_user(&ifr, argp, ifreq_len)) 1990 1990 return -EFAULT; 1991 1991 } else {
+2
include/uapi/linux/sockios.h
··· 24 24 #define SIOCINQ FIONREAD 25 25 #define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */ 26 26 27 + #define SOCK_IOC_TYPE 0x89 28 + 27 29 /* Routing table calls. */ 28 30 #define SIOCADDRT 0x890B /* add routing table entry */ 29 31 #define SIOCDELRT 0x890C /* delete routing table entry */