Skip to content

Commit 20861f2

Browse files
gfreewinddavem330
authored andcommitted
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>
1 parent c62cce2 commit 20861f2

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

drivers/net/tun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
19851985
int le;
19861986
int ret;
19871987

1988-
if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
1988+
if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == SOCK_IOC_TYPE) {
19891989
if (copy_from_user(&ifr, argp, ifreq_len))
19901990
return -EFAULT;
19911991
} else {

include/uapi/linux/sockios.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#define SIOCINQ FIONREAD
2525
#define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */
2626

27+
#define SOCK_IOC_TYPE 0x89
28+
2729
/* Routing table calls. */
2830
#define SIOCADDRT 0x890B /* add routing table entry */
2931
#define SIOCDELRT 0x890C /* delete routing table entry */

0 commit comments

Comments
 (0)