mirror of
https://passt.top/passt
synced 2025-06-02 14:15:37 +02:00
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>
This commit is contained in:
parent
36dfa8b8fb
commit
70121ca1ec
2 changed files with 5 additions and 3 deletions
4
passt.h
4
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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue