Skip to contentSkip to conversation

nodemask: Drop duplicate check in for_each_node_mask()

PATCH Applied Gavin Shan 3 participants 3 messages Jan 24, 2023 – Mar 2, 2023 Bitmap API

lore
Share & tools
lore

Gavin Shan

author
#0 lore raw

PATCH 1/1 nodemask: Drop duplicate check in for_each_node_mask()

The return value type is changed from 'int' to 'unsigned int' since commit 0dfe54071d7c8 ("nodemask: Fix return values to be unsigned"). Besides, the conversion between 'int' and 'unsigned int' on the parameter @node is guaranteed to be safe due to the limited range of MAX_NUMNODES and CONFIG_NODES_SHIFT. By the way, '(node >= 0)' should have been '(node) >= 0' actually.

It's unnecessary to check if their return values are greater or equal to 0 in for_each_node_mask(). Remove it.

No functional change intended.

---
 include/linux/nodemask.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/nodemask.h +1 -1
index bb0ee80526b2..8d07116caaf1 100644
@@ -385,7 +385,7 @@ static inline void __nodes_fold(nodemask_t *dstp, const nodemask_t *origp,
 #if MAX_NUMNODES > 1
 #define for_each_node_mask(node, mask)				    \
 	for ((node) = first_node(mask);				    \
-	     (node >= 0) && (node) < MAX_NUMNODES;		    \
+	     (node) < MAX_NUMNODES;				    \
 	     (node) = next_node((node), (mask)))
 #else /* MAX_NUMNODES == 1 */
 #define for_each_node_mask(node, mask)                                  \
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Gavin Shan

The return value type is changed from 'int' to 'unsigned int' since commit 0dfe54071d7c8 ("nodemask: Fix return values to be unsigned"). Besides, the conversion between 'int' and 'unsigned int' on the parameter @node is guaranteed to be safe due to the limited range of MAX_NUMNODES and CONFIG_NODES_SHIFT. By the way, '(node >= 0)' should have been '(node) >= 0' actually.

It's unnecessary to check if their return values are greater or equal to 0 in for_each_node_mask(). Remove it.

No functional change intended.

Agree on the arguments.

Quoted 21 lines
---
 include/linux/nodemask.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/nodemask.h +1 -1
index bb0ee80526b2..8d07116caaf1 100644
@@ -385,7 +385,7 @@ static inline void __nodes_fold(nodemask_t *dstp, const nodemask_t *origp,
 #if MAX_NUMNODES > 1
 #define for_each_node_mask(node, mask)				    \
 	for ((node) = first_node(mask);				    \
-	     (node >= 0) && (node) < MAX_NUMNODES;		    \
+	     (node) < MAX_NUMNODES;				    \
 	     (node) = next_node((node), (mask)))
 #else /* MAX_NUMNODES == 1 */
 #define for_each_node_mask(node, mask)                                  \
Signature · 1 line
2.23.0
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#2 lore raw
In reply to Gavin Shan
Quoted 7 lines · Gavin Shan

The return value type is changed from 'int' to 'unsigned int' since commit 0dfe54071d7c8 ("nodemask: Fix return values to be unsigned"). Besides, the conversion between 'int' and 'unsigned int' on the parameter @node is guaranteed to be safe due to the limited range of MAX_NUMNODES and CONFIG_NODES_SHIFT. By the way, '(node >= 0)' should have been '(node) >= 0' actually.

Quoted 6 lines

It's unnecessary to check if their return values are greater or equal to 0 in for_each_node_mask(). Remove it.

No functional change intended.

Applied, thanks.