Skip to contentSkip to conversation

mm/hugetlb: Simplify the calculation of variables

PATCH Applied Jiapeng Zhong 3 participants 3 messages Jan 26, 2021 – Jan 27, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/hugetlb: Simplify the calculation of variables

Fix the following coccicheck warnings:

./mm/hugetlb.c:3372:20-22: WARNING !A || A && B is equivalent to !A || B.

---
 mm/hugetlb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/hugetlb.c +1 -2
index cbf32d2..5e6a6e7 100644
@@ -3367,8 +3367,7 @@ static unsigned int allowed_mems_nr(struct hstate *h)
 	mpol_allowed = policy_nodemask_current(gfp_mask);
 
 	for_each_node_mask(node, cpuset_current_mems_allowed) {
-		if (!mpol_allowed ||
-		    (mpol_allowed && node_isset(node, *mpol_allowed)))
+		if (!mpol_allowed || node_isset(node, *mpol_allowed))
 			nr += array[node];
 	}
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw

Hi:

Quoted 17 lines · Jiapeng Zhong

Fix the following coccicheck warnings:

./mm/hugetlb.c:3372:20-22: WARNING !A || A && B is equivalent to !A || B.

---
 mm/hugetlb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/hugetlb.c +0 -0
index cbf32d2..5e6a6e7 100644

mm/hugetlb.c static unsigned int allowed_mems_nr(struct hstate *h) · line 3373

Quoted 9 lines
mm/hugetlb.c +1 -2
@@ -3367,8 +3367,7 @@ static unsigned int allowed_mems_nr(struct hstate *h)
 	mpol_allowed = policy_nodemask_current(gfp_mask);
 
 	for_each_node_mask(node, cpuset_current_mems_allowed) {
-		if (!mpol_allowed ||
-		    (mpol_allowed && node_isset(node, *mpol_allowed)))
+		if (!mpol_allowed || node_isset(node, *mpol_allowed))
 			nr += array[node];
 	}
 

I'm gonna do this too. :)

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jiapeng Zhong
Quoted 10 lines · Jiapeng Zhong

Fix the following coccicheck warnings:

./mm/hugetlb.c:3372:20-22: WARNING !A || A && B is equivalent to !A || B.

---
 mm/hugetlb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Thanks,

Signature · 1 line
Mike Kravetz
Quoted 16 lines
mm/hugetlb.c +1 -2
index cbf32d2..5e6a6e7 100644
@@ -3367,8 +3367,7 @@ static unsigned int allowed_mems_nr(struct hstate *h)
 	mpol_allowed = policy_nodemask_current(gfp_mask);
 
 	for_each_node_mask(node, cpuset_current_mems_allowed) {
-		if (!mpol_allowed ||
-		    (mpol_allowed && node_isset(node, *mpol_allowed)))
+		if (!mpol_allowed || node_isset(node, *mpol_allowed))
 			nr += array[node];
 	}