memblock: remove conditional return with no effect
PATCH v2 1/1 memblock: remove conditional return with no effect
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci.
---
The memblock patch of the treewide v1 series [1] is posted separately. You can find the Coccinelle script in v1 [1].
---
Changes from v1 [1]
- Change base to memblock/for-next
- Filter only memblock changes
[1] https://lore.kernel.org/all/[email protected]/
---
mm/memblock.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
mm/memblock.c +1 -6
@@ -2613,15 +2613,10 @@ static int __init prepare_kho_fdt(void)static int __init reserve_mem_init (void ) { -int err; -if (!kho_is_enabled () || !reserved_mem_count)return 0 ; - err =prepare_kho_fdt (); -if (err) -return err; -return err; +return prepare_kho_fdt (); }late_initcall (reserve_mem_init);
Signature · 1 line
2.43.0
Mike Rapoport
maintainerQuoted 7 lines · Sang-Heon Jeon
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from
scripts/coccinelle/misc/cond_return_no_effect.cocci.Signed-off-by Sang-Heon Jeon <[email protected]>
It's queued now and will appear in the memblock tree after the merge window.
Signature · 2 lines
Sincerely yours, Mike.
Quoted 16 lines · On Mon, 24 Aug 2026 00:48:38 +0900 Sang-Heon Jeon <[email protected]> wrote:
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from
scripts/coccinelle/misc/cond_return_no_effect.cocci....
mm/memblock.c +0
-2@@ -2613,15 +2613,10 @@ static int __init prepare_kho_fdt(void)static int __init reserve_mem_init (void ) { -int err; -
mm/memblock.c static int __init prepare_kho_fdt(void) · line 2621
Quoted 10 lines
mm/memblock.c +1
-4if (!kho_is_enabled () || !reserved_mem_count)return 0 ; - err =prepare_kho_fdt (); -if (err) -return err; -return err; +return prepare_kho_fdt (); }late_initcall (reserve_mem_init);
Your patch led Sashiko to suggest the addition of a round_up() in nearby code:
https://sashiko.dev/#/patchset/[email protected]
Quoted 32 lines · Andrew Morton
Quoted 16 lines · On Mon, 24 Aug 2026 00:48:38 +0900 Sang-Heon Jeon <[email protected]> wrote:
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly.
This is the result of running the Coccinelle script from
scripts/coccinelle/misc/cond_return_no_effect.cocci....
mm/memblock.c +0
-2@@ -2613,15 +2613,10 @@ static int __init prepare_kho_fdt(void)static int __init reserve_mem_init (void ) { -int err; -mm/memblock.c static int __init prepare_kho_fdt(void) · line 2621
Quoted 10 lines
mm/memblock.c +1
-4if (!kho_is_enabled () || !reserved_mem_count)return 0 ; - err =prepare_kho_fdt (); -if (err) -return err; -return err; +return prepare_kho_fdt (); }late_initcall (reserve_mem_init);Reviewed-by Andrew Morton <[email protected]>
Quoted 4 lines
Your patch led Sashiko to suggest the addition of a
round_up()in nearby code:https://sashiko.dev/#/patchset/[email protected]
Thanks for the notice, Andrew, and thanks for the review, Mike.
It seems like a valid concern. I'll send a fix patch and check reviews carefully.
Best regards,
Sang-Heon Jeon