linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: qat - fix excluded_middle.cocci warnings
@ 2020-11-13 17:14 Julia Lawall
  2020-11-19 19:58 ` Giovanni Cabiddu
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2020-11-13 17:14 UTC (permalink / raw)
  To: Giovanni Cabiddu, Herbert Xu, Wojciech Ziemba
  Cc: qat-linux, Denis Efremov, linux-crypto, linux-kernel, kbuild-all

From: kernel test robot <lkp@intel.com>

 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@linux.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   585e5b17b92dead8a3aca4e3c9876fbca5f7e0ba
commit: b76f0ea013125358d1b4ca147a6f9b6883dd2493 coccinelle: misc: add excluded_middle.cocci script
:::::: branch date: 14 hours ago
:::::: commit date: 8 weeks ago

Please take the patch only if it's a positive warning. Thanks!

 adf_dev_mgr.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/crypto/qat/qat_common/adf_dev_mgr.c
+++ b/drivers/crypto/qat/qat_common/adf_dev_mgr.c
@@ -152,7 +152,7 @@ int adf_devmgr_add_dev(struct adf_accel_
 	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) {
 		struct vf_id_map *map;

 		list_for_each(itr, &accel_table) {
@@ -248,7 +248,7 @@ void adf_devmgr_rm_dev(struct adf_accel_
 		       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) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: qat - fix excluded_middle.cocci warnings
  2020-11-13 17:14 [PATCH] crypto: qat - fix excluded_middle.cocci warnings Julia Lawall
@ 2020-11-19 19:58 ` Giovanni Cabiddu
  2020-11-19 22:25   ` [PATCH RESEND] " Giovanni Cabiddu
  0 siblings, 1 reply; 4+ messages in thread
From: Giovanni Cabiddu @ 2020-11-19 19:58 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Herbert Xu, Wojciech Ziemba, qat-linux, Denis Efremov,
	linux-crypto, linux-kernel, kbuild-all

On Fri, Nov 13, 2020 at 06:14:00PM +0100, Julia Lawall wrote:
> From: kernel test robot <lkp@intel.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@intel.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@linux.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH RESEND] crypto: qat - fix excluded_middle.cocci warnings
  2020-11-19 19:58 ` Giovanni Cabiddu
@ 2020-11-19 22:25   ` Giovanni Cabiddu
  2020-11-27  6:26     ` Herbert Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Giovanni Cabiddu @ 2020-11-19 22:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Herbert Xu, Wojciech Ziemba, qat-linux, Denis Efremov,
	linux-crypto, linux-kernel, kbuild-all

On Thu, Nov 19, 2020 at 07:58:16PM +0000, Giovanni Cabiddu wrote:
> On Fri, Nov 13, 2020 at 06:14:00PM +0100, Julia Lawall wrote:
> > From: kernel test robot <lkp@intel.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.
Resending as it skipped linux-crypto patchwork.

----8<----

From: kernel test robot <lkp@intel.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@linux.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND] crypto: qat - fix excluded_middle.cocci warnings
  2020-11-19 22:25   ` [PATCH RESEND] " Giovanni Cabiddu
@ 2020-11-27  6:26     ` Herbert Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2020-11-27  6:26 UTC (permalink / raw)
  To: Giovanni Cabiddu
  Cc: Julia Lawall, Wojciech Ziemba, qat-linux, Denis Efremov,
	linux-crypto, linux-kernel, kbuild-all

On Thu, Nov 19, 2020 at 10:25:19PM +0000, Giovanni Cabiddu wrote:
>
>  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@linux.com>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
> Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> ---
>  drivers/crypto/qat/qat_common/adf_dev_mgr.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-27  6:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13 17:14 [PATCH] crypto: qat - fix excluded_middle.cocci warnings Julia Lawall
2020-11-19 19:58 ` Giovanni Cabiddu
2020-11-19 22:25   ` [PATCH RESEND] " Giovanni Cabiddu
2020-11-27  6:26     ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).