From 32d8851ddee375050d68c88d4f03227d17613609 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 29 Jul 2016 16:02:31 +0300 Subject: [PATCH] -Wnon-virtual-dtor -Woverloaded-virtual -Wsign-promo --- libuavcan/CMakeLists.txt | 3 ++- libuavcan/test/node/service_client.cpp | 2 +- libuavcan/test/node/test_node.hpp | 10 +++++----- .../protocol/dynamic_node_id_server/event_tracer.hpp | 4 ++-- libuavcan/test/transport/can/can.hpp | 1 + libuavcan/test/transport/transfer_test_helpers.hpp | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libuavcan/CMakeLists.txt b/libuavcan/CMakeLists.txt index 62e80ad122..2a14b91b9d 100644 --- a/libuavcan/CMakeLists.txt +++ b/libuavcan/CMakeLists.txt @@ -123,7 +123,8 @@ if (DEBUG_BUILD) 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} -Wdouble-promotion -Wswitch-enum -Wtype-limits -Wno-error=array-bounds") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wzero-as-null-pointer-constant -Wnon-virtual-dtor -Woverloaded-virtual") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-promo") set(cpp03_flags "-std=c++03 -Wno-variadic-macros -Wno-long-long -Wno-zero-as-null-pointer-constant") set(optim_flags "-O3 -DNDEBUG -g0") else () diff --git a/libuavcan/test/node/service_client.cpp b/libuavcan/test/node/service_client.cpp index 4c08c0f8a9..9d8d169e91 100644 --- a/libuavcan/test/node/service_client.cpp +++ b/libuavcan/test/node/service_client.cpp @@ -43,7 +43,7 @@ struct ServiceCallResultHandler } else { - std::cout << "MISMATCH: status=" << last_status << ", last_server_node_id=" + std::cout << "MISMATCH: status=" << int(last_status) << ", last_server_node_id=" << int(last_server_node_id.get()) << ", last response:\n" << last_response << std::endl; return false; } diff --git a/libuavcan/test/node/test_node.hpp b/libuavcan/test/node/test_node.hpp index 867e3799d9..889b9d928b 100644 --- a/libuavcan/test/node/test_node.hpp +++ b/libuavcan/test/node/test_node.hpp @@ -73,11 +73,11 @@ struct PairableCanDriver : public uavcan::ICanDriver, public uavcan::ICanIface virtual uavcan::ICanIface* getIface(uavcan::uint8_t iface_index) { - if (iface_index == 0) - { - return this; - } - return UAVCAN_NULLPTR; + return (iface_index == 0) ? this : UAVCAN_NULLPTR; + } + virtual const uavcan::ICanIface* getIface(uavcan::uint8_t iface_index) const + { + return (iface_index == 0) ? this : UAVCAN_NULLPTR; } virtual uavcan::uint8_t getNumIfaces() const { return 1; } diff --git a/libuavcan/test/protocol/dynamic_node_id_server/event_tracer.hpp b/libuavcan/test/protocol/dynamic_node_id_server/event_tracer.hpp index 790165fbcb..b2c30ce6ab 100644 --- a/libuavcan/test/protocol/dynamic_node_id_server/event_tracer.hpp +++ b/libuavcan/test/protocol/dynamic_node_id_server/event_tracer.hpp @@ -43,7 +43,7 @@ public: { const uavcan::MonotonicDuration ts = SystemClockDriver().getMonotonic() - startup_ts_; std::cout << "EVENT [" << id_ << "]\t" << ts.toString() << "\t" - << code << "\t" << getEventName(code) << "\t" << argument << std::endl; + << int(code) << "\t" << getEventName(code) << "\t" << argument << std::endl; event_log_.push_back(EventLogEntry(code, argument)); } @@ -67,7 +67,7 @@ public: } } - std::cout << "No such event in the event log, code " << code << ", log length " << event_log_.size() + std::cout << "No such event in the event log, code " << int(code) << ", log length " << event_log_.size() << std::endl; throw std::runtime_error("EventTracer::getLastEventArgumentOrFail()"); diff --git a/libuavcan/test/transport/can/can.hpp b/libuavcan/test/transport/can/can.hpp index 7e4f9a9da3..41563a1ac8 100644 --- a/libuavcan/test/transport/can/can.hpp +++ b/libuavcan/test/transport/can/can.hpp @@ -270,6 +270,7 @@ public: } virtual uavcan::ICanIface* getIface(uavcan::uint8_t iface_index) { return &ifaces.at(iface_index); } + virtual const uavcan::ICanIface* getIface(uavcan::uint8_t iface_index) const { return &ifaces.at(iface_index); } virtual uavcan::uint8_t getNumIfaces() const { return uavcan::uint8_t(ifaces.size()); } }; diff --git a/libuavcan/test/transport/transfer_test_helpers.hpp b/libuavcan/test/transport/transfer_test_helpers.hpp index 6f5fec2ec8..14d6ccc8b1 100644 --- a/libuavcan/test/transport/transfer_test_helpers.hpp +++ b/libuavcan/test/transport/transfer_test_helpers.hpp @@ -102,7 +102,7 @@ struct Transfer os << "ts_m=" << ts_monotonic << " ts_utc=" << ts_utc << " prio=" << int(priority.get()) - << " tt=" << transfer_type + << " tt=" << int(transfer_type) << " tid=" << int(transfer_id.get()) << " snid=" << int(src_node_id.get()) << " dnid=" << int(dst_node_id.get())