RDMA/hns: Add a check to ensure integer mtu is positive
authorWeihang Li <liweihang@huawei.com>
Mon, 21 Jun 2021 08:00:36 +0000 (16:00 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 21 Jun 2021 18:03:41 +0000 (15:03 -0300)
commitfe331da0f210c60342b042a03fe53f1b564b412b
tree6ef1df6ea54760c1b04df44308b8706290c6cc5e
parent78c1da52704853bcc57399ca76b5b6e9e08ca627
RDMA/hns: Add a check to ensure integer mtu is positive

GCC may reports an running time assert error when a value calculated from
ib_mtu_enum_to_int() is using as 'val' in FIELD_PREDP:

include/linux/compiler_types.h:328:38: error: call to
'__compiletime_assert_1524' declared with attribute error: FIELD_PREP:
value too large for the field

So a check is added about whether integer mtu from ib_mtu_enum_to_int() is
negative to avoid this warning.

Link: https://lore.kernel.org/r/1624262443-24528-3-git-send-email-liweihang@huawei.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/hns/hns_roce_hw_v2.c