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.
This commit is contained in:
Thomas Haller 2017-08-22 16:38:05 +02:00
parent 2f693fb68c
commit ffd47da5dc

View file

@ -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;