RDMA/siw: Use max() instead of doing it manually
authorJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Thu, 2 Dec 2021 10:07:59 +0000 (18:07 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Mon, 6 Dec 2021 23:49:19 +0000 (19:49 -0400)
Fix following coccicheck warning:

./drivers/infiniband/sw/siw/siw_verbs.c:665:28-29: WARNING opportunity for max().

Link: https://lore.kernel.org/r/1638439679-114250-1-git-send-email-jiapeng.chong@linux.alibaba.com
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reviewed-by: Bernard Metzler <bmt@zurich.ibm.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/sw/siw/siw_verbs.c

index d15a1f9c59f03a390bbef7ca0c6b77df7ddba579..a3dd2cb6d5c989cc3297b47997deecff27ff92ca 100644 (file)
@@ -662,7 +662,7 @@ static int siw_copy_inline_sgl(const struct ib_send_wr *core_wr,
                kbuf += core_sge->length;
                core_sge++;
        }
-       sqe->sge[0].length = bytes > 0 ? bytes : 0;
+       sqe->sge[0].length = max(bytes, 0);
        sqe->num_sge = bytes > 0 ? 1 : 0;
 
        return bytes;