From 7747851ca010a3dfe9ffee808376dd5a7af68b91 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 23 May 2017 23:59:27 +0200 Subject: Static code review fixes. Several style errors and mistakes mostly on constructor and passing arguments as ref. Change-Id: I2ca921d6aa70b9074392bb7779ade35bebf7bd8d Signed-off-by: Romain Forlot --- CAN-binder/low-can-binding/can/can-bus.hpp | 2 +- CAN-binder/low-can-binding/can/can-decoder.cpp | 16 ++++++++-------- CAN-binder/low-can-binding/can/can-decoder.hpp | 14 +++++++------- CAN-binder/low-can-binding/can/can-message-set.cpp | 2 +- CAN-binder/low-can-binding/can/can-message-set.hpp | 2 +- CAN-binder/low-can-binding/can/can-message.cpp | 2 +- CAN-binder/low-can-binding/can/can-message.hpp | 2 +- CAN-binder/low-can-binding/can/can-signals.hpp | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) (limited to 'CAN-binder/low-can-binding/can') diff --git a/CAN-binder/low-can-binding/can/can-bus.hpp b/CAN-binder/low-can-binding/can/can-bus.hpp index 1efd204..16d8cf6 100644 --- a/CAN-binder/low-can-binding/can/can-bus.hpp +++ b/CAN-binder/low-can-binding/can/can-bus.hpp @@ -71,7 +71,7 @@ private: std::vector > can_devices_; public: - can_bus_t(utils::config_parser_t conf_file); + explicit can_bus_t(utils::config_parser_t conf_file); can_bus_t(can_bus_t&&); void set_can_devices(); diff --git a/CAN-binder/low-can-binding/can/can-decoder.cpp b/CAN-binder/low-can-binding/can/can-decoder.cpp index aa1f57e..3e21397 100644 --- a/CAN-binder/low-can-binding/can/can-decoder.cpp +++ b/CAN-binder/low-can-binding/can/can-decoder.cpp @@ -54,7 +54,7 @@ float decoder_t::parseSignalBitfield(can_signal_t& signal, const can_message_t& /// always succeeds. /// openxc_DynamicField decoder_t::noopDecoder(can_signal_t& signal, - const std::vector > signals, float value, bool* send) + const std::vector >& signals, float value, bool* send) { openxc_DynamicField decoded_value = build_DynamicField(value); @@ -76,7 +76,7 @@ openxc_DynamicField decoder_t::noopDecoder(can_signal_t& signal, /// decoder always succeeds. /// openxc_DynamicField decoder_t::booleanDecoder(can_signal_t& signal, - const std::vector > signals, float value, bool* send) + const std::vector >& signals, float value, bool* send) { openxc_DynamicField decoded_value = build_DynamicField(value == 0.0 ? false : true); @@ -98,7 +98,7 @@ openxc_DynamicField decoder_t::booleanDecoder(can_signal_t& signal, /// @return Return value is undefined. /// openxc_DynamicField decoder_t::ignoreDecoder(can_signal_t& signal, - const std::vector > signals, float value, bool* send) + const std::vector >& signals, float value, bool* send) { if(send) *send = false; @@ -125,7 +125,7 @@ openxc_DynamicField decoder_t::ignoreDecoder(can_signal_t& signal, /// return value is undefined. /// openxc_DynamicField decoder_t::stateDecoder(can_signal_t& signal, - const std::vector > signals, float value, bool* send) + const std::vector >& signals, float value, bool* send) { const std::string signal_state = signal.get_states((uint8_t)value); openxc_DynamicField decoded_value = build_DynamicField(signal_state); @@ -154,7 +154,7 @@ openxc_DynamicField decoder_t::stateDecoder(can_signal_t& signal, /// string or boolean. /// openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_message_t& message, - const std::vector > signals, bool* send) + const std::vector >& signals, bool* send) { float value = decoder_t::parseSignalBitfield(signal, message); DEBUG(binder_interface, "%s: Decoded message from parseSignalBitfield: %f", __FUNCTION__, value); @@ -167,7 +167,7 @@ openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_m signal.set_received(true); // Don't send if they is no changes - if ((signal.get_last_value() == value && !signal.get_send_same()) || !send ) + if ((signal.get_last_value() == value && !signal.get_send_same()) || !*send ) { *send = false; } @@ -193,7 +193,7 @@ openxc_DynamicField decoder_t::translateSignal(can_signal_t& signal, const can_m /// string or boolean. If 'send' is false, the return value is undefined. /// openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal, - float value, const std::vector > signals, bool* send) + float value, const std::vector >& signals, bool* send) { SignalDecoder decoder = signal.get_decoder() == nullptr ? noopDecoder : signal.get_decoder(); @@ -216,7 +216,7 @@ openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal, /// not be decoded. /// openxc_DynamicField decoder_t::decodeSignal( can_signal_t& signal, - const can_message_t& message, const std::vector > signals, bool* send) + const can_message_t& message, const std::vector >& signals, bool* send) { float value = parseSignalBitfield(signal, message); return decodeSignal(signal, value, signals, send); diff --git a/CAN-binder/low-can-binding/can/can-decoder.hpp b/CAN-binder/low-can-binding/can/can-decoder.hpp index 238bfea..7eaa4a7 100644 --- a/CAN-binder/low-can-binding/can/can-decoder.hpp +++ b/CAN-binder/low-can-binding/can/can-decoder.hpp @@ -26,23 +26,23 @@ class decoder_t public: static float parseSignalBitfield(can_signal_t& signal, const can_message_t& message); - static openxc_DynamicField stateDecoder(can_signal_t& signal, const std::vector > signals, + static openxc_DynamicField stateDecoder(can_signal_t& signal, const std::vector >& signals, float value, bool* send); - static openxc_DynamicField booleanDecoder(can_signal_t& signal, const std::vector > signals, + static openxc_DynamicField booleanDecoder(can_signal_t& signal, const std::vector >& signals, float value, bool* send); - static openxc_DynamicField ignoreDecoder(can_signal_t& signal, const std::vector > signals, + static openxc_DynamicField ignoreDecoder(can_signal_t& signal, const std::vector >& signals, float value, bool* send); - static openxc_DynamicField noopDecoder(can_signal_t& signal, const std::vector > signals, + static openxc_DynamicField noopDecoder(can_signal_t& signal, const std::vector >& signals, float value, bool* send); static openxc_DynamicField translateSignal(can_signal_t& signal, const can_message_t& message, - const std::vector > signals, bool* send); + const std::vector >& signals, bool* send); static openxc_DynamicField decodeSignal(can_signal_t& signal, const can_message_t& message, - const std::vector > signals, bool* send); + const std::vector >& signals, bool* send); static openxc_DynamicField decodeSignal(can_signal_t& signal, float value, - const std::vector > signals, bool* send); + const std::vector >& signals, bool* send); static float decode_obd2_response(const DiagnosticResponse* response, float parsed_payload); diff --git a/CAN-binder/low-can-binding/can/can-message-set.cpp b/CAN-binder/low-can-binding/can/can-message-set.cpp index 5b3a220..a41f008 100644 --- a/CAN-binder/low-can-binding/can/can-message-set.cpp +++ b/CAN-binder/low-can-binding/can/can-message-set.cpp @@ -22,7 +22,7 @@ can_message_set_t::can_message_set_t( uint8_t index, - const std::string name, + const std::string& name, const std::vector >& can_messages_definition, const std::vector >& diagnostic_messages) : index_{index} diff --git a/CAN-binder/low-can-binding/can/can-message-set.hpp b/CAN-binder/low-can-binding/can/can-message-set.hpp index ca01abc..c763de6 100644 --- a/CAN-binder/low-can-binding/can/can-message-set.hpp +++ b/CAN-binder/low-can-binding/can/can-message-set.hpp @@ -40,7 +40,7 @@ private: public: can_message_set_t( uint8_t index, - const std::string name, + const std::string& name, const std::vector >& can_messages_definition, const std::vector >& diagnostic_messages); diff --git a/CAN-binder/low-can-binding/can/can-message.cpp b/CAN-binder/low-can-binding/can/can-message.cpp index 772734d..abfbfdb 100644 --- a/CAN-binder/low-can-binding/can/can-message.cpp +++ b/CAN-binder/low-can-binding/can/can-message.cpp @@ -36,7 +36,7 @@ can_message_t::can_message_t(uint8_t maxdlen, can_message_format_t format, bool rtr_flag, uint8_t flags, - std::vector data, + std::vector& data, uint64_t timestamp) : maxdlen_{maxdlen}, id_{id}, diff --git a/CAN-binder/low-can-binding/can/can-message.hpp b/CAN-binder/low-can-binding/can/can-message.hpp index 910b3e9..1ce1c7a 100644 --- a/CAN-binder/low-can-binding/can/can-message.hpp +++ b/CAN-binder/low-can-binding/can/can-message.hpp @@ -55,7 +55,7 @@ private: public: can_message_t(); - can_message_t(uint8_t maxdlen, uint32_t id, uint8_t length, can_message_format_t format, bool rtr_flag_, uint8_t flags, std::vector data, uint64_t timestamp); + can_message_t(uint8_t maxdlen, uint32_t id, uint8_t length, can_message_format_t format, bool rtr_flag_, uint8_t flags, std::vector& data, uint64_t timestamp); uint32_t get_id() const; bool get_rtr_flag_() const; diff --git a/CAN-binder/low-can-binding/can/can-signals.hpp b/CAN-binder/low-can-binding/can/can-signals.hpp index cc4b6da..b8fbe4e 100644 --- a/CAN-binder/low-can-binding/can/can-signals.hpp +++ b/CAN-binder/low-can-binding/can/can-signals.hpp @@ -56,7 +56,7 @@ class can_signal_t; /// @return a decoded value in an openxc_DynamicField struct. /// typedef openxc_DynamicField (*SignalDecoder)(can_signal_t& signal, - const std::vector > signals, float value, bool* send); + const std::vector >& signals, float value, bool* send); /// /// @brief: The type signature for a CAN signal encoder. -- cgit 1.2.3-korg