All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
	linux-mips@linux-mips.org,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	"David Daney" <david.daney@cavium.com>,
	"Ralf Bächle" <ralf@linux-mips.org>,
	"Steven J. Hill" <steven.hill@cavium.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_
Date: Tue, 23 May 2017 18:55:52 +0000	[thread overview]
Message-ID: <1495565752.2093.69.camel@perches.com> (raw)
In-Reply-To: <7995eb17-f2ec-54ad-f4d4-7b3dd8337d33@users.sourceforge.net>

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()

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
	linux-mips@linux-mips.org,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	"David Daney" <david.daney@cavium.com>,
	"Ralf Bächle" <ralf@linux-mips.org>,
	"Steven J. Hill" <steven.hill@cavium.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
Date: Tue, 23 May 2017 11:55:52 -0700	[thread overview]
Message-ID: <1495565752.2093.69.camel@perches.com> (raw)
In-Reply-To: <7995eb17-f2ec-54ad-f4d4-7b3dd8337d33@users.sourceforge.net>

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()

  reply	other threads:[~2017-05-23 18:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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: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 [this message]
2017-05-23 18:55   ` Joe Perches
2017-05-23 18:59   ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_ David Daney
2017-05-23 18:59     ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio() David Daney
2017-05-23 21:42   ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_ David Daney
2017-05-23 21:42     ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio() David Daney
2017-05-24 16:01   ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_ SF Markus Elfring
2017-05-24 16:01     ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio() SF Markus Elfring
2017-05-24 19:43     ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_ Joe Perches
2017-05-24 19:43       ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio() Joe Perches
2017-05-29 19:38       ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_ Geert Uytterhoeven
2017-05-29 19:38         ` [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio() Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495565752.2093.69.camel@perches.com \
    --to=joe@perches.com \
    --cc=dan.carpenter@oracle.com \
    --cc=david.daney@cavium.com \
    --cc=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=steven.hill@cavium.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.