network: make use of SD_ENUM_FORCE_S64() for all public enums

This commit is contained in:
Lennart Poettering
2021-02-16 20:36:52 +01:00
parent 9823703ae6
commit 386059e119
6 changed files with 16 additions and 3 deletions
+6
View File
@@ -40,10 +40,16 @@ int main(int argc, char **argv) {
test_table(wol, WOL);
test_table(lldp_event, SD_LLDP_EVENT);
test_table(ndisc_event, SD_NDISC_EVENT);
test_table(dhcp_lease_server_type, SD_DHCP_LEASE_SERVER_TYPE);
test_table_sparse(ipvlan_mode, NETDEV_IPVLAN_MODE);
test_table_sparse(macvlan_mode, NETDEV_MACVLAN_MODE);
test_table_sparse(address_family, ADDRESS_FAMILY);
assert_cc(sizeof(sd_lldp_event) == sizeof(int64_t));
assert_cc(sizeof(sd_ndisc_event) == sizeof(int64_t));
assert_cc(sizeof(sd_dhcp_lease_server_type) == sizeof(int64_t));
assert_cc(sizeof(sd_genl_family) == sizeof(int64_t));
return EXIT_SUCCESS;
}
+2 -2
View File
@@ -42,7 +42,7 @@ int wifi_get_interface(sd_netlink *genl, int ifindex, enum nl80211_iftype *iftyp
if (r < 0)
return log_debug_errno(r, "Failed to determine genl family: %m");
if (family != SD_GENL_NL80211) {
log_debug("Received message of unexpected genl family %u, ignoring.", family);
log_debug("Received message of unexpected genl family %" PRIi64 ", ignoring.", family);
goto nodata;
}
@@ -110,7 +110,7 @@ int wifi_get_station(sd_netlink *genl, int ifindex, struct ether_addr *bssid) {
if (r < 0)
return log_debug_errno(r, "Failed to determine genl family: %m");
if (family != SD_GENL_NL80211) {
log_debug("Received message of unexpected genl family %u, ignoring.", family);
log_debug("Received message of unexpected genl family %" PRIi64 ", ignoring.", family);
goto nodata;
}
+1
View File
@@ -43,6 +43,7 @@ typedef enum sd_dhcp_lease_server_type {
SD_DHCP_LEASE_LPR,
_SD_DHCP_LEASE_SERVER_TYPE_MAX,
_SD_DHCP_LEASE_SERVER_TYPE_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(DHCP_LEASE_SERVER_TYPE),
} sd_dhcp_lease_server_type;
int sd_dhcp_lease_get_address(sd_dhcp_lease *lease, struct in_addr *addr);
+1
View File
@@ -129,6 +129,7 @@ typedef enum sd_lldp_event {
SD_LLDP_EVENT_REFRESHED,
_SD_LLDP_EVENT_MAX,
_SD_LLDP_EVENT_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(LLDP_EVENT),
} sd_lldp_event;
typedef void (*sd_lldp_callback_t)(sd_lldp *lldp, sd_lldp_event event, sd_lldp_neighbor *n, void *userdata);
+1
View File
@@ -60,6 +60,7 @@ typedef enum sd_ndisc_event {
SD_NDISC_EVENT_ROUTER,
_SD_NDISC_EVENT_MAX,
_SD_NDISC_EVENT_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(NDISC_EVENT),
} sd_ndisc_event;
typedef void (*sd_ndisc_callback_t)(sd_ndisc *nd, sd_ndisc_event event, sd_ndisc_router *rt, void *userdata);
+5 -1
View File
@@ -17,6 +17,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <inttypes.h>
#include <net/ethernet.h>
#include <netinet/in.h>
@@ -34,7 +35,7 @@ typedef struct sd_genl_socket sd_genl_socket;
typedef struct sd_netlink_message sd_netlink_message;
typedef struct sd_netlink_slot sd_netlink_slot;
typedef enum sd_gen_family {
typedef enum sd_genl_family {
SD_GENL_ERROR,
SD_GENL_DONE,
SD_GENL_ID_CTRL,
@@ -43,6 +44,9 @@ typedef enum sd_gen_family {
SD_GENL_L2TP,
SD_GENL_MACSEC,
SD_GENL_NL80211,
_SD_GENL_FAMILY_MAX,
_SD_GENL_FAMILY_INVALID = -EINVAL,
_SD_ENUM_FORCE_S64(GENL_FAMILY)
} sd_genl_family;
/* callback */