netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Markus Pargmann <mpa@pengutronix.de>,
	Marek Lindner <mareklindner@neomailbox.ch>,
	Antonio Quartulli <antonio@meshcoding.com>
Subject: [PATCH 05/16] batman-adv: debugfs, avoid compiling for !DEBUG_FS
Date: Fri, 29 May 2015 11:05:17 +0200	[thread overview]
Message-ID: <1432890328-8247-6-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1432890328-8247-1-git-send-email-antonio@meshcoding.com>

From: Markus Pargmann <mpa@pengutronix.de>

Normally the debugfs framework will return error pointer with -ENODEV
for function calls when DEBUG_FS is not set.

batman does not notice this error code and continues trying to create
debugfs files and executes more code. We can avoid this code execution
by disabling compiling debugfs.c when DEBUG_FS is not set.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---
 net/batman-adv/Makefile  |  2 +-
 net/batman-adv/debugfs.c |  8 --------
 net/batman-adv/debugfs.h | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile
index 79833eb..bd7e343 100644
--- a/net/batman-adv/Makefile
+++ b/net/batman-adv/Makefile
@@ -20,7 +20,7 @@ obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
 batman-adv-y += bat_iv_ogm.o
 batman-adv-y += bitarray.o
 batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o
-batman-adv-y += debugfs.o
+batman-adv-$(CONFIG_DEBUG_FS) += debugfs.o
 batman-adv-$(CONFIG_BATMAN_ADV_DAT) += distributed-arp-table.o
 batman-adv-y += fragmentation.o
 batman-adv-y += gateway_client.o
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index 0c213a8..4611808 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -482,11 +482,7 @@ rem_attr:
 	debugfs_remove_recursive(hard_iface->debug_dir);
 	hard_iface->debug_dir = NULL;
 out:
-#ifdef CONFIG_DEBUG_FS
 	return -ENOMEM;
-#else
-	return 0;
-#endif /* CONFIG_DEBUG_FS */
 }
 
 /**
@@ -541,11 +537,7 @@ rem_attr:
 	debugfs_remove_recursive(bat_priv->debug_dir);
 	bat_priv->debug_dir = NULL;
 out:
-#ifdef CONFIG_DEBUG_FS
 	return -ENOMEM;
-#else
-	return 0;
-#endif /* CONFIG_DEBUG_FS */
 }
 
 void batadv_debugfs_del_meshif(struct net_device *dev)
diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h
index f3b49c3..ed25605 100644
--- a/net/batman-adv/debugfs.h
+++ b/net/batman-adv/debugfs.h
@@ -20,6 +20,8 @@
 
 #define BATADV_DEBUGFS_SUBDIR "batman_adv"
 
+#if IS_ENABLED(CONFIG_DEBUG_FS)
+
 void batadv_debugfs_init(void);
 void batadv_debugfs_destroy(void);
 int batadv_debugfs_add_meshif(struct net_device *dev);
@@ -27,4 +29,36 @@ void batadv_debugfs_del_meshif(struct net_device *dev);
 int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface);
 void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface);
 
+#else
+
+static inline void batadv_debugfs_init(void)
+{
+}
+
+static inline void batadv_debugfs_destroy(void)
+{
+}
+
+static inline int batadv_debugfs_add_meshif(struct net_device *dev)
+{
+	return 0;
+}
+
+static inline void batadv_debugfs_del_meshif(struct net_device *dev)
+{
+}
+
+static inline
+int batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface)
+{
+	return 0;
+}
+
+static inline
+void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface)
+{
+}
+
+#endif
+
 #endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */
-- 
2.4.2

  parent reply	other threads:[~2015-05-29  9:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-29  9:05 pull request: batman-adv 2015-05-29 Antonio Quartulli
2015-05-29  9:05 ` [PATCH 01/16] batman-adv: Start new development cycle Antonio Quartulli
2015-05-29  9:05 ` [PATCH 02/16] batman-adv: update copyright years for 2015 Antonio Quartulli
2015-05-29  9:05 ` [PATCH 03/16] batman-adv: Check total_size when queueing fragments Antonio Quartulli
2015-05-29  9:05 ` [PATCH 04/16] batman-adv: Use only queued fragments when merging Antonio Quartulli
2015-05-29  9:05 ` Antonio Quartulli [this message]
2015-05-29  9:05 ` [PATCH 06/16] batman-adv: tvlv realloc, move error handling into if block Antonio Quartulli
2015-05-29  9:05 ` [PATCH 07/16] batman-adv: Makefile, Sort alphabetically Antonio Quartulli
2015-05-29  9:05 ` [PATCH 08/16] batman-adv: iv_ogm_iface_enable, direct return values Antonio Quartulli
2015-05-29  9:05 ` [PATCH 09/16] batman-adv: iv_ogm_aggr_packet, bool return value Antonio Quartulli
2015-05-29  9:05 ` [PATCH 10/16] batman-adv: iv_ogm_send_to_if, declare char* as const Antonio Quartulli
2015-05-29  9:05 ` [PATCH 11/16] batman-adv: Use safer default config for optional features Antonio Quartulli
2015-05-29  9:05 ` [PATCH 12/16] batman-adv: checkpatch - comparison to NULL could be rewritten Antonio Quartulli
2015-05-29  9:05 ` [PATCH 13/16] batman-adv: checkpatch - spaces preferred around that '*' Antonio Quartulli
2015-05-29  9:05 ` [PATCH 14/16] batman-adv: iv_ogm_can_aggregate, code readability Antonio Quartulli
2015-05-29  9:05 ` [PATCH 15/16] batman-adv: iv_ogm_orig_update, remove unnecessary brackets Antonio Quartulli
2015-05-29  9:05 ` [PATCH 16/16] batman-adv: Use common declaration order in *_send_skb_(packet|unicast) Antonio Quartulli
2015-05-31  8:08 ` pull request: batman-adv 2015-05-29 David Miller

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=1432890328-8247-6-git-send-email-antonio@meshcoding.com \
    --to=antonio@meshcoding.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=mareklindner@neomailbox.ch \
    --cc=mpa@pengutronix.de \
    --cc=netdev@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 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).