Userland: Resolve tautological-constant-out-of-range-compare warnings

Stop comparing platform-specific sized integer types to max() values of
other interger types. Enable the warning everywhere.
This commit is contained in:
Andrew Kaster 2022-01-03 02:50:55 -07:00 committed by Brian Gianforcaro
parent a103a85ae6
commit d809637023
Notes: sideshowbarker 2024-07-17 21:43:08 +09:00
4 changed files with 8 additions and 8 deletions

View file

@ -199,7 +199,6 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
add_compile_options(-Wno-atomic-alignment) add_compile_options(-Wno-atomic-alignment)
add_compile_options(-Wno-implicit-const-int-float-conversion) add_compile_options(-Wno-implicit-const-int-float-conversion)
add_compile_options(-Wno-null-pointer-subtraction) add_compile_options(-Wno-null-pointer-subtraction)
add_compile_options(-Wno-tautological-constant-out-of-range-compare)
add_compile_options(-Wno-unneeded-internal-declaration) add_compile_options(-Wno-unneeded-internal-declaration)
add_compile_options(-Wno-unused-but-set-variable) add_compile_options(-Wno-unused-but-set-variable)
add_compile_options(-Wno-unused-const-variable) add_compile_options(-Wno-unused-const-variable)

View file

@ -63,8 +63,9 @@ bool FILE::flush()
} }
if (m_mode & O_RDONLY) { if (m_mode & O_RDONLY) {
// When open for reading, just drop the buffered data. // When open for reading, just drop the buffered data.
VERIFY(m_buffer.buffered_size() <= NumericLimits<off_t>::max()); if constexpr (sizeof(size_t) >= sizeof(off_t))
off_t had_buffered = m_buffer.buffered_size(); VERIFY(m_buffer.buffered_size() <= NumericLimits<off_t>::max());
off_t had_buffered = static_cast<off_t>(m_buffer.buffered_size());
m_buffer.drop(); m_buffer.drop();
// Attempt to reset the underlying file position to what the user // Attempt to reset the underlying file position to what the user
// expects. // expects.

View file

@ -346,7 +346,7 @@ public:
{ {
if (size_to_grow == 0) if (size_to_grow == 0)
return true; return true;
auto new_size = m_data.size() + size_to_grow; u64 new_size = m_data.size() + size_to_grow;
// Can't grow past 2^16 pages. // Can't grow past 2^16 pages.
if (new_size >= Constants::page_size * 65536) if (new_size >= Constants::page_size * 65536)
return false; return false;

View file

@ -488,10 +488,10 @@ void WebSocket::send_frame(WebSocket::OpCode op_code, ReadonlyBytes payload, boo
m_impl->send(ReadonlyBytes(frame_head, 1)); m_impl->send(ReadonlyBytes(frame_head, 1));
// Section 5.1 : a client MUST mask all frames that it sends to the server // Section 5.1 : a client MUST mask all frames that it sends to the server
bool has_mask = true; bool has_mask = true;
if (payload.size() > NumericLimits<u64>::max()) { // FIXME: If the payload has a size > size_t max on a 32-bit platform, we could
// FIXME: We can technically stream this via non-final packets. // technically stream it via non-final packets. However, the size was already
TODO(); // truncated earlier in the call stack when stuffing into a ReadonlyBytes
} else if (payload.size() > NumericLimits<u16>::max()) { if (payload.size() > NumericLimits<u16>::max()) {
// Send (the 'mask' flag + 127) + the 8-byte payload length // Send (the 'mask' flag + 127) + the 8-byte payload length
if constexpr (sizeof(size_t) >= 8) { if constexpr (sizeof(size_t) >= 8) {
u8 payload_length[9] = { u8 payload_length[9] = {