From 0d73f143b8cced60760f8af4ca84e84cb02e89a7 Mon Sep 17 00:00:00 2001 From: yidong0635 Date: Thu, 23 Jul 2020 05:18:53 -0400 Subject: [PATCH] lib/iscsi: Put bits NAND or OR together. We can OR some of the bits ,and setting them one time. Signed-off-by: yidong0635 Change-Id: Ie919ef66f3b8deea125df47d2194130b364c302a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3489 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Reviewed-by: Changpeng Liu --- lib/iscsi/iscsi.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index febf4cac4..1412517e7 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -1203,9 +1203,8 @@ iscsi_op_login_response(struct spdk_iscsi_conn *conn, /* Set T/CSG/NSG to reserved if login error. */ if (rsph->status_class != 0) { - rsph->flags &= ~ISCSI_LOGIN_TRANSIT; - rsph->flags &= ~ISCSI_LOGIN_CURRENT_STAGE_MASK; - rsph->flags &= ~ISCSI_LOGIN_NEXT_STAGE_MASK; + rsph->flags &= ~(ISCSI_LOGIN_TRANSIT | ISCSI_LOGIN_CURRENT_STAGE_MASK | + ISCSI_LOGIN_NEXT_STAGE_MASK); } iscsi_param_free(params); iscsi_conn_write_pdu(conn, rsp_pdu, cb_fn, conn); @@ -1242,9 +1241,8 @@ iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn, rsp_pdu->data_buf_len = 8192; reqh = (struct iscsi_bhs_login_req *)&pdu->bhs; - rsph->flags |= (reqh->flags & ISCSI_LOGIN_TRANSIT); - rsph->flags |= (reqh->flags & ISCSI_LOGIN_CONTINUE); - rsph->flags |= (reqh->flags & ISCSI_LOGIN_CURRENT_STAGE_MASK); + rsph->flags |= (reqh->flags & (ISCSI_LOGIN_TRANSIT | ISCSI_LOGIN_CONTINUE | + ISCSI_LOGIN_CURRENT_STAGE_MASK)); if (ISCSI_BHS_LOGIN_GET_TBIT(rsph->flags)) { rsph->flags |= (reqh->flags & ISCSI_LOGIN_NEXT_STAGE_MASK); } @@ -1303,11 +1301,9 @@ iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn, if ((ISCSI_BHS_LOGIN_GET_NSG(rsph->flags) == ISCSI_NSG_RESERVED_CODE) && ISCSI_BHS_LOGIN_GET_TBIT(rsph->flags)) { - /* set NSG to zero */ - rsph->flags &= ~ISCSI_LOGIN_NEXT_STAGE_MASK; - /* also set other bits to zero */ - rsph->flags &= ~ISCSI_LOGIN_TRANSIT; - rsph->flags &= ~ISCSI_LOGIN_CURRENT_STAGE_MASK; + /* set NSG and other bits to zero */ + rsph->flags &= ~(ISCSI_LOGIN_NEXT_STAGE_MASK | ISCSI_LOGIN_TRANSIT | + ISCSI_LOGIN_CURRENT_STAGE_MASK); SPDK_ERRLOG("Received reserved NSG code: %d\n", ISCSI_NSG_RESERVED_CODE); /* Initiator error */ rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; @@ -3055,8 +3051,7 @@ iscsi_transfer_in(struct spdk_iscsi_conn *conn, struct spdk_iscsi_task *task) for (; offset < sequence_end; offset += segment_len) { len = spdk_min(segment_len, (sequence_end - offset)); - datain_flag &= ~ISCSI_FLAG_FINAL; - datain_flag &= ~ISCSI_DATAIN_STATUS; + datain_flag &= ~(ISCSI_FLAG_FINAL | ISCSI_DATAIN_STATUS); if (offset + len == sequence_end) { /* last PDU in a sequence */