net/tls: Do not call msg_data_left() twice
Subsystems (3)
PATCH 1/1 net/tls: Do not call msg_data_left() twice
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.
--- net/tls/tls_sw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/tls/tls_sw.c +1 -2
@@ -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;
Signature · 1 line
2.13.6
Quoted 3 lines · Vakul Garg
In function
tls_sw_sendmsg(),msg_data_left()needs to be called only once. The second invocation ofmsg_data_left()for assigning variabletry_to_copycan be removed and merged with the first one.
You do realize that msg_data_left(msg) is simply msg->msg_iter.count? So I'm not at all sure that your change will be an overall win...
From: Al Viro
Sent: Wednesday, 25 July, 7:19 AM
Subject: Re: [PATCH net-next] net/tls: Do not call msg_data_left() twice
To: Vakul Garg
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
On Tue, Jul 24, 2018 at 04:41:18PM +0530, Vakul Garg wrote: > 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. You do realize that msg_data_left(msg) is simply msg->msg_iter.count? So I'm not at all sure that your change will be an overall win...
Agreed, msg_data_left is inexpensive. It's just that is pointless to call it again.