• L
    overflow: Fix -Wtype-limits compilation warnings · dc7fe518
    Leon Romanovsky 提交于
    Attempt to use check_shl_overflow() with inputs of unsigned type
    produces the following compilation warnings.
    
    drivers/infiniband/hw/mlx5/qp.c: In function _set_user_rq_size_:
    ./include/linux/overflow.h:230:6: warning: comparison of unsigned
    expression >= 0 is always true [-Wtype-limits]
       _s >= 0 && _s < 8 * sizeof(*d) ? _s : 0;  \
          ^~
    drivers/infiniband/hw/mlx5/qp.c:5820:6: note: in expansion of macro _check_shl_overflow_
      if (check_shl_overflow(rwq->wqe_count, rwq->wqe_shift,
    &rwq->buf_size))
          ^~~~~~~~~~~~~~~~~~
    ./include/linux/overflow.h:232:26: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
      (_to_shift != _s || *_d < 0 || _a < 0 ||   \
                              ^
    drivers/infiniband/hw/mlx5/qp.c:5820:6: note: in expansion of macro _check_shl_overflow_
      if (check_shl_overflow(rwq->wqe_count, rwq->wqe_shift, &rwq->buf_size))
          ^~~~~~~~~~~~~~~~~~
    ./include/linux/overflow.h:232:36: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
      (_to_shift != _s || *_d < 0 || _a < 0 ||   \
                                        ^
    drivers/infiniband/hw/mlx5/qp.c:5820:6: note: in expansion of macro _check_shl_overflow_
      if (check_shl_overflow(rwq->wqe_count, rwq->wqe_shift,&rwq->buf_size))
          ^~~~~~~~~~~~~~~~~~
    
    Fixes: 0c668477 ("overflow.h: Add arithmetic shift helper")
    Reviewed-by: NBart Van Assche <bvanassche@acm.org>
    Acked-by: NKees Cook <keescook@chromium.org>
    Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
    Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
    dc7fe518
overflow.h 9.5 KB