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


Groups > linux.kernel > #1648342

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

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH] MIPS: Octeon: Delete an error message for a failed memory allocation in octeon_irq_init_gpio()
Date Tue, 23 May 2017 21:00:01 +0200
Message-ID <tKncd-77q-1@gated-at.bofh.it> (permalink)
References <tKmzw-6Qv-17@gated-at.bofh.it>
X-Session-Marker 6A6F6540706572636865732E636F6D
X-Spam-Summary 50,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:960:967:973:988:989:1042:1260:1263:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2525:2553:2560:2563:2682:2685:2828:2859:2899:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3870:3871:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4605:5007:6119:7576:7903:9025:9388:10004:10049:10400:10471:10848:10967:11026:11232:11233:11658:11783:11914:12043:12048:12114:12296:12438:12555:12679:12740:12895:13095:13255:13439:13894:14659:14721:14849:21080:21212:21433:21451:21627:30012:30034:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none
X-He-Tag trees81_6dace2222a911
X-Filterd-Recvd-Size 3165
Content-Type text/plain; charset="ISO-8859-1"
X-Mailer Evolution 3.22.6-1ubuntu1
MIME-Version 1.0
Content-Transfer-Encoding 8bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 58
Organization linux.* mail to news gateway
X-Original-Cc LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
X-Original-Date Tue, 23 May 2017 11:55:52 -0700
X-Original-Message-ID <1495565752.2093.69.camel@perches.com>
X-Original-References <7995eb17-f2ec-54ad-f4d4-7b3dd8337d33@users.sourceforge.net>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1648342

Show key headers only | View raw


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

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[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

csiph-web