diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-01-16 11:50:37 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-01-22 23:35:22 +0100 |
commit | 70121ca1ec8480805569a77e71a00d4add4b29af (patch) | |
tree | 0c2605ca7bbe757038c22c2d7d34e5dbc8c01752 /passt.c | |
parent | 36dfa8b8fb62c0eb9ff4c2c5127e29525035e325 (diff) | |
download | passt-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.c')
-rw-r--r-- | passt.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -59,7 +59,7 @@ char pkt_buf[PKT_BUF_BYTES] __attribute__ ((aligned(PAGE_SIZE))); -char *epoll_type_str[EPOLL_TYPE_MAX + 1] = { +char *epoll_type_str[] = { [EPOLL_TYPE_TCP] = "connected TCP socket", [EPOLL_TYPE_TCP_LISTEN] = "listening TCP socket", [EPOLL_TYPE_TCP_TIMER] = "TCP timer", @@ -71,6 +71,8 @@ char *epoll_type_str[EPOLL_TYPE_MAX + 1] = { [EPOLL_TYPE_TAP_PASST] = "connected qemu socket", [EPOLL_TYPE_TAP_LISTEN] = "listening qemu socket", }; +static_assert(ARRAY_SIZE(epoll_type_str) == EPOLL_NUM_TYPES, + "epoll_type_str[] doesn't match enum epoll_type"); /** * post_handler() - Run periodic and deferred tasks for L4 protocol handlers |