use MIN and MAX macros at some places

Signed-off-by: Peter Lieven <pl@kamp.de>
This commit is contained in:
Peter Lieven
2015-02-23 08:03:27 +01:00
parent dd6831a50f
commit de7b38d9a0
2 changed files with 5 additions and 16 deletions

View File

@@ -179,13 +179,9 @@ iscsi_create_context(const char *initiator_name)
/* iscsi->smalloc_size is the size for small allocations. this should be
max(ISCSI_HEADER_SIZE, sizeof(struct iscsi_pdu), sizeof(struct iscsi_in_pdu))
rounded up to the next power of 2. */
required = MAX(required, sizeof(struct iscsi_pdu));
required = MAX(required, sizeof(struct iscsi_in_pdu));
iscsi->smalloc_size = 1;
if (sizeof(struct iscsi_pdu) > required) {
required = sizeof(struct iscsi_pdu);
}
if (sizeof(struct iscsi_in_pdu) > required) {
required = sizeof(struct iscsi_in_pdu);
}
while (iscsi->smalloc_size < required) {
iscsi->smalloc_size <<= 1;
}

View File

@@ -76,9 +76,7 @@ iscsi_send_data_out(struct iscsi_context *iscsi, struct iscsi_pdu *cmd_pdu,
struct iscsi_pdu *pdu;
int flags;
if (len > iscsi->target_max_recv_data_segment_length) {
len = iscsi->target_max_recv_data_segment_length;
}
len = MIN(len, iscsi->target_max_recv_data_segment_length);
pdu = iscsi_allocate_pdu_with_itt_flags(iscsi, ISCSI_PDU_DATA_OUT,
ISCSI_PDU_NO_PDU,
@@ -269,13 +267,8 @@ iscsi_scsi_command_async(struct iscsi_context *iscsi, int lun,
if (iscsi->use_immediate_data == ISCSI_IMMEDIATE_DATA_YES) {
uint32_t len = task->expxferlen;
if (len > iscsi->first_burst_length) {
len = iscsi->first_burst_length;
}
if (len > iscsi->target_max_recv_data_segment_length) {
len = iscsi->target_max_recv_data_segment_length;
}
len = MIN(len, iscsi->first_burst_length);
len = MIN(len, iscsi->target_max_recv_data_segment_length);
pdu->payload_offset = 0;
pdu->payload_len = len;