Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] net/tls: Do not call msg_data_left() twice
@ 2018-07-24 11:11 Vakul Garg
  2018-07-25  1:49 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Vakul Garg @ 2018-07-24 11:11 UTC (permalink / raw)
  To: netdev; +Cc: borisp, aviadye, davejwatson, davem, Vakul Garg

In function tls_sw_sendmsg(), msg_data_left() needs to be called only
once. The second invocation of msg_data_left() for assigning variable
try_to_copy can be removed and merged with the first one.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
---
 net/tls/tls_sw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 0c2d029c9d4c..fd51ce65b99c 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -377,7 +377,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
 			goto send_end;
 	}
 
-	while (msg_data_left(msg)) {
+	while ((try_to_copy = msg_data_left(msg))) {
 		if (sk->sk_err) {
 			ret = -sk->sk_err;
 			goto send_end;
@@ -385,7 +385,6 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
 
 		orig_size = ctx->sg_plaintext_size;
 		full_record = false;
-		try_to_copy = msg_data_left(msg);
 		record_room = TLS_MAX_PAYLOAD_SIZE - ctx->sg_plaintext_size;
 		if (try_to_copy >= record_room) {
 			try_to_copy = record_room;
-- 
2.13.6

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

end of thread, other threads:[~2018-07-25  3:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-24 11:11 [PATCH net-next] net/tls: Do not call msg_data_left() twice Vakul Garg
2018-07-25  1:49 ` Al Viro
2018-07-25  1:54   ` Vakul Garg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox