RDMA/nes: Fixes for sparse endianness warnings
authorTatyana Nikolova <Tatyana.E.Nikolova@intel.com>
Sun, 26 Feb 2012 01:45:37 +0000 (17:45 -0800)
committerRoland Dreier <roland@purestorage.com>
Sun, 26 Feb 2012 01:45:37 +0000 (17:45 -0800)
Fix endianness problems detect by sparse, introduced with the enhanced
MPA patch.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tatyana Nikolova <Tatyana.E.Nikolova@intel.com>
Signed-off-by: Faisal Latif <Faisal.Latif@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/nes/nes_cm.c

index a4972abedef1e967acafc123cfe3fe14bbbabecb..da2c67db5ebb725468bc431801df3880b31e395b 100644 (file)
@@ -338,18 +338,21 @@ static int parse_mpa(struct nes_cm_node *cm_node, u8 *buffer, u32 *type,
        case IETF_MPA_V2: {
                u16 ird_size;
                u16 ord_size;
+               u16 rtr_ctrl_ird;
+               u16 rtr_ctrl_ord;
+
                mpa_v2_frame = (struct ietf_mpa_v2 *)buffer;
                mpa_hdr_len += IETF_RTR_MSG_SIZE;
                cm_node->mpa_frame_size -= IETF_RTR_MSG_SIZE;
                rtr_msg = &mpa_v2_frame->rtr_msg;
 
                /* parse rtr message */
-               rtr_msg->ctrl_ird = ntohs(rtr_msg->ctrl_ird);
-               rtr_msg->ctrl_ord = ntohs(rtr_msg->ctrl_ord);
-               ird_size = rtr_msg->ctrl_ird & IETF_NO_IRD_ORD;
-               ord_size = rtr_msg->ctrl_ord & IETF_NO_IRD_ORD;
+               rtr_ctrl_ird = ntohs(rtr_msg->ctrl_ird);
+               rtr_ctrl_ord = ntohs(rtr_msg->ctrl_ord);
+               ird_size = rtr_ctrl_ird & IETF_NO_IRD_ORD;
+               ord_size = rtr_ctrl_ord & IETF_NO_IRD_ORD;
 
-               if (!(rtr_msg->ctrl_ird & IETF_PEER_TO_PEER)) {
+               if (!(rtr_ctrl_ird & IETF_PEER_TO_PEER)) {
                        /* send reset */
                        return -EINVAL;
                }
@@ -370,9 +373,9 @@ static int parse_mpa(struct nes_cm_node *cm_node, u8 *buffer, u32 *type,
                        }
                }
 
-               if (rtr_msg->ctrl_ord & IETF_RDMA0_READ) {
+               if (rtr_ctrl_ord & IETF_RDMA0_READ) {
                        cm_node->send_rdma0_op = SEND_RDMA_READ_ZERO;
-               } else if (rtr_msg->ctrl_ord & IETF_RDMA0_WRITE) {
+               } else if (rtr_ctrl_ord & IETF_RDMA0_WRITE) {
                        cm_node->send_rdma0_op = SEND_RDMA_WRITE_ZERO;
                } else {        /* Not supported RDMA0 operation */
                        return -EINVAL;
@@ -543,6 +546,8 @@ static void build_mpa_v2(struct nes_cm_node *cm_node,
 {
        struct ietf_mpa_v2 *mpa_frame = (struct ietf_mpa_v2 *)start_addr;
        struct ietf_rtr_msg *rtr_msg = &mpa_frame->rtr_msg;
+       u16 ctrl_ird;
+       u16 ctrl_ord;
 
        /* initialize the upper 5 bytes of the frame */
        build_mpa_v1(cm_node, start_addr, mpa_key);
@@ -550,31 +555,31 @@ static void build_mpa_v2(struct nes_cm_node *cm_node,
        mpa_frame->priv_data_len += htons(IETF_RTR_MSG_SIZE);
 
        /* initialize RTR msg */
-       rtr_msg->ctrl_ird = (cm_node->ird_size > IETF_NO_IRD_ORD) ?
+       ctrl_ird = (cm_node->ird_size > IETF_NO_IRD_ORD) ?
                            IETF_NO_IRD_ORD : cm_node->ird_size;
-       rtr_msg->ctrl_ord = (cm_node->ord_size > IETF_NO_IRD_ORD) ?
+       ctrl_ord = (cm_node->ord_size > IETF_NO_IRD_ORD) ?
                            IETF_NO_IRD_ORD : cm_node->ord_size;
 
-       rtr_msg->ctrl_ird |= IETF_PEER_TO_PEER;
-       rtr_msg->ctrl_ird |= IETF_FLPDU_ZERO_LEN;
+       ctrl_ird |= IETF_PEER_TO_PEER;
+       ctrl_ird |= IETF_FLPDU_ZERO_LEN;
 
        switch (mpa_key) {
        case MPA_KEY_REQUEST:
-               rtr_msg->ctrl_ord |= IETF_RDMA0_WRITE;
-               rtr_msg->ctrl_ord |= IETF_RDMA0_READ;
+               ctrl_ord |= IETF_RDMA0_WRITE;
+               ctrl_ord |= IETF_RDMA0_READ;
                break;
        case MPA_KEY_REPLY:
                switch (cm_node->send_rdma0_op) {
                case SEND_RDMA_WRITE_ZERO:
-                       rtr_msg->ctrl_ord |= IETF_RDMA0_WRITE;
+                       ctrl_ord |= IETF_RDMA0_WRITE;
                        break;
                case SEND_RDMA_READ_ZERO:
-                       rtr_msg->ctrl_ord |= IETF_RDMA0_READ;
+                       ctrl_ord |= IETF_RDMA0_READ;
                        break;
                }
        }
-       rtr_msg->ctrl_ird = htons(rtr_msg->ctrl_ird);
-       rtr_msg->ctrl_ord = htons(rtr_msg->ctrl_ord);
+       rtr_msg->ctrl_ird = htons(ctrl_ird);
+       rtr_msg->ctrl_ord = htons(ctrl_ord);
 }
 
 /**