diff options
author | eadler <eadler@FreeBSD.org> | 2014-02-04 03:36:42 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2014-02-04 03:36:42 +0000 |
commit | ec294fd7f5fc5de11ed889d6c2d701f918d1ecfb (patch) | |
tree | 7e76e370b9406b0383b17bd343084addb4ad6a25 /sys/ofed | |
parent | d374d7f398b846dc59d8a5ec3c7bfb318cf880af (diff) | |
download | FreeBSD-src-ec294fd7f5fc5de11ed889d6c2d701f918d1ecfb.zip FreeBSD-src-ec294fd7f5fc5de11ed889d6c2d701f918d1ecfb.tar.gz |
MFC r258779,r258780,r258787,r258822:
Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit. Instead use (1U << 31) which gets the
expected result.
Similar to the (1 << 31) case it is not defined to do (2 << 30).
This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.
A similar change was made in OpenBSD.
Diffstat (limited to 'sys/ofed')
-rw-r--r-- | sys/ofed/drivers/infiniband/hw/mlx4/qp.c | 10 | ||||
-rw-r--r-- | sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c | 10 | ||||
-rw-r--r-- | sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c | 4 | ||||
-rw-r--r-- | sys/ofed/drivers/net/mlx4/mcg.c | 2 |
4 files changed, 13 insertions, 13 deletions
diff --git a/sys/ofed/drivers/infiniband/hw/mlx4/qp.c b/sys/ofed/drivers/infiniband/hw/mlx4/qp.c index b3baa6d..9b5cb95 100644 --- a/sys/ofed/drivers/infiniband/hw/mlx4/qp.c +++ b/sys/ofed/drivers/infiniband/hw/mlx4/qp.c @@ -275,7 +275,7 @@ static void post_nop_wqe(struct mlx4_ib_qp *qp, int n, int size) wmb(); ctrl->owner_opcode = cpu_to_be32(MLX4_OPCODE_NOP | MLX4_WQE_CTRL_NEC) | - (n & qp->sq.wqe_cnt ? cpu_to_be32(1 << 31) : 0); + (n & qp->sq.wqe_cnt ? cpu_to_be32(1U << 31) : 0); stamp_send_wqe(qp, n + qp->sq_spare_wqes, size); } @@ -2073,7 +2073,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp, for (i = 0; i < qp->sq.wqe_cnt; ++i) { ctrl = get_send_wqe(qp, i); - ctrl->owner_opcode = cpu_to_be32(1 << 31); + ctrl->owner_opcode = cpu_to_be32(1U << 31); if (qp->sq_max_wqes_per_wr == 1) ctrl->fence_size = 1 << (qp->sq.wqe_shift - 4); @@ -2832,7 +2832,7 @@ static void set_mlx_icrc_seg(void *dseg) */ wmb(); - iseg->byte_count = cpu_to_be32((1 << 31) | 4); + iseg->byte_count = cpu_to_be32((1U << 31) | 4); } static void set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ib_sge *sg) @@ -2900,7 +2900,7 @@ static void add_zero_len_inline(void *wqe) { struct mlx4_wqe_inline_seg *inl = wqe; memset(wqe, 0, 16); - inl->byte_count = cpu_to_be32(1 << 31); + inl->byte_count = cpu_to_be32(1U << 31); } static int lay_inline_data(struct mlx4_ib_qp *qp, struct ib_send_wr *wr, @@ -3252,7 +3252,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, } ctrl->owner_opcode = mlx4_ib_opcode[wr->opcode] | - (ind & qp->sq.wqe_cnt ? cpu_to_be32(1 << 31) : 0) | blh; + (ind & qp->sq.wqe_cnt ? cpu_to_be32(1U << 31) : 0) | blh; stamp = ind + qp->sq_spare_wqes; ind += DIV_ROUND_UP(size * 16, 1U << qp->sq.wqe_shift); diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c index d4c8105..6274a1c 100644 --- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c +++ b/sys/ofed/drivers/infiniband/hw/mthca/mthca_mcg.c @@ -173,13 +173,13 @@ int mthca_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) } for (i = 0; i < MTHCA_QP_PER_MGM; ++i) - if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31))) { + if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1U << 31))) { mthca_dbg(dev, "QP %06x already a member of MGM\n", ibqp->qp_num); err = 0; goto out; - } else if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) { - mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1 << 31)); + } else if (!(mgm->qp[i] & cpu_to_be32(1U << 31))) { + mgm->qp[i] = cpu_to_be32(ibqp->qp_num | (1U << 31)); break; } @@ -260,9 +260,9 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) } for (loc = -1, i = 0; i < MTHCA_QP_PER_MGM; ++i) { - if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1 << 31))) + if (mgm->qp[i] == cpu_to_be32(ibqp->qp_num | (1U << 31))) loc = i; - if (!(mgm->qp[i] & cpu_to_be32(1 << 31))) + if (!(mgm->qp[i] & cpu_to_be32(1U << 31))) break; } diff --git a/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c b/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c index 4a4d133..2264bcd 100644 --- a/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/sys/ofed/drivers/infiniband/hw/mthca/mthca_qp.c @@ -1756,7 +1756,7 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, /* Add one more inline data segment for ICRC */ if (qp->transport == MLX) { ((struct mthca_data_seg *) wqe)->byte_count = - cpu_to_be32((1 << 31) | 4); + cpu_to_be32((1U << 31) | 4); ((u32 *) wqe)[1] = 0; wqe += sizeof (struct mthca_data_seg); size += sizeof (struct mthca_data_seg) / 16; @@ -2097,7 +2097,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, /* Add one more inline data segment for ICRC */ if (qp->transport == MLX) { ((struct mthca_data_seg *) wqe)->byte_count = - cpu_to_be32((1 << 31) | 4); + cpu_to_be32((1U << 31) | 4); ((u32 *) wqe)[1] = 0; wqe += sizeof (struct mthca_data_seg); size += sizeof (struct mthca_data_seg) / 16; diff --git a/sys/ofed/drivers/net/mlx4/mcg.c b/sys/ofed/drivers/net/mlx4/mcg.c index 625e5e4..dfe5308 100644 --- a/sys/ofed/drivers/net/mlx4/mcg.c +++ b/sys/ofed/drivers/net/mlx4/mcg.c @@ -1148,7 +1148,7 @@ static int mlx4_QP_ATTACH(struct mlx4_dev *dev, struct mlx4_qp *qp, qpn = qp->qpn; qpn |= (prot << 28); if (attach && block_loopback) - qpn |= (1 << 31); + qpn |= (1U << 31); err = mlx4_cmd(dev, mailbox->dma, qpn, attach, MLX4_CMD_QP_ATTACH, MLX4_CMD_TIME_CLASS_A, |