[v3,3/3] batman-adv: use static inline functions to fake not compiled-in routines

Message ID 1334214449-3996-4-git-send-email-ordex@autistici.org (mailing list archive)
State Not Applicable, archived
Headers

Commit Message

Antonio Quartulli April 12, 2012, 7:07 a.m. UTC
  In case of not compiled-in components, we need to fake some functions in order
to let the rest of the code correctly build. But instead of using something
like:

We have to use:

static inline bla_init(struct bat_priv *bat_priv)
{
	return 1;
}

In this way the compiler can correctly check the type and the number of the
arguments passed to the function, even if the related component (bla in this
case) is not compiled.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 bridge_loop_avoidance.h |   60 ++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 51 insertions(+), 9 deletions(-)
  

Comments

Marek Lindner April 13, 2012, 8:35 p.m. UTC | #1
On Thursday, April 12, 2012 09:07:29 Antonio Quartulli wrote:
> In case of not compiled-in components, we need to fake some functions in
> order to let the rest of the code correctly build. But instead of using
> something like:
> 
> We have to use:
> 
> static inline bla_init(struct bat_priv *bat_priv)
> {
>         return 1;
> }
> 
> In this way the compiler can correctly check the type and the number of the
> arguments passed to the function, even if the related component (bla in
> this case) is not compiled.

Applied in revision 9b3b58e.

Thanks,
Marek
  
Marek Lindner April 13, 2012, 9:04 p.m. UTC | #2
On Thursday, April 12, 2012 09:07:29 Antonio Quartulli wrote:
> In case of not compiled-in components, we need to fake some functions in
> order to let the rest of the code correctly build. But instead of using
> something like:
> 
> We have to use:
> 
> static inline bla_init(struct bat_priv *bat_priv)
> {
>         return 1;
> }
> 
> In this way the compiler can correctly check the type and the number of the
> arguments passed to the function, even if the related component (bla in
> this case) is not compiled.

The same needs to be done for DAT, right ?

Regards,
Marek
  
Antonio Quartulli April 13, 2012, 10:13 p.m. UTC | #3
On Fri, Apr 13, 2012 at 11:04:23 +0200, Marek Lindner wrote:
> On Thursday, April 12, 2012 09:07:29 Antonio Quartulli wrote:
> > In case of not compiled-in components, we need to fake some functions in
> > order to let the rest of the code correctly build. But instead of using
> > something like:
> > 
> > We have to use:
> > 
> > static inline bla_init(struct bat_priv *bat_priv)
> > {
> >         return 1;
> > }
> > 
> > In this way the compiler can correctly check the type and the number of the
> > arguments passed to the function, even if the related component (bla in
> > this case) is not compiled.
> 
> The same needs to be done for DAT, right ?

Exactly.
the next pull request should contain this change also for DAT. Moreover we
should provide a sysfs mechanism enable/disable DAT at runtime, so that people
can disable it on all the nodes without the need of rebuilding the module.

Cheers,
  

Patch

diff --git a/bridge_loop_avoidance.h b/bridge_loop_avoidance.h
index e1a2966..e39f93a 100644
--- a/bridge_loop_avoidance.h
+++ b/bridge_loop_avoidance.h
@@ -40,16 +40,58 @@  void bla_free(struct bat_priv *bat_priv);
 #define BLA_CRC_INIT	0
 #else /* ifdef CONFIG_BATMAN_ADV_BLA */
 
-#define bla_rx(...)				(0)
-#define bla_tx(...)				(0)
-#define bla_is_backbone_gw(...)			(0)
-#define bla_claim_table_seq_print_text		(0)
-#define bla_is_backbone_gw_orig(...)		(0)
-#define bla_check_bcast_duplist(...)		(0)
-#define bla_update_orig_address(...)		do {} while (0)
-#define bla_init(...)				(1)
-#define bla_free(...)				do {} while (0)
+static inline int bla_rx(struct bat_priv *bat_priv, struct sk_buff *skb,
+			 short vid)
+{
+	return 0;
+}
 
+static inline int bla_tx(struct bat_priv *bat_priv, struct sk_buff *skb,
+			 short vid)
+{
+	return 0;
+}
+
+static inline int bla_is_backbone_gw(struct sk_buff *skb,
+				     struct orig_node *orig_node,
+				     int hdr_size)
+{
+	return 0;
+}
+
+static inline int bla_claim_table_seq_print_text(struct seq_file *seq,
+						 void *offset)
+{
+	return 0;
+}
+
+static inline int bla_is_backbone_gw_orig(struct bat_priv *bat_priv,
+					  uint8_t *orig)
+{
+	return 0;
+}
+
+static inline int bla_check_bcast_duplist(struct bat_priv *bat_priv,
+					  struct bcast_packet *bcast_packet,
+					  int hdr_size)
+{
+	return 0;
+}
+
+static inline void bla_update_orig_address(struct bat_priv *bat_priv,
+					   struct hard_iface *primary_if,
+					   struct hard_iface *oldif)
+{
+}
+
+static inline int bla_init(struct bat_priv *bat_priv)
+{
+	return 1;
+}
+
+static inline void bla_free(struct bat_priv *bat_priv)
+{
+}
 
 #endif /* ifdef CONFIG_BATMAN_ADV_BLA */