diff mbox series

[v3] block: aoe: no need to check return value of debugfs_create functions

Message ID 20190603194754.GB21877@kroah.com (mailing list archive)
State New, archived
Headers show
Series [v3] block: aoe: no need to check return value of debugfs_create functions | expand

Commit Message

Greg Kroah-Hartman June 3, 2019, 7:47 p.m. UTC
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: "Ed L. Cashin" <ed.cashin@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Cc: Omar Sandoval <osandov@osandov.com>
Cc: Justin Sanders <justin@coraid.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
v3: Justin is now the maintainer of this driver, properly send it to
    him.
v2: fix uninitialized entry issue found by Omar Sandoval

 drivers/block/aoe/aoeblk.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

Comments

Justin Sanders June 4, 2019, 6:09 p.m. UTC | #1
Hi,

> On Jun 3, 2019, at 3:47 PM, Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> 
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> Cc: "Ed L. Cashin" <ed.cashin@acm.org>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: linux-block@vger.kernel.org
> Cc: Omar Sandoval <osandov@osandov.com>
> Cc: Justin Sanders <justin@coraid.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> v3: Justin is now the maintainer of this driver, properly send it to
>    him.
> v2: fix uninitialized entry issue found by Omar Sandoval
> 
> drivers/block/aoe/aoeblk.c | 16 ++--------------
> 1 file changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
> index e2c6aae2d636..bd19f8af950b 100644
> --- a/drivers/block/aoe/aoeblk.c
> +++ b/drivers/block/aoe/aoeblk.c
> @@ -196,7 +196,6 @@ static const struct file_operations aoe_debugfs_fops = {
> static void
> aoedisk_add_debugfs(struct aoedev *d)
> {
> -	struct dentry *entry;
> 	char *p;
> 
> 	if (aoe_debugfs_dir == NULL)
> @@ -207,15 +206,8 @@ aoedisk_add_debugfs(struct aoedev *d)
> 	else
> 		p++;
> 	BUG_ON(*p == '\0');
> -	entry = debugfs_create_file(p, 0444, aoe_debugfs_dir, d,
> -				    &aoe_debugfs_fops);
> -	if (IS_ERR_OR_NULL(entry)) {
> -		pr_info("aoe: cannot create debugfs file for %s\n",
> -			d->gd->disk_name);
> -		return;
> -	}
> -	BUG_ON(d->debugfs);
> -	d->debugfs = entry;
> +	d->debugfs = debugfs_create_file(p, 0444, aoe_debugfs_dir, d,
> +					 &aoe_debugfs_fops);
> }
> void
> aoedisk_rm_debugfs(struct aoedev *d)
> @@ -472,10 +464,6 @@ aoeblk_init(void)
> 	if (buf_pool_cache == NULL)
> 		return -ENOMEM;
> 	aoe_debugfs_dir = debugfs_create_dir("aoe", NULL);
> -	if (IS_ERR_OR_NULL(aoe_debugfs_dir)) {
> -		pr_info("aoe: cannot create debugfs directory\n");
> -		aoe_debugfs_dir = NULL;
> -	}
> 	return 0;
> }
> 
> -- 
> 2.21.0
> 
> 

This looks good to me, thanks.

Acked-by: Justin Sanders <justin@coraid.com>

Cheers,
Justin
Jens Axboe June 4, 2019, 7:38 p.m. UTC | #2
On 6/3/19 1:47 PM, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index e2c6aae2d636..bd19f8af950b 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -196,7 +196,6 @@  static const struct file_operations aoe_debugfs_fops = {
 static void
 aoedisk_add_debugfs(struct aoedev *d)
 {
-	struct dentry *entry;
 	char *p;
 
 	if (aoe_debugfs_dir == NULL)
@@ -207,15 +206,8 @@  aoedisk_add_debugfs(struct aoedev *d)
 	else
 		p++;
 	BUG_ON(*p == '\0');
-	entry = debugfs_create_file(p, 0444, aoe_debugfs_dir, d,
-				    &aoe_debugfs_fops);
-	if (IS_ERR_OR_NULL(entry)) {
-		pr_info("aoe: cannot create debugfs file for %s\n",
-			d->gd->disk_name);
-		return;
-	}
-	BUG_ON(d->debugfs);
-	d->debugfs = entry;
+	d->debugfs = debugfs_create_file(p, 0444, aoe_debugfs_dir, d,
+					 &aoe_debugfs_fops);
 }
 void
 aoedisk_rm_debugfs(struct aoedev *d)
@@ -472,10 +464,6 @@  aoeblk_init(void)
 	if (buf_pool_cache == NULL)
 		return -ENOMEM;
 	aoe_debugfs_dir = debugfs_create_dir("aoe", NULL);
-	if (IS_ERR_OR_NULL(aoe_debugfs_dir)) {
-		pr_info("aoe: cannot create debugfs directory\n");
-		aoe_debugfs_dir = NULL;
-	}
 	return 0;
 }