]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
driver: tun: Use new macro SOCK_IOC_TYPE instead of literal number 0x89
authorGao Feng <fgao@ikuai8.com>
Thu, 27 Oct 2016 01:05:22 +0000 (09:05 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 31 Oct 2016 14:56:47 +0000 (10:56 -0400)
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>
drivers/net/tun.c
include/uapi/linux/sockios.h

index 9142db847ee156f8e29dab9856cbcc90021ac541..1588469844e77af30596c4498eb0bde9257e0293 100644 (file)
@@ -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_TYPE) {
                if (copy_from_user(&ifr, argp, ifreq_len))
                        return -EFAULT;
        } else {
index 83cc54ce6081e572984e7ba3c793c5adc7459a6f..79d029d2531005167c13869ba3c136c029aa6665 100644 (file)
@@ -24,6 +24,8 @@
 #define SIOCINQ                FIONREAD
 #define SIOCOUTQ       TIOCOUTQ        /* output queue size (not sent + not acked) */
 
+#define SOCK_IOC_TYPE  0x89
+
 /* Routing table calls. */
 #define SIOCADDRT      0x890B          /* add routing table entry      */
 #define SIOCDELRT      0x890C          /* delete routing table entry   */