From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vakul Garg Subject: [PATCH net-next] net/tls: Do not call msg_data_left() twice Date: Tue, 24 Jul 2018 16:41:18 +0530 Message-ID: <20180724111118.15415-1-vakul.garg@nxp.com> Mime-Version: 1.0 Content-Type: text/plain Cc: borisp@mellanox.com, aviadye@mellanox.com, davejwatson@fb.com, davem@davemloft.net, Vakul Garg To: netdev@vger.kernel.org Return-path: Received: from mail-eopbgr60055.outbound.protection.outlook.com ([40.107.6.55]:27520 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388109AbeGXG4g (ORCPT ); Tue, 24 Jul 2018 02:56:36 -0400 Sender: netdev-owner@vger.kernel.org List-ID: 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 --- 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