netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] l2tp: no need to check return value of debugfs_create functions
@ 2019-06-14  7:04 Greg Kroah-Hartman
  2019-06-14 11:55 ` Guillaume Nault
  2019-06-14 15:45 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-14  7:04 UTC (permalink / raw)
  To: David S. Miller, Guillaume Nault; +Cc: netdev

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.

Also, there is no need to store the individual debugfs file name, just
remove the whole directory all at once, saving a local variable.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Guillaume Nault <g.nault@alphalink.fr>
Cc: netdev@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/l2tp/l2tp_debugfs.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c
index 6e2b4b9267e1..35bb4f3bdbe0 100644
--- a/net/l2tp/l2tp_debugfs.c
+++ b/net/l2tp/l2tp_debugfs.c
@@ -31,7 +31,6 @@
 #include "l2tp_core.h"
 
 static struct dentry *rootdir;
-static struct dentry *tunnels;
 
 struct l2tp_dfs_seq_data {
 	struct net *net;
@@ -326,32 +325,18 @@ static const struct file_operations l2tp_dfs_fops = {
 
 static int __init l2tp_debugfs_init(void)
 {
-	int rc = 0;
-
 	rootdir = debugfs_create_dir("l2tp", NULL);
-	if (IS_ERR(rootdir)) {
-		rc = PTR_ERR(rootdir);
-		rootdir = NULL;
-		goto out;
-	}
 
-	tunnels = debugfs_create_file("tunnels", 0600, rootdir, NULL, &l2tp_dfs_fops);
-	if (tunnels == NULL)
-		rc = -EIO;
+	debugfs_create_file("tunnels", 0600, rootdir, NULL, &l2tp_dfs_fops);
 
 	pr_info("L2TP debugfs support\n");
 
-out:
-	if (rc)
-		pr_warn("unable to init\n");
-
-	return rc;
+	return 0;
 }
 
 static void __exit l2tp_debugfs_exit(void)
 {
-	debugfs_remove(tunnels);
-	debugfs_remove(rootdir);
+	debugfs_remove_recursive(rootdir);
 }
 
 module_init(l2tp_debugfs_init);
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] l2tp: no need to check return value of debugfs_create functions
  2019-06-14  7:04 [PATCH] l2tp: no need to check return value of debugfs_create functions Greg Kroah-Hartman
@ 2019-06-14 11:55 ` Guillaume Nault
  2019-06-14 15:45 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Guillaume Nault @ 2019-06-14 11:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: David S. Miller, Guillaume Nault, netdev

On Fri, Jun 14, 2019 at 09:04:38AM +0200, 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.
> 
> Also, there is no need to store the individual debugfs file name, just
> remove the whole directory all at once, saving a local variable.
> 
Acked-by: Guillaume Nault <gnault@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] l2tp: no need to check return value of debugfs_create functions
  2019-06-14  7:04 [PATCH] l2tp: no need to check return value of debugfs_create functions Greg Kroah-Hartman
  2019-06-14 11:55 ` Guillaume Nault
@ 2019-06-14 15:45 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-06-14 15:45 UTC (permalink / raw)
  To: gregkh; +Cc: g.nault, netdev

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Fri, 14 Jun 2019 09:04:38 +0200

> 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.
> 
> Also, there is no need to store the individual debugfs file name, just
> remove the whole directory all at once, saving a local variable.
> 
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Guillaume Nault <g.nault@alphalink.fr>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-14 15:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14  7:04 [PATCH] l2tp: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-06-14 11:55 ` Guillaume Nault
2019-06-14 15:45 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).