* [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
@ 2017-05-23 18:10 SF Markus Elfring
2017-05-23 18:55 ` Joe Perches
0 siblings, 1 reply; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-23 18:10 UTC (permalink / raw)
To: linux-mips, Dan Carpenter, David Daney, Ralf Bächle, Steven J. Hill
Cc: LKML, kernel-janitors
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
2017-05-23 18:10 [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio() SF Markus Elfring
@ 2017-05-23 18:55 ` Joe Perches
2017-05-23 18:59 ` David Daney
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Joe Perches @ 2017-05-23 18:55 UTC (permalink / raw)
To: SF Markus Elfring, linux-mips, Dan Carpenter, David Daney,
Ralf Bächle, Steven J. Hill
Cc: LKML, kernel-janitors
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()
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
2017-05-23 18:55 ` Joe Perches
@ 2017-05-23 18:59 ` David Daney
2017-05-23 21:42 ` David Daney
2017-05-24 16:01 ` SF Markus Elfring
2 siblings, 0 replies; 7+ messages in thread
From: David Daney @ 2017-05-23 18:59 UTC (permalink / raw)
To: Joe Perches, SF Markus Elfring, linux-mips, Dan Carpenter,
David Daney, Ralf Bächle, Steven J. Hill
Cc: LKML, kernel-janitors
On 05/23/2017 11:55 AM, Joe Perches wrote:
> 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.
Quite right.
For Markus Elfring's version: NAK
For Joe's version:
Acked-by: David Daney <david.daney@cavium.com>
> ---
> 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()
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
2017-05-23 18:55 ` Joe Perches
2017-05-23 18:59 ` David Daney
@ 2017-05-23 21:42 ` David Daney
2017-05-24 16:01 ` SF Markus Elfring
2 siblings, 0 replies; 7+ messages in thread
From: David Daney @ 2017-05-23 21:42 UTC (permalink / raw)
To: Joe Perches, SF Markus Elfring, linux-mips, Dan Carpenter,
David Daney, Ralf Bächle, Steven J. Hill
Cc: LKML, kernel-janitors
Steven,
Take Joe Perches' patch, put a proper change log on it and test it.
Hopefully Joe will agree to a SoB and we will do that instead of the
Markus Elfring thing.
Thanks,
David
On 05/23/2017 11:55 AM, Joe Perches wrote:
> 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()
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
2017-05-23 18:55 ` Joe Perches
2017-05-23 18:59 ` David Daney
2017-05-23 21:42 ` David Daney
@ 2017-05-24 16:01 ` SF Markus Elfring
2017-05-24 19:43 ` Joe Perches
2 siblings, 1 reply; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-24 16:01 UTC (permalink / raw)
To: Joe Perches
Cc: linux-mips, Dan Carpenter, David Daney, Ralf Bächle,
Steven J. Hill, LKML, kernel-janitors
>> +++ 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
2017-05-24 16:01 ` SF Markus Elfring
@ 2017-05-24 19:43 ` Joe Perches
2017-05-29 19:38 ` Geert Uytterhoeven
0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2017-05-24 19:43 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-mips, Dan Carpenter, David Daney, Ralf Bächle,
Steven J. Hill, LKML, kernel-janitors
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
2017-05-24 19:43 ` Joe Perches
@ 2017-05-29 19:38 ` Geert Uytterhoeven
0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2017-05-29 19:38 UTC (permalink / raw)
To: Joe Perches
Cc: SF Markus Elfring, Linux MIPS Mailing List, Dan Carpenter,
David Daney, Ralf Bächle, Steven J. Hill, LKML,
kernel-janitors
On Wed, May 24, 2017 at 9:43 PM, Joe Perches <joe@perches.com> wrote:
> 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.
It's like a puzzle: how to fold the if/else trees and forests to achieve
the longest linear path and the smallest indentation ;-)
And... goto (to the end/cleanup phase!) is your friend...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-05-29 19:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 18:10 [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio() SF Markus Elfring
2017-05-23 18:55 ` Joe Perches
2017-05-23 18:59 ` David Daney
2017-05-23 21:42 ` David Daney
2017-05-24 16:01 ` SF Markus Elfring
2017-05-24 19:43 ` Joe Perches
2017-05-29 19:38 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).