[PATCH] build: Fixup headers for C++ inclusion

Craig Gallek kraigatgoog at gmail.com
Fri Jul 15 07:29:06 PDT 2016


From: Craig Gallek <kraig at google.com>

- Fix typos in extern "C" wrappers.
- 'class' is a reserved word, change to cls.
- int -> enum casts are not automatic.
- Static strings must be of type const char*
- Add a few implicit header dependencies explicitly.

Signed-off-by: Craig Gallek <kraig at google.com>
---
 include/linux-private/linux/ipv6.h  |  1 +
 include/netlink-private/netlink.h   |  4 ++--
 include/netlink-private/types.h     |  1 +
 include/netlink/hashtable.h         |  3 +++
 include/netlink/route/link/ip6tnl.h |  2 +-
 include/netlink/route/link/sit.h    |  2 +-
 include/netlink/route/qdisc/hfsc.h  | 12 ++++++------
 7 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/include/linux-private/linux/ipv6.h b/include/linux-private/linux/ipv6.h
index f16349df0ceb..e05e684adac1 100644
--- a/include/linux-private/linux/ipv6.h
+++ b/include/linux-private/linux/ipv6.h
@@ -2,6 +2,7 @@
 #define _IPV6_H
 
 #include <asm/byteorder.h>
+#include <linux/in6.h>
 
 /* The latest drafts declared increase in minimal mtu up to 1280. */
 
diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h
index befd3014afcb..dd07c107127c 100644
--- a/include/netlink-private/netlink.h
+++ b/include/netlink-private/netlink.h
@@ -138,7 +138,7 @@ extern int __str2flags(const char *, const struct trans_tbl *, size_t);
 extern void dump_from_ops(struct nl_object *, struct nl_dump_params *);
 extern struct rtnl_link *link_lookup(struct nl_cache *cache, int ifindex);
 
-static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg)
+static inline int nl_cb_call(struct nl_cb *cb, enum nl_cb_type type, struct nl_msg *msg)
 {
 	int ret;
 
@@ -201,7 +201,7 @@ static inline void rtnl_rcopy_ratespec(struct tc_ratespec *dst,
 	dst->rate = src->rs_rate;
 }
 
-static inline char *nl_cache_name(struct nl_cache *cache)
+static inline const char *nl_cache_name(struct nl_cache *cache)
 {
 	return cache->c_ops ? cache->c_ops->co_name : "unknown";
 }
diff --git a/include/netlink-private/types.h b/include/netlink-private/types.h
index 0f67ddda8f4a..e80c8a14ddd5 100644
--- a/include/netlink-private/types.h
+++ b/include/netlink-private/types.h
@@ -20,6 +20,7 @@
 #include <netlink/route/route.h>
 #include <netlink/idiag/idiagnl.h>
 #include <netlink/netfilter/ct.h>
+#include <netlink-private/object-api.h>
 #include <netlink-private/route/tc-api.h>
 #include <linux/tc_act/tc_mirred.h>
 #include <linux/tc_act/tc_skbedit.h>
diff --git a/include/netlink/hashtable.h b/include/netlink/hashtable.h
index d9e6ee45d809..3b40d86c1376 100644
--- a/include/netlink/hashtable.h
+++ b/include/netlink/hashtable.h
@@ -12,6 +12,9 @@
 #ifndef NETLINK_HASHTABLE_H_
 #define NETLINK_HASHTABLE_H_
 
+#include <stddef.h>
+#include <stdint.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/include/netlink/route/link/ip6tnl.h b/include/netlink/route/link/ip6tnl.h
index 40213567ee36..87ab164f5064 100644
--- a/include/netlink/route/link/ip6tnl.h
+++ b/include/netlink/route/link/ip6tnl.h
@@ -51,7 +51,7 @@ extern "C" {
 	extern int rtnl_link_ip6_tnl_set_proto(struct rtnl_link *link, uint8_t proto);
 	extern uint8_t rtnl_link_ip6_tnl_get_proto(struct rtnl_link *link);
 
-#ifdef _cplusplus
+#ifdef __cplusplus
 }
 #endif
 
diff --git a/include/netlink/route/link/sit.h b/include/netlink/route/link/sit.h
index 8f58d0ac23b9..62e01edfff55 100644
--- a/include/netlink/route/link/sit.h
+++ b/include/netlink/route/link/sit.h
@@ -58,7 +58,7 @@ extern "C" {
 	int rtnl_link_sit_set_ip6rd_relay_prefixlen(struct rtnl_link *link, uint16_t prefix);
 	int rtnl_link_sit_get_ip6rd_relay_prefixlen(struct rtnl_link *link, uint16_t *prefix);
 
-#ifdef _cplusplus
+#ifdef __cplusplus
 }
 #endif
 
diff --git a/include/netlink/route/qdisc/hfsc.h b/include/netlink/route/qdisc/hfsc.h
index 8d34fe55ff74..dd0a2b74fcae 100644
--- a/include/netlink/route/qdisc/hfsc.h
+++ b/include/netlink/route/qdisc/hfsc.h
@@ -24,12 +24,12 @@ extern "C" {
 extern uint32_t	rtnl_qdisc_hfsc_get_defcls(const struct rtnl_qdisc *);
 extern int	rtnl_qdisc_hfsc_set_defcls(struct rtnl_qdisc *, uint32_t);
 
-extern int rtnl_class_hfsc_get_rsc(const struct rtnl_class *class, struct tc_service_curve *tsc);
-extern int rtnl_class_hfsc_set_rsc(struct rtnl_class *class, const struct tc_service_curve *tsc);
-extern int rtnl_class_hfsc_get_fsc(const struct rtnl_class *class, struct tc_service_curve *tsc);
-extern int rtnl_class_hfsc_set_fsc(struct rtnl_class *class, const struct tc_service_curve *tsc);
-extern int rtnl_class_hfsc_get_usc(const struct rtnl_class *class, struct tc_service_curve *tsc);
-extern int rtnl_class_hfsc_set_usc(struct rtnl_class *class, const struct tc_service_curve *tsc);
+extern int rtnl_class_hfsc_get_rsc(const struct rtnl_class *cls, struct tc_service_curve *tsc);
+extern int rtnl_class_hfsc_set_rsc(struct rtnl_class *cls, const struct tc_service_curve *tsc);
+extern int rtnl_class_hfsc_get_fsc(const struct rtnl_class *cls, struct tc_service_curve *tsc);
+extern int rtnl_class_hfsc_set_fsc(struct rtnl_class *cls, const struct tc_service_curve *tsc);
+extern int rtnl_class_hfsc_get_usc(const struct rtnl_class *cls, struct tc_service_curve *tsc);
+extern int rtnl_class_hfsc_set_usc(struct rtnl_class *cls, const struct tc_service_curve *tsc);
 #ifdef __cplusplus
 }
 #endif
-- 
2.8.0.rc3.226.g39d4020




More information about the libnl mailing list