diff mbox series

net: socket.c: Fix comparison issues

Message ID 20210311044408.t6qut7taaagt4a63@kewl-virtual-machine (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: socket.c: Fix comparison issues | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/header_inline success Link

Commit Message

Shubhankar Kuranagatti March 11, 2021, 4:44 a.m. UTC
The constant has been placed to the right side of the test.

Signed-off-by: Shubhankar Kuranagatti <shubhankarvk@gmail.com>
---
 net/socket.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Xie He March 12, 2021, 4:05 a.m. UTC | #1
What is the reason for this change? Why is the new way better than the
old way?
diff mbox series

Patch

diff --git a/net/socket.c b/net/socket.c
index 84a8049c2b09..a23dd4348793 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1495,7 +1495,7 @@  int __sys_socket(int family, int type, int protocol)
 		return -EINVAL;
 	type &= SOCK_TYPE_MASK;
 
-	if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
+	if ((flags & SOCK_NONBLOCK) && SOCK_NONBLOCK != O_NONBLOCK)
 		flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
 
 	retval = sock_create(family, type, protocol, &sock);
@@ -1526,7 +1526,7 @@  int __sys_socketpair(int family, int type, int protocol, int __user *usockvec)
 		return -EINVAL;
 	type &= SOCK_TYPE_MASK;
 
-	if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
+	if ((flags & SOCK_NONBLOCK) && SOCK_NONBLOCK != O_NONBLOCK)
 		flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
 
 	/*
@@ -1693,7 +1693,7 @@  int __sys_accept4_file(struct file *file, unsigned file_flags,
 	if (flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
 		return -EINVAL;
 
-	if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
+	if ((flags & SOCK_NONBLOCK) && SOCK_NONBLOCK != O_NONBLOCK)
 		flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
 
 	sock = sock_from_file(file);