diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-11-30 13:02:11 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-12-04 09:51:06 +0100 |
commit | 9d44aba7e05ea84a3dd7192c97f561b962cac5b9 (patch) | |
tree | ee03a94e5107544ea7299067ed4191969ce2739f /passt.h | |
parent | e2e8219f13b80cef257134ebcb4d2616b2f1578c (diff) | |
download | passt-9d44aba7e05ea84a3dd7192c97f561b962cac5b9.tar passt-9d44aba7e05ea84a3dd7192c97f561b962cac5b9.tar.gz passt-9d44aba7e05ea84a3dd7192c97f561b962cac5b9.tar.bz2 passt-9d44aba7e05ea84a3dd7192c97f561b962cac5b9.tar.lz passt-9d44aba7e05ea84a3dd7192c97f561b962cac5b9.tar.xz passt-9d44aba7e05ea84a3dd7192c97f561b962cac5b9.tar.zst passt-9d44aba7e05ea84a3dd7192c97f561b962cac5b9.zip |
util: MAX_FROM_BITS() should be unsigned
MAX_FROM_BITS() computes the maximum value representable in a number of
bits. The expression for that is an unsigned value, but we explicitly cast
it to a signed int. It looks like this is because one of the main users is
for FD_REF_MAX, which is used to bound fd values, typically stored as a
signed int.
The value MAX_FROM_BITS() is calculating is naturally non-negative, though,
so it makes more sense for it to be unsigned, and to move the case to the
definition of FD_REF_MAX.
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.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -87,7 +87,7 @@ union epoll_ref { struct { enum epoll_type type:8; #define FD_REF_BITS 24 -#define FD_REF_MAX MAX_FROM_BITS(FD_REF_BITS) +#define FD_REF_MAX ((int)MAX_FROM_BITS(FD_REF_BITS)) int32_t fd:FD_REF_BITS; union { union tcp_epoll_ref tcp; |