From: miquel.raynal@bootlin.com (Miquel Raynal)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] mtd: maps: Remove print after allocation failure
Date: Mon, 19 Mar 2018 23:42:50 +0100 [thread overview]
Message-ID: <20180319234250.18aa0826@xps13> (raw)
In-Reply-To: <1521390796-13715-1-git-send-email-arushisinghal19971997@gmail.com>
Hi Arushi,
On Sun, 18 Mar 2018 22:03:15 +0530, Arushi Singhal
<arushisinghal19971997@gmail.com> wrote:
> The prints after [k|v][m|z|c]alloc() functions are not needed, because
> in case of failure, allocator will print their internal error prints
> anyway.
>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> ---
> changes in v2
> * done changes in all the other files.
>
> drivers/mtd/maps/amd76xrom.c | 6 ++----
> drivers/mtd/maps/ck804xrom.c | 4 +---
> drivers/mtd/maps/esb2rom.c | 4 +---
> drivers/mtd/maps/ichxrom.c | 6 ++----
> drivers/mtd/maps/sun_uflash.c | 4 +---
> drivers/mtd/maps/vmu-flash.c | 3 ---
> 6 files changed, 7 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
> index 26de0a1..406a8d3 100644
> --- a/drivers/mtd/maps/amd76xrom.c
> +++ b/drivers/mtd/maps/amd76xrom.c
> @@ -188,10 +188,8 @@ static int amd76xrom_init_one(struct pci_dev *pdev,
>
> if (!map) {
> map = kmalloc(sizeof(*map), GFP_KERNEL);
> - }
> - if (!map) {
> - printk(KERN_ERR MOD_NAME ": kmalloc failed");
> - goto out;
> + if (!map)
> + goto out;
> }
> memset(map, 0, sizeof(*map));
> INIT_LIST_HEAD(&map->list);
> diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c
> index 584962e..2529d1b 100644
> --- a/drivers/mtd/maps/ck804xrom.c
> +++ b/drivers/mtd/maps/ck804xrom.c
> @@ -219,10 +219,8 @@ static int __init ck804xrom_init_one(struct pci_dev *pdev,
> if (!map)
> map = kmalloc(sizeof(*map), GFP_KERNEL);
>
> - if (!map) {
> - printk(KERN_ERR MOD_NAME ": kmalloc failed");
> + if (!map)
> goto out;
> - }
This is a personal feeling but I prefer the first version:
if (!map) {
map = kmalloc();
if (!map)
err;
}
than
if (!map)
map = kmalloc();
if (!map)
err;
Same below of course.
Thanks,
Miqu?l
--
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Arushi Singhal <arushisinghal19971997@gmail.com>
Cc: boris.brezillon@free-electrons.com, richard@nod.at,
dwmw2@infradead.org, computersforpeace@gmail.com,
nicolas.ferre@microchip.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, miquel.raynal@free-electrons.com,
alexandre.belloni@free-electrons.com, wens@csie.org,
cyrille.pitchen@wedev4u.fr
Subject: Re: [PATCH v2 1/2] mtd: maps: Remove print after allocation failure
Date: Mon, 19 Mar 2018 23:42:50 +0100 [thread overview]
Message-ID: <20180319234250.18aa0826@xps13> (raw)
In-Reply-To: <1521390796-13715-1-git-send-email-arushisinghal19971997@gmail.com>
Hi Arushi,
On Sun, 18 Mar 2018 22:03:15 +0530, Arushi Singhal
<arushisinghal19971997@gmail.com> wrote:
> The prints after [k|v][m|z|c]alloc() functions are not needed, because
> in case of failure, allocator will print their internal error prints
> anyway.
>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> ---
> changes in v2
> * done changes in all the other files.
>
> drivers/mtd/maps/amd76xrom.c | 6 ++----
> drivers/mtd/maps/ck804xrom.c | 4 +---
> drivers/mtd/maps/esb2rom.c | 4 +---
> drivers/mtd/maps/ichxrom.c | 6 ++----
> drivers/mtd/maps/sun_uflash.c | 4 +---
> drivers/mtd/maps/vmu-flash.c | 3 ---
> 6 files changed, 7 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
> index 26de0a1..406a8d3 100644
> --- a/drivers/mtd/maps/amd76xrom.c
> +++ b/drivers/mtd/maps/amd76xrom.c
> @@ -188,10 +188,8 @@ static int amd76xrom_init_one(struct pci_dev *pdev,
>
> if (!map) {
> map = kmalloc(sizeof(*map), GFP_KERNEL);
> - }
> - if (!map) {
> - printk(KERN_ERR MOD_NAME ": kmalloc failed");
> - goto out;
> + if (!map)
> + goto out;
> }
> memset(map, 0, sizeof(*map));
> INIT_LIST_HEAD(&map->list);
> diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c
> index 584962e..2529d1b 100644
> --- a/drivers/mtd/maps/ck804xrom.c
> +++ b/drivers/mtd/maps/ck804xrom.c
> @@ -219,10 +219,8 @@ static int __init ck804xrom_init_one(struct pci_dev *pdev,
> if (!map)
> map = kmalloc(sizeof(*map), GFP_KERNEL);
>
> - if (!map) {
> - printk(KERN_ERR MOD_NAME ": kmalloc failed");
> + if (!map)
> goto out;
> - }
This is a personal feeling but I prefer the first version:
if (!map) {
map = kmalloc();
if (!map)
err;
}
than
if (!map)
map = kmalloc();
if (!map)
err;
Same below of course.
Thanks,
Miquèl
--
Miquel Raynal, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2018-03-19 22:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-18 16:33 [PATCH v2 1/2] mtd: maps: Remove print after allocation failure Arushi Singhal
2018-03-18 16:33 ` Arushi Singhal
2018-03-18 16:33 ` [PATCH v2 2/2] mtd: nand: " Arushi Singhal
2018-03-18 16:33 ` Arushi Singhal
2018-03-19 22:47 ` Miquel Raynal
2018-03-19 22:47 ` Miquel Raynal
2018-03-19 22:42 ` Miquel Raynal [this message]
2018-03-19 22:42 ` [PATCH v2 1/2] mtd: maps: " Miquel Raynal
-- strict thread matches above, loose matches on Subject: below --
2018-03-20 15:31 Arushi Singhal
2018-03-20 15:31 ` Arushi Singhal
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=20180319234250.18aa0826@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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.