batman-adv: change compat code to remove sparse warning

Message ID 1362049727-16411-1-git-send-email-siwu@hrz.tu-chemnitz.de (mailing list archive)
State Accepted, archived
Commit 2caa9e1a656f825d24a2517383bf30877753be40
Headers

Commit Message

Simon Wunderlich Feb. 28, 2013, 11:08 a.m. UTC
  The latest compat patch fixing rtnl ops compile errors from 2.6.32
("batman-adv: add compat support for the new netlink ops") fixes
the compilation, but leaves some sparse errors:
batman-adv/soft-interface.c:573:10: warning: Initializer entry defined twice
batman-adv/soft-interface.c:574:10: also defined here

This patch uses another approach by moving the initializers in a dummy
struct instead. This also removes the sparse errors.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
---
 compat.h |   30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)
  

Comments

Antonio Quartulli Feb. 28, 2013, 11:13 a.m. UTC | #1
On Thu, Feb 28, 2013 at 12:08:47 +0100, Simon Wunderlich wrote:
> The latest compat patch fixing rtnl ops compile errors from 2.6.32
> ("batman-adv: add compat support for the new netlink ops") fixes
> the compilation, but leaves some sparse errors:
> batman-adv/soft-interface.c:573:10: warning: Initializer entry defined twice
> batman-adv/soft-interface.c:574:10: also defined here
> 
> This patch uses another approach by moving the initializers in a dummy
> struct instead. This also removes the sparse errors.
> 
> Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>

Acked-by: Antonio Quartulli <ordex@autistici.org>


Thank you Simon!
Cheers,
  
Marek Lindner March 1, 2013, 2:15 a.m. UTC | #2
On Thursday, February 28, 2013 19:13:30 Antonio Quartulli wrote:
> On Thu, Feb 28, 2013 at 12:08:47 +0100, Simon Wunderlich wrote:
> > The latest compat patch fixing rtnl ops compile errors from 2.6.32
> > ("batman-adv: add compat support for the new netlink ops") fixes
> > the compilation, but leaves some sparse errors:
> > batman-adv/soft-interface.c:573:10: warning: Initializer entry defined
> > twice batman-adv/soft-interface.c:574:10: also defined here
> >
> > This patch uses another approach by moving the initializers in a dummy
> > struct instead. This also removes the sparse errors.
> >
> > Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
> 
> Acked-by: Antonio Quartulli <ordex@autistici.org>

Applied in revision 2caa9e1.

Thanks,
Marek
  

Patch

diff --git a/compat.h b/compat.h
index 64244ac..69c3dc2 100644
--- a/compat.h
+++ b/compat.h
@@ -135,23 +135,19 @@  static inline int batadv_param_set_copystring(const char *val,
 #define kstrtoul strict_strtoul
 #define kstrtol  strict_strtol
 
-#define batadv_softif_slave_add(x, y) \
-batadv_softif_slave_add(struct net_device *dev, struct ifreq *rq, int cmd)\
-{\
-	return -EOPNOTSUPP;\
-}\
-static int __attribute__((unused)) __batadv_softif_slave_add(x, y)
-
-#define batadv_softif_slave_del(x, y) \
-__batadv_softif_slave_del(struct net_device *dev, struct net_device *slave_dev);\
-static int batadv_softif_slave_del(struct net_device *dev, struct ifreq *rq, int cmd)\
-{\
-	return -EOPNOTSUPP;\
-}\
-static int __attribute__((unused)) __batadv_softif_slave_del(x, y)
-
-#define ndo_add_slave ndo_do_ioctl
-#define ndo_del_slave ndo_do_ioctl
+/* Hack for removing ndo_add/del_slave at the end of net_device_ops.
+ * This is somewhat ugly because it requires that ndo_validate_addr
+ * is at the end of this struct in soft-interface.c.
+ */
+#define ndo_validate_addr \
+	ndo_validate_addr = eth_validate_addr, \
+}; \
+static const struct { \
+	void *ndo_validate_addr; \
+	void *ndo_add_slave; \
+	void *ndo_del_slave; \
+} __attribute__((unused)) __useless_ops1 = { \
+	.ndo_validate_addr
 
 #endif /* < KERNEL_VERSION(2, 6, 39) */