lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201119195816.GA131726@silpixa00400314>
Date:   Thu, 19 Nov 2020 19:58:16 +0000
From:   Giovanni Cabiddu <giovanni.cabiddu@...el.com>
To:     Julia Lawall <julia.lawall@...ia.fr>
Cc:     Herbert Xu <herbert@...dor.apana.org.au>,
        Wojciech Ziemba <wojciech.ziemba@...el.com>,
        qat-linux@...el.com, Denis Efremov <efremov@...ux.com>,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
        kbuild-all@...ts.01.org
Subject: Re: [PATCH] crypto: qat - fix excluded_middle.cocci warnings

On Fri, Nov 13, 2020 at 06:14:00PM +0100, Julia Lawall wrote:
> From: kernel test robot <lkp@...el.com>
> 
>  Condition !A || A && B is equivalent to !A || B.
A similar change was submitted and discussed some time ago:
https://patchwork.kernel.org/project/linux-crypto/patch/78b1532c-f8bf-48e4-d0a7-30ea0137d408@huawei.com/

The change simplifies the logic but makes the code less readable.
I added a comment to clarify it.

Regards,

-- 
Giovanni

----8<----
From: kernel test robot <lkp@...el.com>
Date: Fri, 13 Nov 2020 18:14:00 +0100
Subject: [PATCH] crypto: qat - fix excluded_middle.cocci warnings

 Condition !A || A && B is equivalent to !A || B.

Generated by: scripts/coccinelle/misc/excluded_middle.cocci

Fixes: b76f0ea01312 ("coccinelle: misc: add excluded_middle.cocci script")
CC: Denis Efremov <efremov@...ux.com>
Reported-by: kernel test robot <lkp@...el.com>
Signed-off-by: kernel test robot <lkp@...el.com>
Signed-off-by: Julia Lawall <julia.lawall@...ia.fr>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@...el.com>
---
 drivers/crypto/qat/qat_common/adf_dev_mgr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_dev_mgr.c b/drivers/crypto/qat/qat_common/adf_dev_mgr.c
index 29dc2e3d38ff..4c752eed10fe 100644
--- a/drivers/crypto/qat/qat_common/adf_dev_mgr.c
+++ b/drivers/crypto/qat/qat_common/adf_dev_mgr.c
@@ -151,8 +151,8 @@ int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev,
 	mutex_lock(&table_lock);
 	atomic_set(&accel_dev->ref_count, 0);
 
-	/* PF on host or VF on guest */
-	if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) {
+	/* PF on host or VF on guest - optimized to remove redundant is_vf */
+	if (!accel_dev->is_vf || !pf) {
 		struct vf_id_map *map;
 
 		list_for_each(itr, &accel_table) {
@@ -248,7 +248,8 @@ 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)) {
+	/* PF on host or VF on guest - optimized to remove redundant is_vf */
+	if (!accel_dev->is_vf || !pf) {
 		id_map[accel_dev->accel_id] = 0;
 		num_devices--;
 	} else if (accel_dev->is_vf && pf) {
-- 
2.28.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ