summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-08-22 16:38:05 +0200
committerThomas Haller <thaller@redhat.com>2017-08-23 18:37:21 +0200
commitffd47da5dc9fcc2c1220bd4db9c9008db0571234 (patch)
tree35e097964313f09c51d70ee5bec99c2dabe04a78
parent2f693fb68c0b71cc77e7a722c5d3b8bebea01e35 (diff)
downloadNetworkManager-ffd47da5dc9fcc2c1220bd4db9c9008db0571234.tar.gz
platform: use _Generic() for NM_PLATFORM_IP_ROUTE_IS_DEFAULT() macro
Avoid the plain cast and use _Generic() to check the type of @route argument.
-rw-r--r--src/platform/nm-platform.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 841c5e77a7..6575634bed 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -420,8 +420,23 @@ 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_IS_DEFAULT(route) \
( ((const NMPlatformIPRoute *) (route))->plen <= 0 )
+#endif
struct _NMPlatformIP4Route {
__NMPlatformIPRoute_COMMON;