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>
This commit is contained in:

committed by
David S. Miller

parent
c62cce2cae
commit
20861f26e3
@@ -1985,7 +1985,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
|
|||||||
int le;
|
int le;
|
||||||
int ret;
|
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))
|
if (copy_from_user(&ifr, argp, ifreq_len))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -24,6 +24,8 @@
|
|||||||
#define SIOCINQ FIONREAD
|
#define SIOCINQ FIONREAD
|
||||||
#define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */
|
#define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */
|
||||||
|
|
||||||
|
#define SOCK_IOC_TYPE 0x89
|
||||||
|
|
||||||
/* Routing table calls. */
|
/* Routing table calls. */
|
||||||
#define SIOCADDRT 0x890B /* add routing table entry */
|
#define SIOCADDRT 0x890B /* add routing table entry */
|
||||||
#define SIOCDELRT 0x890C /* delete routing table entry */
|
#define SIOCDELRT 0x890C /* delete routing table entry */
|
||||||
|
Reference in New Issue
Block a user