Message ID | 20211119140208.40416-6-liangwenpeng@huawei.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Jason Gunthorpe |
Headers | show |
Series | RDMA/hns: Cleanup for clearing static warnings | expand |
On Fri, Nov 19, 2021 at 10:02:04PM +0800, Wenpeng Liang wrote: > From: Haoyue Xu <xuhaoyue1@hisilicon.com> > > The "ret" should be initialized when it is defined instead of in the loop. Why? It is a bit weird, but the code is fine as written The only suggestion I'd make is if (hns_roce_cmq_csq_done(hr_dev)) { ret = 0; for (i = 0; i < num; i++) { Just because the , operator is not so typically used like that Jason
On 2021/11/20 1:27, Jason Gunthorpe wrote: > On Fri, Nov 19, 2021 at 10:02:04PM +0800, Wenpeng Liang wrote: >> From: Haoyue Xu <xuhaoyue1@hisilicon.com> >> >> The "ret" should be initialized when it is defined instead of in the loop. > > Why? > > It is a bit weird, but the code is fine as written > > The only suggestion I'd make is > > if (hns_roce_cmq_csq_done(hr_dev)) { > ret = 0; > for (i = 0; i < num; i++) { > > Just because the , operator is not so typically used like that > > Jason > . > Thanks for your suggestion, I will assign ret in the if branch in v2. Thanks, Wenpeng
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index ae4f6fa8ad71..556d79fb2352 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -1260,8 +1260,8 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev, struct hns_roce_v2_cmq_ring *csq = &priv->cmq.csq; u32 timeout = 0; u16 desc_ret; + int ret = 0; u32 tail; - int ret; int i; spin_lock_bh(&csq->lock); @@ -1284,7 +1284,7 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev, } while (++timeout < priv->cmq.tx_timeout); if (hns_roce_cmq_csq_done(hr_dev)) { - for (ret = 0, i = 0; i < num; i++) { + for (i = 0; i < num; i++) { /* check the result of hardware write back */ desc[i] = csq->desc[tail++]; if (tail == csq->desc_num)