libnm,core: use NM_FLAGS_ANY() for MODEM_CAPS_3GPP()/MODEM_CAPS_3GPP2()

Macros should (where possible and sensible) behave function-like.
That means for example, that they evaluate arguments only once, and
use parentheses around code that expands, so that unexpected uses
work correctly. The parentheses was missing.

Instead, just use the NM_FLAGS_ANY() macro which gets this right.
This commit is contained in:
Thomas Haller 2022-01-28 21:01:38 +01:00
parent e9de583bb9
commit 8f6423ac06
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 6 additions and 6 deletions

View file

@ -37,7 +37,7 @@ MODEM_CAPS_3GPP(MMModemCapability caps)
G_GNUC_END_IGNORE_DEPRECATIONS
}
#define MODEM_CAPS_3GPP2(caps) (caps & (MM_MODEM_CAPABILITY_CDMA_EVDO))
#define MODEM_CAPS_3GPP2(caps) NM_FLAGS_ANY((caps), MM_MODEM_CAPABILITY_CDMA_EVDO)
/* Maximum time to keep the DBus call waiting for a connection result.
* This value is greater than the default timeout in ModemManager (180s since

View file

@ -153,12 +153,12 @@ get_type_description(NMDevice *device)
return NULL;
}
#define MODEM_CAPS_3GPP(caps) \
(caps \
& (NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_LTE \
| NM_DEVICE_MODEM_CAPABILITY_5GNR))
#define MODEM_CAPS_3GPP(caps) \
NM_FLAGS_ANY((caps), \
(NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS | NM_DEVICE_MODEM_CAPABILITY_LTE \
| NM_DEVICE_MODEM_CAPABILITY_5GNR))
#define MODEM_CAPS_3GPP2(caps) (caps & (NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO))
#define MODEM_CAPS_3GPP2(caps) NM_FLAGS_ANY((caps), NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)
static gboolean
connection_compatible(NMDevice *device, NMConnection *connection, GError **error)