Skip to content

Commit

Permalink
Merge pull request #23 from eckel-formlabs/FE-10541/task/fix-warnings
Browse files Browse the repository at this point in the history
🚑 Fix -Wzero-as-null-pointer-constant warning
  • Loading branch information
eckel-formlabs authored Aug 21, 2020
2 parents 0d3adf3 + ea06174 commit c31adc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libuavcan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ if (DEBUG_BUILD)
if (COMPILER_IS_GCC_COMPATIBLE)
# No such thing as too many warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic -Wfloat-equal -Wconversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion -Wcast-align -Wmissing-declarations -Wlogical-op")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-conversion -Wcast-align -Wmissing-declarations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdouble-promotion -Wswitch-enum -Wtype-limits -Wno-error=array-bounds")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wsign-promo -Wold-style-cast")
Expand All @@ -155,6 +155,7 @@ if (DEBUG_BUILD)
message(STATUS "Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
message(FATAL_ERROR "This compiler cannot be used to build tests; use release build instead.")
endif ()
add_compile_options($<$<CXX_COMPILER_ID:GNU>:-Wlogical-op>)

# Additional flavours of the library

Expand Down
2 changes: 1 addition & 1 deletion libuavcan/src/transport/uc_transfer_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int TransferSender::send(const uint8_t* payload, unsigned payload_len, Monotonic
TransferCRC crc = crc_base_;
crc.add(payload, payload_len);

static const int BUFLEN = sizeof(static_cast<CanFrame*>(0)->data);
static const int BUFLEN = sizeof(static_cast<CanFrame*>(nullptr)->data);
uint8_t buf[BUFLEN];

buf[0] = uint8_t(crc.get() & 0xFFU); // Transfer CRC, little endian
Expand Down

0 comments on commit c31adc8

Please sign in to comment.