net/mlx4: fix shifts of signed values in Tx
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>
Wed, 16 May 2018 16:20:54 +0000 (18:20 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 17 May 2018 17:06:29 +0000 (19:06 +0200)
This patch addresses the following issues reported by cppcheck:

 [drivers/net/mlx4/mlx4_rxtx.c:266]: (error) Shifting signed 32-bit value
     by 31 bits is undefined behaviour
 [drivers/net/mlx4/mlx4_rxtx.c:624]: (error) Shifting signed 32-bit value
     by 31 bits is undefined behaviour
 [drivers/net/mlx4/mlx4_txq.c:89]: (error) Shifting signed 32-bit value by
     31 bits is undefined behaviour
 [drivers/net/mlx4/mlx4_txq.c:91]: (error) Shifting signed 32-bit value by
     31 bits is undefined behaviour

Fixes: 78e81a9844f8 ("net/mlx4: merge Tx queue rings management")
Cc: stable@dpdk.org
Reported-by: Ferruh Yigit <ferruh.yigit@intel.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
drivers/net/mlx4/mlx4_rxtx.c
drivers/net/mlx4/mlx4_txq.c

index 44efeb4..a92da66 100644 (file)
@@ -263,7 +263,7 @@ mlx4_txq_stamp_freed_wqe(struct mlx4_sq *sq, volatile uint32_t *start,
                } while (start != (volatile uint32_t *)sq->eob);
                start = (volatile uint32_t *)sq->buf;
                /* Flip invalid stamping ownership. */
-               stamp ^= RTE_BE32(0x1 << MLX4_SQ_OWNER_BIT);
+               stamp ^= RTE_BE32(1u << MLX4_SQ_OWNER_BIT);
                sq->stamp = stamp;
                if (start == end)
                        return size;
@@ -621,7 +621,7 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
                        ctrl_next = (volatile struct mlx4_wqe_ctrl_seg *)
                                ((volatile uint8_t *)ctrl_next - sq->size);
                        /* Flip HW valid ownership. */
-                       sq->owner_opcode ^= 0x1 << MLX4_SQ_OWNER_BIT;
+                       sq->owner_opcode ^= 1u << MLX4_SQ_OWNER_BIT;
                }
                /*
                 * For raw Ethernet, the SOLICIT flag is used to indicate
index a358732..6edaadb 100644 (file)
@@ -86,9 +86,9 @@ mlx4_txq_fill_dv_obj_info(struct txq *txq, struct mlx4dv_obj *mlxdv)
        uint32_t headroom_size = 2048 + (1 << dqp->sq.wqe_shift);
        /* Continuous headroom size bytes must always stay freed. */
        sq->remain_size = sq->size - headroom_size;
-       sq->owner_opcode = MLX4_OPCODE_SEND | (0 << MLX4_SQ_OWNER_BIT);
+       sq->owner_opcode = MLX4_OPCODE_SEND | (0u << MLX4_SQ_OWNER_BIT);
        sq->stamp = rte_cpu_to_be_32(MLX4_SQ_STAMP_VAL |
-                                    (0 << MLX4_SQ_OWNER_BIT));
+                                    (0u << MLX4_SQ_OWNER_BIT));
        sq->db = dqp->sdb;
        sq->doorbell_qpn = dqp->doorbell_qpn;
        cq->buf = dcq->buf.buf;