aboutgitcodebugslistschat
path: root/passt.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-01-16 11:50:37 +1100
committerStefano Brivio <sbrivio@redhat.com>2024-01-22 23:35:22 +0100
commit70121ca1ec8480805569a77e71a00d4add4b29af (patch)
tree0c2605ca7bbe757038c22c2d7d34e5dbc8c01752 /passt.h
parent36dfa8b8fb62c0eb9ff4c2c5127e29525035e325 (diff)
downloadpasst-70121ca1ec8480805569a77e71a00d4add4b29af.tar
passt-70121ca1ec8480805569a77e71a00d4add4b29af.tar.gz
passt-70121ca1ec8480805569a77e71a00d4add4b29af.tar.bz2
passt-70121ca1ec8480805569a77e71a00d4add4b29af.tar.lz
passt-70121ca1ec8480805569a77e71a00d4add4b29af.tar.xz
passt-70121ca1ec8480805569a77e71a00d4add4b29af.tar.zst
passt-70121ca1ec8480805569a77e71a00d4add4b29af.zip
epoll: Better handling of number of epoll types
As we already did for flow types, use an "EPOLL_NUM_TYPES" isntead of EPOLL_TYPE_MAX, which is a little bit safer and clearer. Add a static assert on the size of the matching names array. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'passt.h')
-rw-r--r--passt.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/passt.h b/passt.h
index c74887a..f54023a 100644
--- a/passt.h
+++ b/passt.h
@@ -70,7 +70,7 @@ enum epoll_type {
/* socket listening for qemu socket connections */
EPOLL_TYPE_TAP_LISTEN,
- EPOLL_TYPE_MAX = EPOLL_TYPE_TAP_LISTEN,
+ EPOLL_NUM_TYPES,
};
/**
@@ -115,7 +115,7 @@ extern char pkt_buf [PKT_BUF_BYTES];
extern char *epoll_type_str[];
#define EPOLL_TYPE_STR(n) \
- (((uint8_t)(n) <= EPOLL_TYPE_MAX && epoll_type_str[(n)]) ? \
+ (((uint8_t)(n) < EPOLL_NUM_TYPES && epoll_type_str[(n)]) ? \
epoll_type_str[(n)] : "?")
#include <resolv.h> /* For MAXNS below */