Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1648320 > unrolled thread

[PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2017-05-23 20:20 +0200
Last post2017-05-24 21:50 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] MIPS: Octeon: Delete an error message for a failed memory  allocation in octeon_irq_init_gpio() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-23 20:20 +0200
    Re: [PATCH] MIPS: Octeon: Delete an error message for a failed  memory allocation in octeon_irq_init_gpio() Joe Perches <joe@perches.com> - 2017-05-23 21:00 +0200
      Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory  allocation in octeon_irq_init_gpio() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-24 18:10 +0200
        Re: [PATCH] MIPS: Octeon: Delete an error message for a failed  memory allocation in octeon_irq_init_gpio() Joe Perches <joe@perches.com> - 2017-05-24 21:50 +0200

#1648320 — [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-23 20:20 +0200
Subject[PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
Message-ID<tKmzw-6Qv-17@gated-at.bofh.it>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 23 May 2017 20:00:06 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/mips/cavium-octeon/octeon-irq.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index c1eb1ff7c800..050c08ece5b6 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -1615,7 +1615,6 @@ static int __init octeon_irq_init_gpio(
 		irq_domain_add_linear(
 			gpio_node, 16, &octeon_irq_domain_gpio_ops, gpiod);
 	} else {
-		pr_warn("Cannot allocate memory for GPIO irq_domain.\n");
 		return -ENOMEM;
 	}
 
-- 
2.13.0

[toc] | [next] | [standalone]


#1648342 — Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()

FromJoe Perches <joe@perches.com>
Date2017-05-23 21:00 +0200
SubjectRe: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
Message-ID<tKncd-77q-1@gated-at.bofh.it>
In reply to#1648320
On Tue, 2017-05-23 at 20:10 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 23 May 2017 20:00:06 +0200
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/mips/cavium-octeon/octeon-irq.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
> index c1eb1ff7c800..050c08ece5b6 100644
> --- a/arch/mips/cavium-octeon/octeon-irq.c
> +++ b/arch/mips/cavium-octeon/octeon-irq.c
> @@ -1615,7 +1615,6 @@ static int __init octeon_irq_init_gpio(
>  		irq_domain_add_linear(
>  			gpio_node, 16, &octeon_irq_domain_gpio_ops, gpiod);
>  	} else {
> -		pr_warn("Cannot allocate memory for GPIO irq_domain.\n");
>  		return -ENOMEM;
>  	}

You really should reverse the test here and
unindent the first block.

Again:  Don't be mindless.
        Take the time to improve the code.
---
diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octe
index c1eb1ff7c800..2bdc750f2f2d 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -1609,15 +1609,13 @@ static int __init octeon_irq_init_gpio(
 	}
 
 	gpiod = kzalloc(sizeof(*gpiod), GFP_KERNEL);
-	if (gpiod) {
-		/* gpio domain host_data is the base hwirq number. */
-		gpiod->base_hwirq = base_hwirq;
-		irq_domain_add_linear(
-			gpio_node, 16, &octeon_irq_domain_gpio_ops, gpiod);
-	} else {
-		pr_warn("Cannot allocate memory for GPIO irq_domain.\n");
+	if (!gpiod)
 		return -ENOMEM;
-	}
+
+	/* gpio domain host_data is the base hwirq number. */
+	gpiod->base_hwirq = base_hwirq;
+	irq_domain_add_linear(gpio_node, 16,
+			      &octeon_irq_domain_gpio_ops, gpiod);
 
 	/*
 	 * Clear the OF_POPULATED flag that was set by of_irq_init()

[toc] | [prev] | [next] | [standalone]


#1649735

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2017-05-24 18:10 +0200
Message-ID<tKH1f-4vB-13@gated-at.bofh.it>
In reply to#1648342
>> +++ b/arch/mips/cavium-octeon/octeon-irq.c
>> @@ -1615,7 +1615,6 @@ static int __init octeon_irq_init_gpio(
>>  		irq_domain_add_linear(
>>  			gpio_node, 16, &octeon_irq_domain_gpio_ops, gpiod);
>>  	} else {
>> -		pr_warn("Cannot allocate memory for GPIO irq_domain.\n");
>>  		return -ENOMEM;
>>  	}
> 
> You really should reverse the test here and
> unindent the first block.

Thanks for your improved source code transformation.

I am curious if I will stumble on a similar change possibility once more
for remaining update candidates in other software areas.

Regards,
Markus

[toc] | [prev] | [next] | [standalone]


#1649893 — Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()

FromJoe Perches <joe@perches.com>
Date2017-05-24 21:50 +0200
SubjectRe: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
Message-ID<tKKs9-6vf-1@gated-at.bofh.it>
In reply to#1649735
On Wed, 2017-05-24 at 18:01 +0200, SF Markus Elfring wrote:
> I am curious if I will stumble on a similar change possibility once more
> for remaining update candidates in other software areas.

Only if you keep your eyes open to the possibilities.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web