summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-11-07 19:58:35 +0100
committerThomas Haller <thaller@redhat.com>2017-11-13 11:35:44 +0100
commit8948dbe117c45227f4c7c1e57a0c0785c6f06a1c (patch)
tree1d6a0ee99addfd88ac83dd1564a15cc8b12dd98b
parentd5c9c95e96a376834e7582843cf019fbdba03a7c (diff)
downloadNetworkManager-8948dbe117c45227f4c7c1e57a0c0785c6f06a1c.tar.gz
platform: add generic NM_PLATFORM_IP_ROUTE_CAST() macro
A cast macro, that does some static type checking (of the pointer).
-rw-r--r--src/platform/nm-platform.h20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index d155c1092e..a98f1586ab 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -441,23 +441,11 @@ typedef struct {
};
} NMPlatformIPRoute;
-#if _NM_CC_SUPPORT_GENERIC
-#define NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route) \
- (_Generic ((route), \
- const NMPlatformIPRoute *: ((const NMPlatformIPRoute *) (route))->plen, \
- NMPlatformIPRoute *: ((const NMPlatformIPRoute *) (route))->plen, \
- const NMPlatformIPXRoute *: ((const NMPlatformIPRoute *) (route))->plen, \
- NMPlatformIPXRoute *: ((const NMPlatformIPRoute *) (route))->plen, \
- const NMPlatformIP4Route *: ((const NMPlatformIPRoute *) (route))->plen, \
- NMPlatformIP4Route *: ((const NMPlatformIPRoute *) (route))->plen, \
- const NMPlatformIP6Route *: ((const NMPlatformIPRoute *) (route))->plen, \
- NMPlatformIP6Route *: ((const NMPlatformIPRoute *) (route))->plen, \
- const void *: ((const NMPlatformIPRoute *) (route))->plen, \
- void *: ((const NMPlatformIPRoute *) (route))->plen) == 0)
-#else
+#define NM_PLATFORM_IP_ROUTE_CAST(route) \
+ NM_CONSTCAST (NMPlatformIPRoute, (route), NMPlatformIPXRoute, NMPlatformIP4Route, NMPlatformIP6Route)
+
#define NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route) \
- ( ((const NMPlatformIPRoute *) (route))->plen <= 0 )
-#endif
+ (NM_PLATFORM_IP_ROUTE_CAST (route)->plen <= 0)
struct _NMPlatformIP4Route {
__NMPlatformIPRoute_COMMON;