Skip to contentSkip to conversation

lib/stackdepot : Remove logically dead code in stack_depot_init()

PATCH NAK Chelsy Ratnawat 2 participants 2 messages Oct 16 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/stackdepot : Remove logically dead code in stack_depot_init()

Since scale is always greater than PAGE_SHIFT, remove the unreachable else branch and simplify the conditional shift.

This issue was reported by Coverity scan.

---
 lib/stackdepot.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
lib/stackdepot.c +1 -5
index dd2717ff94bf..0393801ab1d9 100644
@@ -247,11 +247,7 @@ int stack_depot_init(void)
 
 		entries = nr_free_buffer_pages();
 		entries = roundup_pow_of_two(entries);
-
-		if (scale > PAGE_SHIFT)
-			entries >>= (scale - PAGE_SHIFT);
-		else
-			entries <<= (PAGE_SHIFT - scale);
+		entries >>= (scale - PAGE_SHIFT);
 	}
 
 	if (entries < 1UL << STACK_BUCKET_NUMBER_ORDER_MIN)
Signature · 1 line
2.53.0
#1 lore raw
Quoted 3 lines · Chelsy Ratnawat

Since scale is always greater than PAGE_SHIFT, remove the unreachable else branch and simplify the conditional shift.

Is it on all architectures?

Sashiko noticed this as well:
https://sashiko.dev/#/patchset/20261016062011.103059-1-chelsyratnawat2001%40gmail.com

NACK.

Quoted 27 lines

This issue was reported by Coverity scan.

---
 lib/stackdepot.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
lib/stackdepot.c +1 -6
index dd2717ff94bf..0393801ab1d9 100644
@@ -247,11 +247,7 @@ int stack_depot_init(void)
 
                entries = nr_free_buffer_pages();
                entries = roundup_pow_of_two(entries);
-
-               if (scale > PAGE_SHIFT)
-                       entries >>= (scale - PAGE_SHIFT);
-               else
-                       entries <<= (PAGE_SHIFT - scale);
+               entries >>= (scale - PAGE_SHIFT);
        }
 
        if (entries < 1UL << STACK_BUCKET_NUMBER_ORDER_MIN)
--

2.53.0