Re: [PATCH] lib/stackdepot : Remove logically dead code in stack_depot_init()
From: Marco Elver
Date: Fri Oct 16 2026 - 05:58:48 EST
On Fri, 16 Oct 2026 at 08:20, Chelsy Ratnawat
<chelsyratnawat2001@xxxxxxxxx> wrote:
>
> 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.
> This issue was reported by Coverity scan.
>
> Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@xxxxxxxxx>
> ---
> lib/stackdepot.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/lib/stackdepot.c b/lib/stackdepot.c
> index dd2717ff94bf..0393801ab1d9 100644
> --- a/lib/stackdepot.c
> +++ b/lib/stackdepot.c
> @@ -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
>