From: Yunfeng Ye <yeyunfeng@huawei.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Giovanni Cabiddu <giovanni.cabiddu@intel.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>, <qat-linux@intel.com>,
"open list:HARDWARE RANDOM NUMBER GENERATOR CORE"
<linux-crypto@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"hushiyuan@huawei.com" <hushiyuan@huawei.com>,
"linfeilong@huawei.com" <linfeilong@huawei.com>
Subject: Re: [PATCH] crypto: qat - remove redundant condition accel_dev->is_vf
Date: Fri, 25 Oct 2019 17:45:31 +0800 [thread overview]
Message-ID: <0b95f573-548b-4cec-e433-ef0ef16229cf@huawei.com> (raw)
In-Reply-To: <CAKv+Gu_MVe8mEeC-fVVbbLfUv-rEEk5_eoxfHjTCMgAFmSHrJw@mail.gmail.com>
On 2019/10/25 17:33, Ard Biesheuvel wrote:
> On Fri, 25 Oct 2019 at 09:24, Yunfeng Ye <yeyunfeng@huawei.com> wrote:
>>
>> Warning is found by the code analysis tool:
>> "Redundant condition: accel_dev->is_vf"
>>
>> So remove the redundant condition accel_dev->is_vf.
>>
>> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
>> ---
>> drivers/crypto/qat/qat_common/adf_dev_mgr.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/crypto/qat/qat_common/adf_dev_mgr.c b/drivers/crypto/qat/qat_common/adf_dev_mgr.c
>> index 2d06409bd3c4..b54b8850fe20 100644
>> --- a/drivers/crypto/qat/qat_common/adf_dev_mgr.c
>> +++ b/drivers/crypto/qat/qat_common/adf_dev_mgr.c
>> @@ -196,7 +196,7 @@ int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev,
>> atomic_set(&accel_dev->ref_count, 0);
>>
>> /* PF on host or VF on guest */
>> - if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) {
>> + if (!accel_dev->is_vf || !pf) {
>
> I disagree with this change. There is no bug here, and the way the
> condition is formulated self-documents the code, i.e.,
>
> IF NOT is_vf
> OR (is_vf BUT NOT pf)
>
> Using an automated tool to reduce every boolean expression to its
> minimal representation doesn't seem that useful to me, since the
> compiler is perfectly capable of doing that when generating the object
> code.
>
ok, thanks, this modify just fix warning, and make code simple.
>
>
>
>> struct vf_id_map *map;
>>
>> list_for_each(itr, &accel_table) {
>> @@ -292,7 +292,7 @@ void adf_devmgr_rm_dev(struct adf_accel_dev *accel_dev,
>> struct adf_accel_dev *pf)
>> {
>> mutex_lock(&table_lock);
>> - if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) {
>> + if (!accel_dev->is_vf || !pf) {
>> id_map[accel_dev->accel_id] = 0;
>> num_devices--;
>> } else if (accel_dev->is_vf && pf) {
>> --
>> 2.7.4
>>
>
> .
>
next prev parent reply other threads:[~2019-10-25 9:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-25 7:23 Yunfeng Ye
2019-10-25 9:33 ` Ard Biesheuvel
2019-10-25 9:45 ` Yunfeng Ye [this message]
[not found] ` <77832b26242f4987877d6122ba14a0d0@irsmsx101.ger.corp.intel.com>
2019-10-25 9:50 ` Giovanni Cabiddu
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=0b95f573-548b-4cec-e433-ef0ef16229cf@huawei.com \
--to=yeyunfeng@huawei.com \
--cc=ard.biesheuvel@linaro.org \
--cc=davem@davemloft.net \
--cc=giovanni.cabiddu@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=hushiyuan@huawei.com \
--cc=linfeilong@huawei.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qat-linux@intel.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
all inboxes | Powered by JetHome®