platform: accept %NULL route as parameter to nm_platform_ip_route_get_gateway()

It's sometimes convenient to accept %NULL and have a "maybe type" like
behavior to propagate the %NULL input of the getter.
This commit is contained in:
Thomas Haller 2021-10-30 09:44:32 +02:00 committed by Beniamino Galvani
parent bcf31a9b29
commit 7faeda8351

View file

@ -2176,7 +2176,9 @@ static inline gconstpointer
nm_platform_ip_route_get_gateway(int addr_family, const NMPlatformIPRoute *route)
{
nm_assert_addr_family(addr_family);
nm_assert(route);
if (!route)
return NULL;
if (NM_IS_IPv4(addr_family))
return &((NMPlatformIP4Route *) route)->gateway;