All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] net: core: datagram.c: Fix use of assignment in if condition
@ 2021-03-11 10:34 Shubhankar Kuranagatti
  2021-03-11 10:59 ` Eric Dumazet
  2021-03-11 15:39   ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Shubhankar Kuranagatti @ 2021-03-11 10:34 UTC (permalink / raw)
  To: davem; +Cc: kuba, edumazet, willemb, netdev, linux-kernel, mchehab+huawei

The assignment inside the if condition has been changed to
initialising outside the if condition.

Signed-off-by: Shubhankar Kuranagatti <shubhankarvk@gmail.com>
---
 net/core/datagram.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/net/core/datagram.c b/net/core/datagram.c
index 15ab9ffb27fe..7b2204f102b7 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -427,7 +427,8 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 		offset += n;
 		if (n != copy)
 			goto short_copy;
-		if ((len -= copy) == 0)
+		len -= copy
+		if ((len) == 0)
 			return 0;
 	}
 
@@ -439,7 +440,8 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 		WARN_ON(start > offset + len);
 
 		end = start + skb_frag_size(frag);
-		if ((copy = end - offset) > 0) {
+		copy = end - offset
+		if ((copy) > 0) {
 			struct page *page = skb_frag_page(frag);
 			u8 *vaddr = kmap(page);
 
@@ -452,7 +454,8 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 			offset += n;
 			if (n != copy)
 				goto short_copy;
-			if (!(len -= copy))
+			len -= copy
+			if (!(len))
 				return 0;
 		}
 		start = end;
@@ -464,13 +467,15 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
 		WARN_ON(start > offset + len);
 
 		end = start + frag_iter->len;
-		if ((copy = end - offset) > 0) {
+		copy = end - offset;
+		if ((copy) > 0) {
 			if (copy > len)
 				copy = len;
 			if (__skb_datagram_iter(frag_iter, offset - start,
 						to, copy, fault_short, cb, data))
 				goto fault;
-			if ((len -= copy) == 0)
+			len -= copy
+			if ((len) == 0)
 				return 0;
 			offset += copy;
 		}
@@ -558,7 +563,8 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
 			copy = len;
 		if (copy_from_iter(skb->data + offset, copy, from) != copy)
 			goto fault;
-		if ((len -= copy) == 0)
+		len -= copy;
+		if ((len) == 0)
 			return 0;
 		offset += copy;
 	}
@@ -571,7 +577,8 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
 		WARN_ON(start > offset + len);
 
 		end = start + skb_frag_size(frag);
-		if ((copy = end - offset) > 0) {
+		copy = end - offset;
+		if ((copy) > 0) {
 			size_t copied;
 
 			if (copy > len)
@@ -581,8 +588,8 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
 					  copy, from);
 			if (copied != copy)
 				goto fault;
-
-			if (!(len -= copy))
+			len -= copy
+			if (!(len))
 				return 0;
 			offset += copy;
 		}
@@ -595,14 +602,16 @@ int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
 		WARN_ON(start > offset + len);
 
 		end = start + frag_iter->len;
-		if ((copy = end - offset) > 0) {
+		copy = end - offset;
+		if ((copy) > 0) {
 			if (copy > len)
 				copy = len;
 			if (skb_copy_datagram_from_iter(frag_iter,
 							offset - start,
 							from, copy))
 				goto fault;
-			if ((len -= copy) == 0)
+			len -= copy;
+			if ((len) == 0)
 				return 0;
 			offset += copy;
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-11 15:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 10:34 [PATCH 1/2] net: core: datagram.c: Fix use of assignment in if condition Shubhankar Kuranagatti
2021-03-11 10:59 ` Eric Dumazet
2021-03-11 15:39 ` kernel test robot
2021-03-11 15:39   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.