nfctool: Fix build failure with libnl v1
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 8 Jan 2013 15:12:13 +0000 (16:12 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 8 Jan 2013 15:12:53 +0000 (16:12 +0100)
With libnl v1 neard fails to build with:

tools/nfctool/netlink.c: In function ‘nl_send_msg’:
tools/nfctool/netlink.c:135:2: error: passing argument 1 of
‘nl_send_auto_complete’ from incompatible pointer type [-Werror]
/usr/include/netlink/netlink.h:48:14: note: expected ‘struct nl_handle *’ but
argument is of type ‘struct nl_sock *’
tools/nfctool/netlink.c:153:3: error: passing argument 1 of ‘nl_recvmsgs’ from
incompatible pointer type [-Werror]
/usr/include/netlink/netlink.h:58:14: note: expected ‘struct nl_handle *’ but
argument is of type ‘struct nl_sock *’
tools/nfctool/netlink.c: In function ‘nl_get_multicast_id’:
tools/nfctool/netlink.c:212:2: error: passing argument 1 of
‘genl_ctrl_resolve’ from incompatible pointer type [-Werror]
/usr/include/netlink/genl/ctrl.h:29:14: note: expected ‘struct nl_handle *’
but argument is of type ‘struct nl_sock *’
[...]

Adding the regular compatibility layer fixes it.

tools/nfctool/netlink.c

index 7102bca..aaa0641 100644 (file)
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <errno.h>
 #include <sys/socket.h>
 #include <linux/nfc.h>
+
+#include <netlink/netlink.h>
 #include <netlink/genl/genl.h>
+#include <netlink/genl/family.h>
 #include <netlink/genl/ctrl.h>
+
 #include <glib.h>
 
 #include "nfctool.h"
 #include "netlink.h"
 
+#ifdef NEED_LIBNL_COMPAT
+#define nl_sock nl_handle
+
+static inline struct nl_handle *nl_socket_alloc(void)
+{
+       return nl_handle_alloc();
+}
+
+static inline void nl_socket_free(struct nl_sock *h)
+{
+       nl_handle_destroy(h);
+}
+
+#define NLE_MISSING_ATTR       14
+
+static inline void __nl_perror(int error, const char *s)
+{
+       nl_perror(s);
+}
+#define nl_perror __nl_perror
+#endif
+
 struct handler_args {
        const char *group;
        int id;