Commit 919765e9 authored by Bart Van Assche's avatar Bart Van Assche Committed by Nicholas Bellinger

target/iscsi: Use min() in iscsit_dump_data_payload() instead of open-coding it

This patch does not change any functionality.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Mike Christie <mchristi@redhat.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 8d973ab5
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "iscsi_target_erl2.h" #include "iscsi_target_erl2.h"
#include "iscsi_target.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 * Used to dump excess datain payload for certain error recovery
...@@ -56,7 +56,7 @@ int iscsit_dump_data_payload( ...@@ -56,7 +56,7 @@ int iscsit_dump_data_payload(
if (conn->sess->sess_ops->RDMAExtensions) if (conn->sess->sess_ops->RDMAExtensions)
return 0; 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); buf = kzalloc(length, GFP_ATOMIC);
if (!buf) { if (!buf) {
...@@ -67,8 +67,7 @@ int iscsit_dump_data_payload( ...@@ -67,8 +67,7 @@ int iscsit_dump_data_payload(
memset(&iov, 0, sizeof(struct kvec)); memset(&iov, 0, sizeof(struct kvec));
while (offset < buf_len) { while (offset < buf_len) {
size = ((offset + length) > buf_len) ? size = min(buf_len - offset, length);
(buf_len - offset) : length;
iov.iov_len = size; iov.iov_len = size;
iov.iov_base = buf; iov.iov_base = buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment