From: Shubhankar Kuranagatti <shubhankarvk@gmail.com>
To: davem@davemloft.net
Cc: kuba@kernel.org, edumazet@google.com, willemb@google.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
mchehab+huawei@kernel.org
Subject: [PATCH 1/2] net: core: datagram.c: Fix use of assignment in if condition
Date: Thu, 11 Mar 2021 16:04:46 +0530 [thread overview]
Message-ID: <20210311103446.5dwjcopeggy7k6gg@kewl-virtual-machine> (raw)
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
next reply other threads:[~2021-03-11 10:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-11 10:34 Shubhankar Kuranagatti [this message]
2021-03-11 10:59 ` Eric Dumazet
2021-03-11 15:39 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210311103446.5dwjcopeggy7k6gg@kewl-virtual-machine \
--to=shubhankarvk@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®