From 05c36d67ce8a303481248c38996a5b71bfd8c4d9 Mon Sep 17 00:00:00 2001 From: Piotr Tworek Date: Mon, 16 Nov 2020 01:48:58 +0100 Subject: [PATCH] os: Fix clang constant warning in Port_allocator. Clang 11 produces the following warning when building port_allocator.cc: port_allocator.cc:27:21: error: result of comparison of constant 65536 with expression of type 'const Genode::uint16_t' (aka 'const unsigned short') is always true [-Werror,-Wtautological-constant-out-of-range-compare] (port.value < (unsigned)(Port_allocator::FIRST + Basically the code compares Port::value (uint16_t) against a constant 65536 which is larger than UINT16_MAX (65535). This comparison will always be true. Issue #3984 --- repos/os/src/server/nic_router/port_allocator.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/repos/os/src/server/nic_router/port_allocator.cc b/repos/os/src/server/nic_router/port_allocator.cc index 8c955705e3..fab135c2c0 100644 --- a/repos/os/src/server/nic_router/port_allocator.cc +++ b/repos/os/src/server/nic_router/port_allocator.cc @@ -18,12 +18,8 @@ using namespace Net; using namespace Genode; -bool Net::dynamic_port(Port const port) -{ - return port.value >= (unsigned)Port_allocator::FIRST && - port.value < (unsigned)Port_allocator::FIRST + - Port_allocator::COUNT; -} +bool Net::dynamic_port(Port const port) { + return port.value >= Port_allocator::FIRST; } /********************