From bac94c18b83a593b9ad445bb678f6b37e5be1cea Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 7 Mar 2020 12:32:35 -0800 Subject: [PATCH] libiscsi: Reduce the size of struct iscsi_context Reduce the size of struct iscsi_context by reordering the members of this data structure. Additionally, change the rdma_ack_timeout value from 'unsigned char' into 'uint8_t' to make it clear that this variable represents an integer. Signed-off-by: Bart Van Assche --- include/iscsi-private.h | 3 +-- lib/init.c | 4 ++-- lib/iser.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/iscsi-private.h b/include/iscsi-private.h index 178669c..1c4a0f5 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -89,6 +89,7 @@ struct iscsi_context { enum iscsi_session_type session_type; unsigned char isid[6]; + uint8_t rdma_ack_timeout; uint32_t itt; uint32_t cmdsn; uint32_t min_cmdsn_waiting; @@ -109,8 +110,6 @@ struct iscsi_context { int tcp_syncnt; int tcp_nonblocking; - unsigned char rdma_ack_timeout; - int current_phase; int next_phase; #define ISCSI_LOGIN_SECNEG_PHASE_OFFER_CHAP 0 diff --git a/lib/init.c b/lib/init.c index 8b2c3df..5c49ab8 100644 --- a/lib/init.c +++ b/lib/init.c @@ -281,7 +281,7 @@ iscsi_create_context(const char *initiator_name) } if (getenv("LIBISCSI_RDMA_ACK_TIMEOUT") != NULL) { - iscsi->rdma_ack_timeout = (unsigned char)atoi(getenv("LIBISCSI_RDMA_ACK_TIMEOUT")); + iscsi->rdma_ack_timeout = atoi(getenv("LIBISCSI_RDMA_ACK_TIMEOUT")); } /* iscsi->smalloc_size is the size for small allocations. this should be @@ -622,7 +622,7 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) } else if (!strcmp(key, "iser")) { is_iser = 1; } else if (!strcmp(key, "LIBISCSI_RDMA_ACK_TIMEOUT")) { - iscsi->rdma_ack_timeout = (unsigned char)atoi(value); + iscsi->rdma_ack_timeout = atoi(value); #endif } tmp = next; diff --git a/lib/iser.c b/lib/iser.c index eebb419..1440f37 100644 --- a/lib/iser.c +++ b/lib/iser.c @@ -830,7 +830,7 @@ void iscsi_set_rdma_ack_timetout(struct iscsi_context *iscsi, unsigned char valu */ int iser_rdma_set_option(struct rdma_cm_id *cma_id, struct iscsi_context *iscsi) { int ret = 0; - unsigned char timeout = iscsi->rdma_ack_timeout; + uint8_t timeout = iscsi->rdma_ack_timeout; if (timeout) { #ifdef HAVE_RDMA_ACK_TIMEOUT