b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Avoid bool in structures
@ 2018-04-19 19:01 Sven Eckelmann
  2018-04-19 19:01 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Remove unused dentry without DEBUGFS Sven Eckelmann
  2018-04-25 17:23 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Avoid bool in structures Sven Eckelmann
  0 siblings, 2 replies; 3+ messages in thread
From: Sven Eckelmann @ 2018-04-19 19:01 UTC (permalink / raw)
  To: b.a.t.m.a.n

Using the bool type for structure member is considered inappropriate [1]
for the kernel. Its size is not well defined (but usually 1 byte but maybe
also 4 byte).

[1] https://lkml.org/lkml/2017/11/21/384

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/types.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 0174f79e..3b3fc146 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1160,13 +1160,13 @@ struct batadv_priv_dat {
  */
 struct batadv_mcast_querier_state {
 	/** @exists: whether a querier exists in the mesh */
-	bool exists;
+	unsigned char exists:1;
 
 	/**
 	 * @shadowing: if a querier exists, whether it is potentially shadowing
 	 *  multicast listeners (i.e. querier is behind our own bridge segment)
 	 */
-	bool shadowing;
+	unsigned char shadowing:1;
 };
 
 /**
@@ -1207,10 +1207,10 @@ struct batadv_priv_mcast {
 	u8 flags;
 
 	/** @enabled: whether the multicast tvlv is currently enabled */
-	bool enabled;
+	unsigned char enabled:1;
 
 	/** @bridged: whether the soft interface has a bridge on top */
-	bool bridged;
+	unsigned char bridged:1;
 
 	/**
 	 * @num_want_all_unsnoopables: number of nodes wanting unsnoopable IP
@@ -1389,7 +1389,7 @@ struct batadv_tp_vars {
 	atomic_t dup_acks;
 
 	/** @fast_recovery: true if in Fast Recovery mode */
-	bool fast_recovery;
+	unsigned char fast_recovery:1;
 
 	/** @recover: last sent seqno when entering Fast Recovery */
 	u32 recover;
@@ -2046,10 +2046,10 @@ struct batadv_skb_cb {
 	 * @decoded: Marks a skb as decoded, which is checked when searching for
 	 *  coding opportunities in network-coding.c
 	 */
-	bool decoded;
+	unsigned char decoded:1;
 
 	/** @num_bcasts: Counter for broadcast packet retransmissions */
-	unsigned int num_bcasts;
+	unsigned char num_bcasts;
 };
 
 /**
-- 
2.17.0


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

* [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Remove unused dentry without DEBUGFS
  2018-04-19 19:01 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Avoid bool in structures Sven Eckelmann
@ 2018-04-19 19:01 ` Sven Eckelmann
  2018-04-25 17:23 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Avoid bool in structures Sven Eckelmann
  1 sibling, 0 replies; 3+ messages in thread
From: Sven Eckelmann @ 2018-04-19 19:01 UTC (permalink / raw)
  To: b.a.t.m.a.n

The debug_dir variable in the main structures is only accessed when
CONFIG_BATMAN_ADV_DEBUGFS is enabled. It can be dropped to potentially save
some bytes of memory.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/types.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 3b3fc146..360357f8 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -215,10 +215,12 @@ struct batadv_hard_iface {
 	struct batadv_hard_iface_bat_v bat_v;
 #endif
 
+#ifdef CONFIG_BATMAN_ADV_DEBUGFS
 	/**
 	 * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
 	 */
 	struct dentry *debug_dir;
+#endif
 
 	/**
 	 * @neigh_list: list of unique single hop neighbors via this interface
@@ -1242,10 +1244,12 @@ struct batadv_priv_nc {
 	/** @work: work queue callback item for cleanup */
 	struct delayed_work work;
 
+#ifdef CONFIG_BATMAN_ADV_DEBUGFS
 	/**
 	 * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
 	 */
 	struct dentry *debug_dir;
+#endif
 
 	/**
 	 * @min_tq: only consider neighbors for encoding if neigh_tq > min_tq
@@ -1598,8 +1602,10 @@ struct batadv_priv {
 	/** @mesh_obj: kobject for sysfs mesh subdirectory */
 	struct kobject *mesh_obj;
 
+#ifdef CONFIG_BATMAN_ADV_DEBUGFS
 	/** @debug_dir: dentry for debugfs batman-adv subdirectory */
 	struct dentry *debug_dir;
+#endif
 
 	/** @forw_bat_list: list of aggregated OGMs that will be forwarded */
 	struct hlist_head forw_bat_list;
-- 
2.17.0


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

* Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Avoid bool in structures
  2018-04-19 19:01 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Avoid bool in structures Sven Eckelmann
  2018-04-19 19:01 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Remove unused dentry without DEBUGFS Sven Eckelmann
@ 2018-04-25 17:23 ` Sven Eckelmann
  1 sibling, 0 replies; 3+ messages in thread
From: Sven Eckelmann @ 2018-04-25 17:23 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

On Donnerstag, 19. April 2018 21:01:07 CEST Sven Eckelmann wrote:
> Using the bool type for structure member is considered inappropriate [1]
> for the kernel. Its size is not well defined (but usually 1 byte but maybe
> also 4 byte).
> 
> [1] https://lkml.org/lkml/2017/11/21/384
> 
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
>  net/batman-adv/types.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Both patches added as b8f25ee5d426 [1] and 566b52be5f23 [2]

Kind regards,
	Sven

[1] https://git.open-mesh.org/batman-adv.git/commit/b8f25ee5d4263d4eab3a66cae338037f1645c427
[2] https://git.open-mesh.org/batman-adv.git/commit/566b52be5f23eb5ffe94dd40f956c9a473129251

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2018-04-25 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19 19:01 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Avoid bool in structures Sven Eckelmann
2018-04-19 19:01 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Remove unused dentry without DEBUGFS Sven Eckelmann
2018-04-25 17:23 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Avoid bool in structures Sven Eckelmann

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).