From cea6dedccc751f3761f04688d124df795346c75c Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 26 Sep 2024 15:20:07 +0300 Subject: [PATCH] Userspace: Compile programs and libraries with -Wall -Wextra -Werror --- userspace/libraries/CMakeLists.txt | 2 +- userspace/libraries/LibGUI/Window.cpp | 2 +- userspace/programs/CMakeLists.txt | 2 +- userspace/programs/Terminal/Terminal.cpp | 4 ++-- userspace/programs/WindowServer/WindowServer.cpp | 5 +---- userspace/programs/ls/main.cpp | 4 ++-- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/userspace/libraries/CMakeLists.txt b/userspace/libraries/CMakeLists.txt index 370f73ca8c..d34fe70e46 100644 --- a/userspace/libraries/CMakeLists.txt +++ b/userspace/libraries/CMakeLists.txt @@ -20,7 +20,7 @@ foreach(library ${USERSPACE_LIBRARIES}) # This is to allow cmake to link when libc updates target_link_options(${library_lower} PRIVATE -nolibc) # Default compile options - target_compile_options(${library_lower} PRIVATE -g -O2) + target_compile_options(${library_lower} PRIVATE -g -O2 -Wall -Wextra -Werror) target_compile_definitions(${library_lower} PRIVATE __enable_sse=${BANAN_ENABLE_SSE}) if (NOT BANAN_ENABLE_SSE) diff --git a/userspace/libraries/LibGUI/Window.cpp b/userspace/libraries/LibGUI/Window.cpp index 9a5978bee8..e8951fd5c7 100644 --- a/userspace/libraries/LibGUI/Window.cpp +++ b/userspace/libraries/LibGUI/Window.cpp @@ -166,7 +166,7 @@ namespace LibGUI if (amount <= 0) return; - const uint32_t copy_src_y = BAN::Math::clamp(src_y, 0, height()); + const int32_t copy_src_y = BAN::Math::clamp(src_y, 0, height()); const int32_t copy_amount = BAN::Math::clamp(src_y + amount, 0, height()) - copy_src_y; if (copy_amount > 0) { diff --git a/userspace/programs/CMakeLists.txt b/userspace/programs/CMakeLists.txt index 848dd5806d..a66a8a7b4c 100644 --- a/userspace/programs/CMakeLists.txt +++ b/userspace/programs/CMakeLists.txt @@ -43,7 +43,7 @@ foreach(project ${USERSPACE_PROGRAMS}) # This is to allow cmake to link when libc updates target_link_options(${project} PRIVATE -nolibc) # Default compile options - target_compile_options(${project} PRIVATE -g -O2) + target_compile_options(${project} PRIVATE -g -O2 -Wall -Wextra -Werror) target_compile_definitions(${project} PRIVATE __enable_sse=${BANAN_ENABLE_SSE}) if (NOT BANAN_ENABLE_SSE) diff --git a/userspace/programs/Terminal/Terminal.cpp b/userspace/programs/Terminal/Terminal.cpp index 6b66177ee9..a1846eb5d2 100644 --- a/userspace/programs/Terminal/Terminal.cpp +++ b/userspace/programs/Terminal/Terminal.cpp @@ -222,13 +222,13 @@ bool Terminal::read_shell() } // find the next ansi escape code or end of buffer - size_t non_ansi_end = i; + ssize_t non_ansi_end = i; while (non_ansi_end < nread && buffer[non_ansi_end] != '\e') non_ansi_end++; // we only need to process maximum of `rows()` newlines. // anything before that would get overwritten anyway - size_t start = non_ansi_end; + ssize_t start = non_ansi_end; size_t newline_count = 0; while (start > i && newline_count < rows()) newline_count += (buffer[--start] == '\n'); diff --git a/userspace/programs/WindowServer/WindowServer.cpp b/userspace/programs/WindowServer/WindowServer.cpp index 81ad6c4812..7a49494d9d 100644 --- a/userspace/programs/WindowServer/WindowServer.cpp +++ b/userspace/programs/WindowServer/WindowServer.cpp @@ -413,7 +413,7 @@ void WindowServer::invalidate(Rectangle area) const auto is_rounded_off = [&](Position pos) -> bool { - for (size_t i = 0; i < 4; i++) + for (int32_t i = 0; i < 4; i++) { if (!corner_areas[i].contains(pos)) continue; @@ -558,8 +558,6 @@ void WindowServer::sync() dir_y = -dir_y; } - size_t synced_pages = 0; - for (size_t i = 0; i < m_pages_to_sync_bitmap.size() * 8; i++) { size_t byte = i / 8; @@ -582,7 +580,6 @@ void WindowServer::sync() len * 4096, MS_SYNC ); - synced_pages += len; i += len; } diff --git a/userspace/programs/ls/main.cpp b/userspace/programs/ls/main.cpp index fd3dbb00c2..1b1a450482 100644 --- a/userspace/programs/ls/main.cpp +++ b/userspace/programs/ls/main.cpp @@ -135,7 +135,7 @@ int list_directory(const BAN::String& path, config_t config) if (!S_ISDIR(st.st_mode)) { - MUST(entries.emplace_back(path, st)); + MUST(entries.emplace_back(path, st, BAN::String())); if (S_ISLNK(st.st_mode)) { if (readlink(path.data(), link_buffer, sizeof(link_buffer)) == -1) @@ -166,7 +166,7 @@ int list_directory(const BAN::String& path, config_t config) continue; } - MUST(entries.emplace_back(BAN::StringView(dirent->d_name), st)); + MUST(entries.emplace_back(BAN::StringView(dirent->d_name), st, BAN::String())); if (S_ISLNK(st.st_mode)) { if (readlinkat(dirfd(dirp), dirent->d_name, link_buffer, sizeof(link_buffer)) == -1)