Skip to contentSkip to conversation

mm/mm_init.c: Clean code. Use BUILD_BUG_ON when comparing compile time constant

PATCH Applied [email protected] 2 participants 2 messages Feb 28, 2020 – Mar 2, 2020

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

PATCH 1/1 mm/mm_init.c: Clean code. Use BUILD_BUG_ON when comparing compile time constant

From: Mateusz Nosek <[email protected]>

MAX_ZONELISTS is compile time constant,
so it should be compared using BUILD_BUG_ON not BUG_ON.

---
 mm/mm_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mm_init.c +1 -1
index 5c918388de99..7da6991d9435 100644
@@ -37,7 +37,7 @@ void __init mminit_verify_zonelist(void)
 		struct zonelist *zonelist;
 		int i, listid, zoneid;
 
-		BUG_ON(MAX_ZONELISTS > 2);
+		BUILD_BUG_ON(MAX_ZONELISTS > 2);
 		for (i = 0; i < MAX_ZONELISTS * MAX_NR_ZONES; i++) {
 
 			/* Identify the zone and nodelist */
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Fri, Feb 28, 2020 at 11:46:17PM +0100, [email protected] wrote:

From: Mateusz Nosek <[email protected]>

MAX_ZONELISTS is compile time constant,
so it should be compared using BUILD_BUG_ON not BUG_ON.

Sounds you are right.

Quoted 19 lines

---
mm/mm_init.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
mm/mm_init.c +1 -1
index 5c918388de99..7da6991d9435 100644
@@ -37,7 +37,7 @@ void __init mminit_verify_zonelist(void)
 		struct zonelist *zonelist;
 		int i, listid, zoneid;
 
-		BUG_ON(MAX_ZONELISTS > 2);
+		BUILD_BUG_ON(MAX_ZONELISTS > 2);
 		for (i = 0; i < MAX_ZONELISTS * MAX_NR_ZONES; i++) {
 
 			/* Identify the zone and nodelist */
Signature · 1 line
2.17.1
Signature · 2 lines
Wei Yang
Help you, Help me