Skip to content

Commit

Permalink
use MIN and MAX macros at some places
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Lieven <pl@kamp.de>
  • Loading branch information
plieven committed Feb 23, 2015
1 parent dd6831a commit de7b38d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
8 changes: 2 additions & 6 deletions lib/init.c
Expand Up @@ -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;
}
Expand Down
13 changes: 3 additions & 10 deletions lib/iscsi-command.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit de7b38d

Please sign in to comment.