From: Jason Gunthorpe <jgg@nvidia.com>
To: hhh ching <chenglang7@gmail.com>
Cc: Weihang Li <liweihang@huawei.com>,
dledford@redhat.com, leon@kernel.org, linux-rdma@vger.kernel.org,
linuxarm@huawei.com
Subject: Re: [PATCH v4 for-next 1/8] RDMA/hns: Fix sparse warnings about hr_reg_write()
Date: Fri, 18 Jun 2021 13:10:38 -0300 [thread overview]
Message-ID: <20210618161038.GH1002214@nvidia.com> (raw)
In-Reply-To: <CAEc5TmJTfaSqPgk7CWgD1R9Oqddkg7XEJSHJF0A=8EFJtXcYLQ@mail.gmail.com>
On Fri, Jun 18, 2021 at 11:22:46PM +0800, hhh ching wrote:
> Jason Gunthorpe <jgg@nvidia.com> 于2021年6月18日周五 下午8:49写道:
> >
> > On Fri, Jun 18, 2021 at 06:05:58PM +0800, Weihang Li wrote:
> > > Fix complains from sparse about "dubious: x & !y" when calling
> > > hr_reg_write(ctx, field, !!val) by using "val ? 1 : 0" instead of "!!val".
> > >
> > > Fixes: dc504774408b ("RDMA/hns: Use new interface to set MPT related fields")
> > > Fixes: 495c24808ce7 ("RDMA/hns: Add XRC subtype in QPC and XRC type in SRQC")
> > > Fixes: 782832f25404 ("RDMA/hns: Simplify the function config_eqc()")
> > > Signed-off-by: Weihang Li <liweihang@huawei.com>
> > > drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 14 +++++++-------
> > > 1 file changed, 7 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> > > index fbc45b9..6452ccc 100644
> > > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
> > > @@ -3013,15 +3013,15 @@ static int hns_roce_v2_write_mtpt(struct hns_roce_dev *hr_dev,
> > > hr_reg_enable(mpt_entry, MPT_L_INV_EN);
> > >
> > > hr_reg_write(mpt_entry, MPT_BIND_EN,
> > > - !!(mr->access & IB_ACCESS_MW_BIND));
> > > + mr->access & IB_ACCESS_MW_BIND ? 1 : 0);
> >
> > Err, I'm still confused where the sparse warning is coming from
>
> Hi, Jason, i found some code in sparse/evaluate.c:
> const unsigned left_not = expr->left->type == EXPR_PREOP &&
> expr->left->op == '!';
> const unsigned right_not = expr->right->type == EXPR_PREOP &&
> expr->right->op == '!';
> if ((op == '&' || op == '|') && (left_not || right_not))
> warning(expr->pos, "dubious: %sx %c %sy",
>
> I guess the "dubious" is, if somebody use "&" or "|", maybe he want
> to bitwise operate a number instead of a bool.
Oh I see, yes, that does many some sense actually
> > A hr_reg_write_bool() would be cleaner?
Which makes me further think this is the right direction
Jason
next prev parent reply other threads:[~2021-06-18 16:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-18 10:05 [PATCH v4 for-next 0/8] RDMA/hns: Use new interfaces to write/read fields Weihang Li
2021-06-18 10:05 ` [PATCH v4 for-next 1/8] RDMA/hns: Fix sparse warnings about hr_reg_write() Weihang Li
2021-06-18 12:01 ` Jason Gunthorpe
2021-06-18 15:22 ` hhh ching
2021-06-18 16:10 ` Jason Gunthorpe [this message]
2021-06-19 8:37 ` liweihang
2021-06-18 10:05 ` [PATCH v4 for-next 2/8] RDMA/hns: Add a check to ensure integer mtu is positive Weihang Li
2021-06-18 10:06 ` [PATCH v4 for-next 3/8] RDMA/hns: Use new interface to write CQ context Weihang Li
2021-06-18 10:06 ` [PATCH v4 for-next 4/8] RDMA/hns: Use new interface to modify QP context Weihang Li
2021-06-18 10:06 ` [PATCH v4 for-next 5/8] RDMA/hns: Use new interface to get CQE fields Weihang Li
2021-06-18 10:06 ` [PATCH v4 for-next 6/8] RDMA/hns: Use new interface to write FRMR fields Weihang Li
2021-06-18 10:06 ` [PATCH v4 for-next 7/8] RDMA/hns: Use new interface to write DB related fields Weihang Li
2021-06-18 10:06 ` [PATCH v4 for-next 8/8] RDMA/hns: Clean SRQC structure definition Weihang Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210618161038.GH1002214@nvidia.com \
--to=jgg@nvidia.com \
--cc=chenglang7@gmail.com \
--cc=dledford@redhat.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liweihang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox