diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2023-11-07 11:13:05 +0100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-11-07 12:22:13 +0100 |
commit | b94462296937f59e3750e1c35b80b69a67a535af (patch) | |
tree | cf95f1ed88deef10cf5fd4fe370b6b9c752db0f5 | |
parent | 53ff387156380bee9acb5fe2ca62af97b9ccce36 (diff) | |
download | passt-b94462296937f59e3750e1c35b80b69a67a535af.tar passt-b94462296937f59e3750e1c35b80b69a67a535af.tar.gz passt-b94462296937f59e3750e1c35b80b69a67a535af.tar.bz2 passt-b94462296937f59e3750e1c35b80b69a67a535af.tar.lz passt-b94462296937f59e3750e1c35b80b69a67a535af.tar.xz passt-b94462296937f59e3750e1c35b80b69a67a535af.tar.zst passt-b94462296937f59e3750e1c35b80b69a67a535af.zip |
netlink: Sequence numbers are actually 32 bits wide
Harmless, as we use sequence numbers monotonically anyway, but now
clang-tidy reports:
/home/sbrivio/passt/netlink.c:155:7: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [clang-diagnostic-format,-warnings-as-errors]
nh->nlmsg_seq, seq);
^
/home/sbrivio/passt/log.h:26:7: note: expanded from macro 'die'
err(__VA_ARGS__); \
^~~~~~~~~~~
/home/sbrivio/passt/log.h:19:34: note: expanded from macro 'err'
^~~~~~~~~~~
Suppressed 222820 warnings (222816 in non-user code, 4 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1 warning treated as error
make: *** [Makefile:255: clang-tidy] Error 1
Fixes: 9d4ab98d538f ("netlink: Add nl_do() helper for simple operations with error checking")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | netlink.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -113,7 +113,7 @@ fail: * * Return: sequence number of request on success, terminates on error */ -static uint16_t nl_send(int s, void *req, uint16_t type, +static uint32_t nl_send(int s, void *req, uint16_t type, uint16_t flags, ssize_t len) { struct nlmsghdr *nh; @@ -146,12 +146,12 @@ static uint16_t nl_send(int s, void *req, uint16_t type, * > 0 @n if there are more responses to request @seq * terminates if sequence numbers are out of sync */ -static int nl_status(const struct nlmsghdr *nh, ssize_t n, uint16_t seq) +static int nl_status(const struct nlmsghdr *nh, ssize_t n, uint32_t seq) { ASSERT(NLMSG_OK(nh, n)); if (nh->nlmsg_seq != seq) - die("netlink: Unexpected sequence number (%hu != %hu)", + die("netlink: Unexpected sequence number (%u != %u)", nh->nlmsg_seq, seq); if (nh->nlmsg_type == NLMSG_DONE) { @@ -229,7 +229,7 @@ static int nl_do(int s, void *req, uint16_t type, uint16_t flags, ssize_t len) struct nlmsghdr *nh; char buf[NLBUFSIZ]; ssize_t status; - uint16_t seq; + uint32_t seq; seq = nl_send(s, req, type, flags, len); nl_foreach(nh, status, s, buf, seq) @@ -259,7 +259,7 @@ unsigned int nl_get_ext_if(int s, sa_family_t af) struct rtattr *rta; char buf[NLBUFSIZ]; ssize_t status; - uint16_t seq; + uint32_t seq; size_t na; seq = nl_send(s, &req, RTM_GETROUTE, NLM_F_DUMP, sizeof(req)); @@ -313,7 +313,7 @@ int nl_route_get_def(int s, unsigned int ifi, sa_family_t af, void *gw) bool found = false; char buf[NLBUFSIZ]; ssize_t status; - uint16_t seq; + uint32_t seq; seq = nl_send(s, &req, RTM_GETROUTE, NLM_F_DUMP, sizeof(req)); nl_foreach_oftype(nh, status, s, buf, seq, RTM_NEWROUTE) { @@ -438,7 +438,7 @@ int nl_route_dup(int s_src, unsigned int ifi_src, unsigned dup_routes = 0; struct nlmsghdr *nh; char buf[NLBUFSIZ]; - uint16_t seq; + uint32_t seq; unsigned i; seq = nl_send(s_src, &req, RTM_GETROUTE, NLM_F_DUMP, sizeof(req)); @@ -550,7 +550,7 @@ int nl_addr_get(int s, unsigned int ifi, sa_family_t af, struct nlmsghdr *nh; char buf[NLBUFSIZ]; ssize_t status; - uint16_t seq; + uint32_t seq; seq = nl_send(s, &req, RTM_GETADDR, NLM_F_DUMP, sizeof(req)); nl_foreach_oftype(nh, status, s, buf, seq, RTM_NEWADDR) { @@ -674,7 +674,7 @@ int nl_addr_dup(int s_src, unsigned int ifi_src, char buf[NLBUFSIZ]; struct nlmsghdr *nh; ssize_t status; - uint16_t seq; + uint32_t seq; int rc = 0; seq = nl_send(s_src, &req, RTM_GETADDR, NLM_F_DUMP, sizeof(req)); @@ -729,7 +729,7 @@ int nl_link_get_mac(int s, unsigned int ifi, void *mac) struct nlmsghdr *nh; char buf[NLBUFSIZ]; ssize_t status; - uint16_t seq; + uint32_t seq; seq = nl_send(s, &req, RTM_GETLINK, 0, sizeof(req)); nl_foreach_oftype(nh, status, s, buf, seq, RTM_NEWLINK) { |