Skip to contentSkip to conversation

memblock: remove conditional return with no effect

PATCH In review Sang-Heon Jeon 3 participants 4 messages Aug 23 – Aug 27

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

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
index 43e036f3e11a..9a31781923fb 100644
@@ -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
maintainer
#1 lore raw
Quoted 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.

It's queued now and will appear in the memblock tree after the merge window.

Signature · 2 lines
Sincerely yours,
Mike.
maintainer Reviewed-by on v2 1/1
#2 lore raw
In reply to Sang-Heon Jeon
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 -4
 	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);

Your patch led Sashiko to suggest the addition of a round_up() in nearby code:

	https://sashiko.dev/#/patchset/[email protected]
#3 lore raw
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 -4
      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);
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