diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a476c0..b560503 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ stages: stage: test script: - mkdir build && cd build - - cmake -DBUILD_TESTING=1 .. + - CXXFLAGS=-Werror cmake -DBUILD_TESTING=1 .. - make -j$(nproc) - broadwayd & CTEST_OUTPUT_ON_FAILURE=1 make test diff --git a/src/cmake.cpp b/src/cmake.cpp index ad8a420..c1327e7 100644 --- a/src/cmake.cpp +++ b/src/cmake.cpp @@ -151,7 +151,7 @@ boost::filesystem::path CMake::get_executable(const boost::filesystem::path &bui }); } - boost::optional best_match_size; + ssize_t best_match_size = -1; boost::filesystem::path best_match_executable; for(auto &cmake_executable : cmake_executables) { @@ -163,7 +163,7 @@ boost::filesystem::path CMake::get_executable(const boost::filesystem::path &bui return maybe_executable; auto command_file_directory = command_file.parent_path(); if(filesystem::file_in_path(file_path, command_file_directory)) { - auto size = static_cast(std::distance(command_file_directory.begin(), command_file_directory.end())); + auto size = std::distance(command_file_directory.begin(), command_file_directory.end()); if(size > best_match_size) { best_match_size = size; best_match_executable = maybe_executable; @@ -182,7 +182,7 @@ boost::filesystem::path CMake::get_executable(const boost::filesystem::path &bui return maybe_executable; auto command_file_directory = command_file.parent_path(); if(filesystem::file_in_path(file_path, command_file_directory)) { - auto size = static_cast(std::distance(command_file_directory.begin(), command_file_directory.end())); + auto size = std::distance(command_file_directory.begin(), command_file_directory.end()); if(size > best_match_size) { best_match_size = size; best_match_executable = maybe_executable; diff --git a/src/meson.cpp b/src/meson.cpp index 23bbe05..85e1dda 100644 --- a/src/meson.cpp +++ b/src/meson.cpp @@ -99,7 +99,7 @@ bool Meson::update_debug_build(const boost::filesystem::path &debug_build_path, boost::filesystem::path Meson::get_executable(const boost::filesystem::path &build_path, const boost::filesystem::path &file_path) { CompileCommands compile_commands(build_path); - boost::optional best_match_size; + ssize_t best_match_size = -1; boost::filesystem::path best_match_executable; for(auto &command : compile_commands.commands) { auto command_file = filesystem::get_normal_path(command.file); @@ -113,7 +113,7 @@ boost::filesystem::path Meson::get_executable(const boost::filesystem::path &bui return executable; auto command_file_directory = command_file.parent_path(); if(filesystem::file_in_path(file_path, command_file_directory)) { - auto size = static_cast(std::distance(command_file_directory.begin(), command_file_directory.end())); + auto size = std::distance(command_file_directory.begin(), command_file_directory.end()); if(size > best_match_size) { best_match_size = size; best_match_executable = executable; diff --git a/src/source.cpp b/src/source.cpp index 768a86f..eb4f547 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -233,7 +233,7 @@ Source::View::View(const boost::filesystem::path &file_path, const Glib::RefPtr< --line_end; bool lines_commented = true; bool extra_spaces = true; - boost::optional min_indentation; + int min_indentation = std::numeric_limits::max(); for(auto line = line_start; line <= line_end; ++line) { auto iter = get_buffer()->get_iter_at_line(line); bool line_added = false; @@ -279,8 +279,7 @@ Source::View::View(const boost::filesystem::path &file_path, const Glib::RefPtr< if(line_added) { lines_commented &= line_commented; extra_spaces &= extra_space; - if(!min_indentation || indentation < min_indentation) - min_indentation = indentation; + min_indentation = std::min(min_indentation, indentation); } } if(lines.size()) { @@ -288,7 +287,8 @@ Source::View::View(const boost::filesystem::path &file_path, const Glib::RefPtr< get_buffer()->begin_user_action(); for(auto &line : lines) { auto iter = get_buffer()->get_iter_at_line(line); - iter.forward_chars(min_indentation.value_or(0)); + if(min_indentation != std::numeric_limits::max()) + iter.forward_chars(min_indentation); if(lines_commented) { auto end_iter = iter; end_iter.forward_chars(comment_characters.size() + static_cast(extra_spaces));