From: liweihang <liweihang@huawei.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: "dledford@redhat.com" <dledford@redhat.com>,
"leon@kernel.org" <leon@kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Linuxarm <linuxarm@huawei.com>, chenglang <chenglang@huawei.com>
Subject: Re: [PATCH v3 for-next 1/8] RDMA/hns: Use temporary variables to fix warning about hr_reg_write()
Date: Fri, 18 Jun 2021 09:17:41 +0000 [thread overview]
Message-ID: <f3ff5a5b41af4fddb7072d550f95d196@huawei.com> (raw)
In-Reply-To: 20210617224142.GU1002214@nvidia.com
On 2021/6/18 6:41, Jason Gunthorpe wrote:
> On Thu, Jun 17, 2021 at 03:31:44PM +0800, Weihang Li wrote:
>> From: Lang Cheng <chenglang@huawei.com>
>>
>> Fix complains from sparse about "dubious: x & !y" when calling
>> hr_reg_write(ctx, field, !!val).
>
> Where is this from?
>
> I'm not convinced you should have the temporary here given how much
> magics are involved in this stuff that rely on builtin_constant_p
>
> Jason
>
The warning comes from:
#define __BF_FIELD_CHECK(_mask, _reg, _val, _pfx) \
...
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
_pfx "value too large for the field"); \
I will change 'hr_reg_write(ctx, field, !!val)' to 'hr_reg_write(ctx, field, val
? 1 : 0)'. The latter is not as succinct as the former, but can avoid the sparse
warning.
Thanks
Weihang
next prev parent reply other threads:[~2021-06-18 9:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-17 7:31 [PATCH v3 for-next 0/8] RDMA/hns: Use new interfaces to write/read fields Weihang Li
2021-06-17 7:31 ` [PATCH v3 for-next 1/8] RDMA/hns: Use temporary variables to fix warning about hr_reg_write() Weihang Li
2021-06-17 22:41 ` Jason Gunthorpe
2021-06-18 9:17 ` liweihang [this message]
2021-06-17 7:31 ` [PATCH v3 for-next 2/8] RDMA/hns: Add a check to ensure integer mtu is positive Weihang Li
2021-06-17 7:31 ` [PATCH v3 for-next 3/8] RDMA/hns: Use new interface to write CQ context Weihang Li
2021-06-17 7:31 ` [PATCH v3 for-next 4/8] RDMA/hns: Use new interface to modify QP context Weihang Li
2021-06-17 7:31 ` [PATCH v3 for-next 5/8] RDMA/hns: Use new interface to get CQE fields Weihang Li
2021-06-17 7:31 ` [PATCH v3 for-next 6/8] RDMA/hns: Use new interface to write FRMR fields Weihang Li
2021-06-17 7:31 ` [PATCH v3 for-next 7/8] RDMA/hns: Use new interface to write DB related fields Weihang Li
2021-06-17 7:31 ` [PATCH v3 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=f3ff5a5b41af4fddb7072d550f95d196@huawei.com \
--to=liweihang@huawei.com \
--cc=chenglang@huawei.com \
--cc=dledford@redhat.com \
--cc=jgg@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linuxarm@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.