Skip to contentSkip to conversation

memblock: Return NUMA_NO_NODE instead of -1 to improve code readability

PATCH Applied Yuntao Wang 2 participants 2 messages Dec 7, 2023 – Dec 8, 2023

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

PATCH 1/1 memblock: Return NUMA_NO_NODE instead of -1 to improve code readability

When no corresponding memory region is found for the given pfn, return NUMA_NO_NODE instead of -1. This improves code readability and aligns with the existing logic of the memblock_search_pfn_nid() function's user.

---
 mm/memblock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memblock.c +1 -1
index 5a88d6d24d79..c1f579c23396 100644
@@ -1851,7 +1851,7 @@ int __init_memblock memblock_search_pfn_nid(unsigned long pfn,
 	int mid = memblock_search(type, PFN_PHYS(pfn));
 
 	if (mid == -1)
-		return -1;
+		return NUMA_NO_NODE;
 
 	*start_pfn = PFN_DOWN(type->regions[mid].base);
 	*end_pfn = PFN_DOWN(type->regions[mid].base + type->regions[mid].size);
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Yuntao Wang

When no corresponding memory region is found for the given pfn, return NUMA_NO_NODE instead of -1. This improves code readability and aligns with the existing logic of the memblock_search_pfn_nid() function's user.

Applied, thanks!

Quoted 20 lines
---
 mm/memblock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memblock.c +1 -1
index 5a88d6d24d79..c1f579c23396 100644
@@ -1851,7 +1851,7 @@ int __init_memblock memblock_search_pfn_nid(unsigned long pfn,
 	int mid = memblock_search(type, PFN_PHYS(pfn));
 
 	if (mid == -1)
-		return -1;
+		return NUMA_NO_NODE;
 
 	*start_pfn = PFN_DOWN(type->regions[mid].base);
 	*end_pfn = PFN_DOWN(type->regions[mid].base + type->regions[mid].size);
Signature · 1 line
2.43.0
Signature · 2 lines
Sincerely yours,
Mike.