From patchwork Tue Oct 31 18:03:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10035079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94F6260327 for ; Tue, 31 Oct 2017 18:03:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CAE728A13 for ; Tue, 31 Oct 2017 18:03:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8189828AA3; Tue, 31 Oct 2017 18:03:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE9928AD4 for ; Tue, 31 Oct 2017 18:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932666AbdJaSDc (ORCPT ); Tue, 31 Oct 2017 14:03:32 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:25243 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932632AbdJaSD1 (ORCPT ); Tue, 31 Oct 2017 14:03:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1509473007; x=1541009007; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=RoJiAcQ30NkmIQzXwMhbYNjCMSIoBpCChlVx8XPyZ5c=; b=q71iB/doLcE6WgwGLRq69JUWUpMYi52pM1cMeAch2Wrx884XAOOyJniR 2wetD6toL6BBro1A3rADFGJvbuH1FJ4kzLcV6/g5G3HWLO0i/X7Br9KZS TN8+PWDiYEdWhxdN8tvVpapLJDrWEYz6bM1cyqUK7BPJ0giGIP7a1DTrH FeQzuOZeYFqPOk0+Vc0AlLZ2Gkr3flxkwGJGG4T6N9skjwR+EwBOTB9IO Esy5AakHRvS8HdcLwg4mbYZqf0BNtMx9hA9L5L/BpzevuGPXiPAJTGHYi 0r0l/6Ga5eXQb27578fk74jNK4u5cIxw1OmfQ+/TACEWHNj7cMcOxD11T A==; X-IronPort-AV: E=Sophos;i="5.44,325,1505750400"; d="scan'208";a="60328645" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 01 Nov 2017 02:03:24 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 31 Oct 2017 11:01:09 -0700 Received: from unknown (HELO MILHUBIP03.sdcorp.global.sandisk.com) ([10.177.9.96]) by uls-op-cesaip02.wdc.com with ESMTP; 31 Oct 2017 11:03:24 -0700 Received: from milsmgip12.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Tue, 31 Oct 2017 11:03:23 -0700 X-AuditID: 0ab1095a-d99e3980000146e4-51-59f8baea3369 Received: from thinkpad-bart.int.fusionio.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id BA.A9.18148.AEAB8F95; Tue, 31 Oct 2017 11:03:22 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , "James E . J . Bottomley" CC: Nicholas Bellinger , Christoph Hellwig , , Bart Van Assche , Bart Van Assche , Hannes Reinecke , Mike Christie Subject: [PATCH 06/11] target/iscsi: Use min() in iscsit_dump_data_payload() instead of open-coding it Date: Tue, 31 Oct 2017 11:03:14 -0700 Message-ID: <20171031180319.19258-7-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171031180319.19258-1-bart.vanassche@wdc.com> References: <20171031180319.19258-1-bart.vanassche@wdc.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHJMWRmVeSWpSXmKPExsXCtZEjRffVrh+RBvP+G1sc/NnGaHHpzxdG iwVv9rJZrFx9lMli1cQ8i+XH/zFZrD+ygdGibfUZRovWpW+ZHDg97m8/wuTx4NBmFo/dNxvY PD4+vcXi8X7fVTaPaWvOM3ms33KVxePzJjmP9gPdTAGcUVw2Kak5mWWpRfp2CVwZK36eYy6Y wV3x/PUE9gbGRZxdjJwcEgImEveb3jJ2MXJxCAmsZpR4tvMMC0iCTUBP4tS8fUwgtohArsSp hzeYQIqYBaYwSSxcdJQVJCEskCZx8tICZhCbRUBVYkrfXkYQm1fAWmLzui8sEBvkJd4vuA8W 5xSwkXjbsxssLgRUc23vEuYJjNwLGBlWMYrlZuYU56ZnFhga6RUn5qVkFmfrJefnbmIEhxhn 1A7G6xPNDzEycXBKNTC2yd4r1lAQW6nDfS6Etf1y0eu9gYes0u7eZ5/X1/7R1aUotnHBy59M er8q7k5gLvSMei9xStk9b+3PZY9XeofylPwJavpYbr1sz/cr6ks/2Mr8O6R9zGL2BCHW618+ nznJUhrx78KmmV8t7xQZc9SJqJpNaxb+kc7WGLzwy+bEzKMJvbHXis8rsRRnJBpqMRcVJwIA x8KKC+EBAAA= MIME-Version: 1.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch does not change any functionality. Signed-off-by: Bart Van Assche Cc: Nicholas Bellinger Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/target/iscsi/iscsi_target_erl1.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index fe9b7f1e44ac..659efafb43ec 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -34,7 +34,7 @@ #include "iscsi_target_erl2.h" #include "iscsi_target.h" -#define OFFLOAD_BUF_SIZE 32768 +#define OFFLOAD_BUF_SIZE 32768U /* * Used to dump excess datain payload for certain error recovery @@ -56,7 +56,7 @@ int iscsit_dump_data_payload( if (conn->sess->sess_ops->RDMAExtensions) return 0; - length = (buf_len > OFFLOAD_BUF_SIZE) ? OFFLOAD_BUF_SIZE : buf_len; + length = min(buf_len, OFFLOAD_BUF_SIZE); buf = kzalloc(length, GFP_ATOMIC); if (!buf) { @@ -67,8 +67,7 @@ int iscsit_dump_data_payload( memset(&iov, 0, sizeof(struct kvec)); while (offset < buf_len) { - size = ((offset + length) > buf_len) ? - (buf_len - offset) : length; + size = min(buf_len - offset, length); iov.iov_len = size; iov.iov_base = buf;