[PATCH] firmware: edd: Remove redundant condition

Haowen Bai posted 1 patch 4 years, 3 months ago
There is a newer version of this series
drivers/firmware/edd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] firmware: edd: Remove redundant condition
Posted by Haowen Bai 4 years, 3 months ago
The logic !A || A && B is equivalent to !A || B. so we have
to make code clear.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 drivers/firmware/edd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 69353dd..5cc2389 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -685,8 +685,7 @@ static void edd_populate_dir(struct edd_device * edev)
 	int i;
 
 	for (i = 0; (attr = edd_attrs[i]) && !error; i++) {
-		if (!attr->test ||
-		    (attr->test && attr->test(edev)))
+		if (!attr->test || attr->test(edev))
 			error = sysfs_create_file(&edev->kobj,&attr->attr);
 	}
 
-- 
2.7.4
Re: [PATCH] firmware: edd: Remove redundant condition
Posted by Greg KH 4 years, 3 months ago
On Thu, Mar 17, 2022 at 06:05:20PM +0800, Haowen Bai wrote:
> The logic !A || A && B is equivalent to !A || B. so we have
> to make code clear.

But the logic here is:
	(!A || (A && B))
not:
	(!A || A && B)

as you write.

Is that the same?  I don't want to have to dig up my son's logic
textbook...

How did you test this?

thanks,

greg k-h