Skip to content

Commit

Permalink
Add -Wuseless-cast to FTXUI_DEV_WARNINGS (#728)
Browse files Browse the repository at this point in the history
Add the -Wuseless-cast to the FTXUI_DEV_WARNINGS and
fix the compiler complaints about useless casts
  • Loading branch information
StefanRvO committed Aug 19, 2023
1 parent 1e6df78 commit eb9a701
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cmake/ftxui_set_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ function(ftxui_set_options library)
target_compile_options(${library} PRIVATE "-Wpedantic")
target_compile_options(${library} PRIVATE "-Wshadow")
target_compile_options(${library} PRIVATE "-Wunused")

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${library} PRIVATE "-Wuseless-cast")
endif()
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions src/ftxui/component/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class ContainerBase : public ComponentBase {
return;
}
for (size_t offset = 1; offset < children_.size(); ++offset) {
const size_t i = ((size_t(*selector_ + offset * dir + children_.size())) %
children_.size());
const size_t i =
(*selector_ + offset * dir + children_.size()) % children_.size();
if (children_[i]->Focusable()) {
*selector_ = int(i);
return;
Expand Down
6 changes: 3 additions & 3 deletions src/ftxui/component/terminal_input_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ TerminalInputParser::Output TerminalInputParser::Parse() {
// Then some sequences are illegal if it exist a shorter representation of the
// same codepoint.
TerminalInputParser::Output TerminalInputParser::ParseUTF8() {
auto head = static_cast<unsigned char>(Current());
auto head = Current();
unsigned char selector = 0b1000'0000; // NOLINT

// The non code-point part of the first byte.
Expand Down Expand Up @@ -234,7 +234,7 @@ TerminalInputParser::Output TerminalInputParser::ParseUTF8() {
}

// Invalid continuation byte.
head = static_cast<unsigned char>(Current());
head = Current();
if ((head & 0b1100'0000) != 0b1000'0000) { // NOLINT
return DROP;
}
Expand Down Expand Up @@ -322,7 +322,7 @@ TerminalInputParser::Output TerminalInputParser::ParseCSI() {

if (Current() >= '0' && Current() <= '9') {
argument *= 10; // NOLINT
argument += int(Current() - '0');
argument += Current() - '0';
continue;
}

Expand Down

0 comments on commit eb9a701

Please sign in to comment.