Skip to contentSkip to conversation

powerpc/pseries/hotplug-memory.c: Change rc variable to bool

PATCH In review Leonardo Bras 3 participants 5 messages Aug 2, 2019 – Nov 14, 2019 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 powerpc/pseries/hotplug-memory.c: Change rc variable to bool

Changes the return variable to bool (as the return value) and avoids doing a ternary operation before returning.

---
Changes in v2:
- Restore previous and-ing logic on rc.

 arch/powerpc/platforms/pseries/hotplug-memory.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/pseries/hotplug-memory.c +3 -3
index 8e700390f3d6..c126b94d1943 100644
@@ -338,7 +338,7 @@ static int pseries_remove_mem_node(struct device_node *np)
 static bool lmb_is_removable(struct drmem_lmb *lmb)
 {
 	int i, scns_per_block;
-	int rc = 1;
+	bool rc = true;
 	unsigned long pfn, block_sz;
 	u64 phys_addr;
 
@@ -363,11 +363,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb)
 		if (!pfn_present(pfn))
 			continue;
 
-		rc &= is_mem_section_removable(pfn, PAGES_PER_SECTION);
+		rc = rc && is_mem_section_removable(pfn, PAGES_PER_SECTION);
 		phys_addr += MIN_MEMORY_BLOCK_SIZE;
 	}
 
-	return rc ? true : false;
+	return rc;
 }
 
 static int dlpar_add_lmb(struct drmem_lmb *);
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 29 lines · Leonardo Bras

Changes the return variable to bool (as the return value) and avoids doing a ternary operation before returning.

---
Changes in v2:
- Restore previous and-ing logic on rc.

 arch/powerpc/platforms/pseries/hotplug-memory.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/pseries/hotplug-memory.c +1 -1
index 8e700390f3d6..c126b94d1943 100644
@@ -338,7 +338,7 @@ static int pseries_remove_mem_node(struct device_node *np)
 static bool lmb_is_removable(struct drmem_lmb *lmb)
 {
 	int i, scns_per_block;
-	int rc = 1;
+	bool rc = true;
 	unsigned long pfn, block_sz;
 	u64 phys_addr;
 
@@ -363,11 +363,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb)
 		if (!pfn_present(pfn))
 			continue;
 

arch/powerpc/platforms/pseries/hotplug-memory.c static bool lmb_is_removable(struct drmem_lmb *lmb) · line 373

Quoted 10 lines
arch/powerpc/platforms/pseries/hotplug-memory.c +2 -2
-		rc &= is_mem_section_removable(pfn, PAGES_PER_SECTION);
+		rc = rc && is_mem_section_removable(pfn, PAGES_PER_SECTION);
 		phys_addr += MIN_MEMORY_BLOCK_SIZE;
 	}
 
-	return rc ? true : false;
+	return rc;
 }
 
 static int dlpar_add_lmb(struct drmem_lmb *);

Yeah, why not

Signature · 3 lines
Thanks,

David / dhildenb
#2 lore raw

Hello Michael,

Any feedback on this patch?

Best regards,

Quoted 45 lines · David Hildenbrand
Quoted 29 lines · Leonardo Bras

Changes the return variable to bool (as the return value) and avoids doing a ternary operation before returning.

---
Changes in v2:
- Restore previous and-ing logic on rc.

 arch/powerpc/platforms/pseries/hotplug-memory.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/pseries/hotplug-memory.c +1 -1
index 8e700390f3d6..c126b94d1943 100644
@@ -338,7 +338,7 @@ static int pseries_remove_mem_node(struct device_node *np)
 static bool lmb_is_removable(struct drmem_lmb *lmb)
 {
 	int i, scns_per_block;
-	int rc = 1;
+	bool rc = true;
 	unsigned long pfn, block_sz;
 	u64 phys_addr;
 
@@ -363,11 +363,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb)
 		if (!pfn_present(pfn))
 			continue;
 

arch/powerpc/platforms/pseries/hotplug-memory.c static bool lmb_is_removable(struct drmem_lmb *lmb) · line 373

Quoted 10 lines
arch/powerpc/platforms/pseries/hotplug-memory.c +2 -2
-		rc &= is_mem_section_removable(pfn, PAGES_PER_SECTION);
+		rc = rc && is_mem_section_removable(pfn, PAGES_PER_SECTION);
 		phys_addr += MIN_MEMORY_BLOCK_SIZE;
 	}
 
-	return rc ? true : false;
+	return rc;
 }
 
 static int dlpar_add_lmb(struct drmem_lmb *);

Yeah, why not