diff mbox series

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

Message ID 20190802133914.30413-1-leonardo@linux.ibm.com (mailing list archive)
State Accepted, archived
Commit b948aaaf3e39cc475e45fea727638f191a5cb1b4
Headers show
Series [v2,1/1] powerpc/pseries/hotplug-memory.c: Change rc variable to bool | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (f3365d1a959d5c6527efe3d38276acc9b58e3f3f)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked

Commit Message

Leonardo Bras Aug. 2, 2019, 1:39 p.m. UTC
Changes the return variable to bool (as the return value) and
avoids doing a ternary operation before returning.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
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(-)

Comments

David Hildenbrand Aug. 2, 2019, 1:45 p.m. UTC | #1
On 02.08.19 15:39, Leonardo Bras wrote:
> Changes the return variable to bool (as the return value) and
> avoids doing a ternary operation before returning.
> 
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> ---
> 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(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
> index 8e700390f3d6..c126b94d1943 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> @@ -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 *);
> 

Yeah, why not

Reviewed-by: David Hildenbrand <david@redhat.com>
Leonardo Bras Sept. 20, 2019, 1:57 a.m. UTC | #2
Hello Michael,

Any feedback on this patch?

Best regards,


On Fri, 2019-08-02 at 15:45 +0200, David Hildenbrand wrote:
> On 02.08.19 15:39, Leonardo Bras wrote:
> > Changes the return variable to bool (as the return value) and
> > avoids doing a ternary operation before returning.
> > 
> > Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> > ---
> > 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(-)
> > 
> > diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
> > index 8e700390f3d6..c126b94d1943 100644
> > --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> > +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> > @@ -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 *);
> > 
> 
> Yeah, why not
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>
>
Michael Ellerman Nov. 14, 2019, 9:07 a.m. UTC | #3
On Fri, 2019-08-02 at 13:39:15 UTC, Leonardo Bras wrote:
> Changes the return variable to bool (as the return value) and
> avoids doing a ternary operation before returning.
> 
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b948aaaf3e39cc475e45fea727638f191a5cb1b4

cheers
Leonardo Bras Nov. 14, 2019, 6:25 p.m. UTC | #4
On Thu, 2019-11-14 at 20:07 +1100, Michael Ellerman wrote:
> On Fri, 2019-08-02 at 13:39:15 UTC, Leonardo Bras wrote:
> > Changes the return variable to bool (as the return value) and
> > avoids doing a ternary operation before returning.
> > 
> > Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> 
> Series applied to powerpc next, thanks.
> 
> https://git.kernel.org/powerpc/c/b948aaaf3e39cc475e45fea727638f191a5cb1b4
> 
> cheers

Thanks!
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 8e700390f3d6..c126b94d1943 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -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 *);