mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-09 12:00:36 +01:00
libnm: relax asserting argument for nm_utils_hwaddr_len()
nm_utils_hwaddr_len() isn't very useful. It's documented to
only accept two possible input values (ARPHRD_ETHER and ARPHRD_INFINIBAND)
for which the respective return values are well known.
In particular, asserting that the input value is one of the two values
means it becomes harder to extend the function (and make it more useful).
Because, then the user would need to call:
#if NM_VERSION > NM_VERSION_1_XX
len = nm_utils_hwaddr_len (ARPHDR_FOO);
#else
len = 0
#endif
and then it would introduce an unnecessary run time dependency on
NM_VERSION_1_XX.
Instead, just document to return 0 if the value is not supported.
This commit is contained in:
parent
2d360d8293
commit
2fdc713e92
1 changed files with 8 additions and 6 deletions
|
|
@ -4001,20 +4001,22 @@ nm_utils_wifi_strength_bars (guint8 strength)
|
|||
*
|
||||
* Returns the length in octets of a hardware address of type @type.
|
||||
*
|
||||
* It is an error to call this function with any value other than
|
||||
* Before 1.28, it was an error to call this function with any value other than
|
||||
* <literal>ARPHRD_ETHER</literal> or <literal>ARPHRD_INFINIBAND</literal>.
|
||||
*
|
||||
* Return value: the length.
|
||||
* Return value: the length or zero if the type is unrecognized.
|
||||
*/
|
||||
gsize
|
||||
nm_utils_hwaddr_len (int type)
|
||||
{
|
||||
if (type == ARPHRD_ETHER)
|
||||
switch (type) {
|
||||
case ARPHRD_ETHER:
|
||||
return ETH_ALEN;
|
||||
else if (type == ARPHRD_INFINIBAND)
|
||||
case ARPHRD_INFINIBAND:
|
||||
return INFINIBAND_ALEN;
|
||||
|
||||
g_return_val_if_reached (0);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue