From: SF Markus Elfring <elfring@users.sourceforge.net>
To: Jens Axboe <axboe@fb.com>, kernel-janitors@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] z2ram: Delete four error messages for a failed memory allocation in z2_open()
Date: Mon, 07 Aug 2017 16:06:41 +0000 [thread overview]
Message-ID: <83b6c012-07ca-39df-cfd4-0c4791ecda3d@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 7 Aug 2017 17:56:53 +0200
Omit extra messages 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>
---
drivers/block/z2ram.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 41c95c9b2ab4..66af886cb0a0 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -199,12 +199,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
z2ram_map =
kmalloc((size/Z2RAM_CHUNKSIZE)*sizeof(z2ram_map[0]),
GFP_KERNEL);
- if ( z2ram_map = NULL )
- {
- printk( KERN_ERR DEVICE_NAME
- ": cannot get mem for z2ram_map\n" );
+ if (!z2ram_map)
goto err_out;
- }
while (size) {
z2ram_map[ z2ram_size++ ] = vaddr;
@@ -224,12 +220,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
case Z2MINOR_COMBINED:
z2ram_map = kmalloc( max_z2_map + max_chip_map, GFP_KERNEL );
- if ( z2ram_map = NULL )
- {
- printk( KERN_ERR DEVICE_NAME
- ": cannot get mem for z2ram_map\n" );
+ if (!z2ram_map)
goto err_out;
- }
get_z2ram();
get_chipram();
@@ -245,12 +237,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
case Z2MINOR_Z2ONLY:
z2ram_map = kmalloc( max_z2_map, GFP_KERNEL );
- if ( z2ram_map = NULL )
- {
- printk( KERN_ERR DEVICE_NAME
- ": cannot get mem for z2ram_map\n" );
+ if (!z2ram_map)
goto err_out;
- }
get_z2ram();
@@ -263,12 +251,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
case Z2MINOR_CHIPONLY:
z2ram_map = kmalloc( max_chip_map, GFP_KERNEL );
- if ( z2ram_map = NULL )
- {
- printk( KERN_ERR DEVICE_NAME
- ": cannot get mem for z2ram_map\n" );
+ if (!z2ram_map)
goto err_out;
- }
get_chipram();
--
2.13.4
WARNING: multiple messages have this Message-ID (diff)
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: Jens Axboe <axboe@fb.com>, kernel-janitors@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] z2ram: Delete four error messages for a failed memory allocation in z2_open()
Date: Mon, 7 Aug 2017 18:06:41 +0200 [thread overview]
Message-ID: <83b6c012-07ca-39df-cfd4-0c4791ecda3d@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 7 Aug 2017 17:56:53 +0200
Omit extra messages 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>
---
drivers/block/z2ram.c | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 41c95c9b2ab4..66af886cb0a0 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -199,12 +199,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
z2ram_map =
kmalloc((size/Z2RAM_CHUNKSIZE)*sizeof(z2ram_map[0]),
GFP_KERNEL);
- if ( z2ram_map == NULL )
- {
- printk( KERN_ERR DEVICE_NAME
- ": cannot get mem for z2ram_map\n" );
+ if (!z2ram_map)
goto err_out;
- }
while (size) {
z2ram_map[ z2ram_size++ ] = vaddr;
@@ -224,12 +220,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
case Z2MINOR_COMBINED:
z2ram_map = kmalloc( max_z2_map + max_chip_map, GFP_KERNEL );
- if ( z2ram_map == NULL )
- {
- printk( KERN_ERR DEVICE_NAME
- ": cannot get mem for z2ram_map\n" );
+ if (!z2ram_map)
goto err_out;
- }
get_z2ram();
get_chipram();
@@ -245,12 +237,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
case Z2MINOR_Z2ONLY:
z2ram_map = kmalloc( max_z2_map, GFP_KERNEL );
- if ( z2ram_map == NULL )
- {
- printk( KERN_ERR DEVICE_NAME
- ": cannot get mem for z2ram_map\n" );
+ if (!z2ram_map)
goto err_out;
- }
get_z2ram();
@@ -263,12 +251,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
case Z2MINOR_CHIPONLY:
z2ram_map = kmalloc( max_chip_map, GFP_KERNEL );
- if ( z2ram_map == NULL )
- {
- printk( KERN_ERR DEVICE_NAME
- ": cannot get mem for z2ram_map\n" );
+ if (!z2ram_map)
goto err_out;
- }
get_chipram();
--
2.13.4
next reply other threads:[~2017-08-07 16:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 16:06 SF Markus Elfring [this message]
2017-08-07 16:06 ` [PATCH] z2ram: Delete four error messages for a failed memory allocation in z2_open() SF Markus Elfring
2017-08-07 16:08 ` Jens Axboe
2017-08-07 16:08 ` Jens Axboe
2017-08-07 16:43 ` Joe Perches
2017-08-07 16:43 ` Joe Perches
2017-08-07 16:44 ` Jens Axboe
2017-08-07 16:44 ` Jens Axboe
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=83b6c012-07ca-39df-cfd4-0c4791ecda3d@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=axboe@fb.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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.