diff --git a/.codespellignore b/.codespellignore index b9de5c1ca4..c3ce07428f 100644 --- a/.codespellignore +++ b/.codespellignore @@ -166,3 +166,6 @@ function ok(a,b){for(var c=a.wa[b].data.items,d=c.length,g=N(a.wa[b].id),h="",i= UIntValidator(0, UINT_MAX), // On win32 TRUE and FALSE are #define'd. We can #undef them here but that * A #define'd value HAVE_LIBLO which lets us know within the code if the OSC +import java.nio.ByteOrder; + byte[] header = ByteBuffer.allocate(4).order(ByteOrder.nativeOrder()).putInt(headerContent).array(); + int headerValue = ByteBuffer.wrap(header).order(ByteOrder.nativeOrder()).getInt(); diff --git a/.travis.yml b/.travis.yml index a2ba47de68..f4a479469d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -271,6 +271,7 @@ cache: - $HOME/.cache/pip # pip cache - $HOME/.npm # npm cache - $HOME/.ccache # ccache cache + - $HOME/.m2 # maven cache before_cache: - rm -f $HOME/.cache/pip/log/debug.log # erase log diff --git a/common/base/Flags.cpp b/common/base/Flags.cpp index 7427d41532..201a87ce1b 100644 --- a/common/base/Flags.cpp +++ b/common/base/Flags.cpp @@ -358,8 +358,15 @@ void FlagRegistry::GenManPage() { str << " <" << flag->arg_type() << ">"; } if (flag->short_opt()) { - short_flag_lines.push_back( - OptionPair(str.str(), iter->second->help())); + if (flag->name() == FLAGS_version.name()) { + std::ostringstream help_str; + help_str << "Print\n.B " << exe_name << "\nversion information."; + short_flag_lines.push_back( + OptionPair(str.str(), help_str.str())); + } else { + short_flag_lines.push_back( + OptionPair(str.str(), iter->second->help())); + } } else { long_flag_lines.push_back( OptionPair(str.str(), iter->second->help())); diff --git a/common/network/AdvancedTCPConnectorTest.cpp b/common/network/AdvancedTCPConnectorTest.cpp index 779d62b454..86637ed0a1 100644 --- a/common/network/AdvancedTCPConnectorTest.cpp +++ b/common/network/AdvancedTCPConnectorTest.cpp @@ -399,7 +399,7 @@ uint16_t AdvancedTCPConnectorTest::ReservePort() { void AdvancedTCPConnectorTest::AcceptedConnection(TCPSocket *new_socket) { OLA_ASSERT_NOT_NULL(new_socket); GenericSocketAddress address = new_socket->GetPeerAddress(); - OLA_ASSERT_TRUE(address.Family() == AF_INET); + OLA_ASSERT_EQ(address.Family(), static_cast(AF_INET)); OLA_INFO << "Connection from " << address; // terminate the ss when this connection is closed @@ -415,7 +415,7 @@ void AdvancedTCPConnectorTest::OnConnect(TCPSocket *socket) { OLA_ASSERT_NOT_NULL(socket); GenericSocketAddress address = socket->GetPeerAddress(); - OLA_ASSERT_TRUE(address.Family() == AF_INET); + OLA_ASSERT_EQ(address.Family(), static_cast(AF_INET)); OLA_ASSERT_EQ(m_localhost, address.V4Addr().Host()); m_connected_socket = socket; diff --git a/common/network/Interface.cpp b/common/network/Interface.cpp index f1082d3215..cfe3eee6a8 100644 --- a/common/network/Interface.cpp +++ b/common/network/Interface.cpp @@ -117,16 +117,32 @@ Interface& Interface::operator=(const Interface &other) { } -bool Interface::operator==(const Interface &other) { +bool Interface::operator==(const Interface &other) const { return (name == other.name && ip_address == other.ip_address && + bcast_address == other.bcast_address && subnet_mask == other.subnet_mask && + hw_address == other.hw_address && loopback == other.loopback && index == other.index && type == other.type); } +string Interface::ToString(const string &separator) const { + std::ostringstream str; + str << name << separator + << "Index: " << index << separator + << "IP: " << ip_address << separator + << "Broadcast: " << bcast_address << separator + << "Subnet: " << subnet_mask << separator + << "Type: " << type << separator + << "MAC: " << hw_address << separator + << "Loopback: " << loopback; + return str.str(); +} + + /** * Create a new interface builder */ @@ -228,8 +244,9 @@ Interface InterfaceBuilder::Construct() { bool InterfaceBuilder::SetAddress(const string &str, IPV4Address *target) { IPV4Address tmp_address; - if (!IPV4Address::FromString(str, &tmp_address)) + if (!IPV4Address::FromString(str, &tmp_address)) { return false; + } *target = tmp_address; return true; } diff --git a/common/network/InterfacePicker.cpp b/common/network/InterfacePicker.cpp index 8f88397e0d..ba796508ae 100644 --- a/common/network/InterfacePicker.cpp +++ b/common/network/InterfacePicker.cpp @@ -44,7 +44,7 @@ using std::vector; * @param iface, the interface to populate * @param ip_or_name the IP address or interface name of the local interface * we'd prefer to use. - * @param options a Options struct configuring ChooseInterface + * @param options an Options struct configuring ChooseInterface * @return true if we found an interface, false otherwise */ // TODO(Simon): Change these to callback based code to reduce duplication. @@ -84,13 +84,15 @@ bool InterfacePicker::ChooseInterface( } } - if (!found && options.specific_only) + if (!found && options.specific_only) { return false; // No match and being fussy + } - if (!found) + if (!found) { *iface = interfaces[0]; - OLA_DEBUG << "Using interface " << iface->name << " (" << - iface->ip_address << ")"; + } + OLA_DEBUG << "Using interface " << iface->name << " (" + << iface->ip_address << ")"; return true; } @@ -99,7 +101,7 @@ bool InterfacePicker::ChooseInterface( * Select an interface to use by index * @param iface, the interface to populate * @param index the index of the local interface we'd prefer to use. - * @param options a Options struct configuring ChooseInterface + * @param options an Options struct configuring ChooseInterface * @return true if we found an interface, false otherwise */ // TODO(Simon): Change these to callback based code to reduce duplication. @@ -125,13 +127,15 @@ bool InterfacePicker::ChooseInterface( } } - if (!found && options.specific_only) + if (!found && options.specific_only) { return false; // No match and being fussy + } - if (!found) + if (!found) { *iface = interfaces[0]; - OLA_DEBUG << "Using interface " << iface->name << " (" << - iface->ip_address << ") with index " << iface->index; + } + OLA_DEBUG << "Using interface " << iface->name << " (" + << iface->ip_address << ") with index " << iface->index; return true; } diff --git a/common/network/InterfacePickerTest.cpp b/common/network/InterfacePickerTest.cpp index 3514aaf519..d122332414 100644 --- a/common/network/InterfacePickerTest.cpp +++ b/common/network/InterfacePickerTest.cpp @@ -75,13 +75,7 @@ void InterfacePickerTest::testGetInterfaces() { vector::iterator iter; cout << endl; for (iter = interfaces.begin(); iter != interfaces.end(); ++iter) { - cout << iter->name << endl; - cout << " index: " << iter->index << endl; - cout << " ip: " << iter->ip_address << endl; - cout << " bcast: " << iter->bcast_address << endl; - cout << " subnet: " << iter->subnet_mask << endl; - cout << " type: " << iter->type << endl; - cout << " hw_addr: " << iter->hw_address << endl; + cout << iter->ToString("\n ") << endl; cout << endl; cout << "---------------" << endl; } @@ -133,7 +127,7 @@ void InterfacePickerTest::testChooseInterface() { FakeInterfacePicker picker2(interfaces); OLA_ASSERT_TRUE(picker2.ChooseInterface(&iface, "192.168.1.1")); - OLA_ASSERT_TRUE(iface1 == iface); + OLA_ASSERT_EQ(iface1, iface); // check that preferred works Interface iface2; @@ -144,24 +138,24 @@ void InterfacePickerTest::testChooseInterface() { FakeInterfacePicker picker3(interfaces); OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, "192.168.1.1")); - OLA_ASSERT_TRUE(iface2 == iface); + OLA_ASSERT_EQ(iface2, iface); // now check for iface name OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, "eth0")); - OLA_ASSERT_TRUE(iface1 == iface); + OLA_ASSERT_EQ(iface1, iface); OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, "eth1")); - OLA_ASSERT_TRUE(iface2 == iface); + OLA_ASSERT_EQ(iface2, iface); // a invalid address should return the first one OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, "foo")); - OLA_ASSERT_TRUE(iface1 == iface); + OLA_ASSERT_EQ(iface1, iface); // now check by iface index OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, 2)); - OLA_ASSERT_TRUE(iface2 == iface); + OLA_ASSERT_EQ(iface2, iface); // an invalid index should return the first one OLA_ASSERT_TRUE(picker3.ChooseInterface(&iface, 3)); - OLA_ASSERT_TRUE(iface1 == iface); + OLA_ASSERT_EQ(iface1, iface); } diff --git a/common/network/InterfaceTest.cpp b/common/network/InterfaceTest.cpp index 612b016d34..bfc9bb9ca5 100644 --- a/common/network/InterfaceTest.cpp +++ b/common/network/InterfaceTest.cpp @@ -112,7 +112,7 @@ void InterfaceTest::testBuilder() { // now build from IPV4Address and MACAddress objects IPV4Address ip_address, netmask, broadcast_address; IPV4Address::FromString("10.0.0.1", &ip_address); - IPV4Address::FromString("10.0.255.255", &netmask); + IPV4Address::FromString("255.255.0.0", &netmask); IPV4Address::FromString("10.0.255.255", &broadcast_address); MACAddress mac_address; MACAddress::FromString("ba:98:76:54:32:10", &mac_address); @@ -129,4 +129,20 @@ void InterfaceTest::testBuilder() { OLA_ASSERT_EQ(broadcast_address, interface.bcast_address); OLA_ASSERT_EQ(netmask, interface.subnet_mask); OLA_ASSERT_EQ(mac_address, interface.hw_address); + + // test stringification + OLA_ASSERT_EQ(string("eth1, Index: -1, IP: 10.0.0.1, Broadcast: " + "10.0.255.255, Subnet: 255.255.0.0, Type: 65535, MAC: " + "ba:98:76:54:32:10, Loopback: 0"), + interface.ToString()); + OLA_ASSERT_EQ(string("eth1|Index: -1|IP: 10.0.0.1|Broadcast: 10.0.255.255|" + "Subnet: 255.255.0.0|Type: 65535|MAC: " + "ba:98:76:54:32:10|Loopback: 0"), + interface.ToString("|")); + std::ostringstream str; + str << interface; + OLA_ASSERT_EQ(string("eth1, Index: -1, IP: 10.0.0.1, Broadcast: " + "10.0.255.255, Subnet: 255.255.0.0, Type: 65535, MAC: " + "ba:98:76:54:32:10, Loopback: 0"), + str.str()); } diff --git a/common/network/SocketTest.cpp b/common/network/SocketTest.cpp index f26f0eb44e..b2f42e1cc9 100644 --- a/common/network/SocketTest.cpp +++ b/common/network/SocketTest.cpp @@ -343,7 +343,7 @@ void SocketTest::ReceiveSendAndClose(ConnectedDescriptor *socket) { void SocketTest::NewConnectionSend(TCPSocket *new_socket) { OLA_ASSERT_TRUE(new_socket); GenericSocketAddress address = new_socket->GetPeerAddress(); - OLA_ASSERT_TRUE(address.Family() == AF_INET); + OLA_ASSERT_EQ(address.Family(), static_cast(AF_INET)); OLA_INFO << "Connection from " << address; ssize_t bytes_sent = new_socket->Send( static_cast(test_cstring), @@ -361,7 +361,7 @@ void SocketTest::NewConnectionSend(TCPSocket *new_socket) { void SocketTest::NewConnectionSendAndClose(TCPSocket *new_socket) { OLA_ASSERT_NOT_NULL(new_socket); GenericSocketAddress address = new_socket->GetPeerAddress(); - OLA_ASSERT_TRUE(address.Family() == AF_INET); + OLA_ASSERT_EQ(address.Family(), static_cast(AF_INET)); OLA_INFO << "Connection from " << address; ssize_t bytes_sent = new_socket->Send( static_cast(test_cstring), diff --git a/common/network/TCPConnectorTest.cpp b/common/network/TCPConnectorTest.cpp index 694a27291f..7086901363 100644 --- a/common/network/TCPConnectorTest.cpp +++ b/common/network/TCPConnectorTest.cpp @@ -279,7 +279,7 @@ void TCPConnectorTest::testEarlyDestruction() { void TCPConnectorTest::AcceptedConnection(TCPSocket *new_socket) { OLA_ASSERT_NOT_NULL(new_socket); GenericSocketAddress address = new_socket->GetPeerAddress(); - OLA_ASSERT_TRUE(address.Family() == AF_INET); + OLA_ASSERT_EQ(address.Family(), static_cast(AF_INET)); OLA_INFO << "Connection from " << address; // terminate the ss when this connection is closed diff --git a/data/rdm/manufacturer_pids.proto b/data/rdm/manufacturer_pids.proto index 0fe828856c..b9169a2ab8 100644 --- a/data/rdm/manufacturer_pids.proto +++ b/data/rdm/manufacturer_pids.proto @@ -3556,7 +3556,7 @@ manufacturer { set_sub_device_range: ROOT_DEVICE } pid { - name: "LIGHTSENSOR_LEVEL_TRIGGER_ENABLE" + name: "LIGHT_SENSOR_LEVEL_TRIGGER_ENABLE" value: 33032 get_request { } @@ -3578,7 +3578,7 @@ manufacturer { set_sub_device_range: ROOT_DEVICE } pid { - name: "CAPTURE_CURRENT_SENSOR_VALUE" + name: "CAPTURE_CURRENT_LIGHT_LEVEL" value: 33033 set_request { } @@ -3587,7 +3587,7 @@ manufacturer { set_sub_device_range: ROOT_DEVICE } pid { - name: "LIGHTSENSOR_TRIGGER_LEVEL" + name: "LIGHT_SENSOR_TRIGGER_LEVEL" value: 33034 get_request { } diff --git a/include/ola/network/IPV4Address.h b/include/ola/network/IPV4Address.h index 0f0db5a2d4..06857af6f8 100644 --- a/include/ola/network/IPV4Address.h +++ b/include/ola/network/IPV4Address.h @@ -139,8 +139,8 @@ class IPV4Address { * should be at least LENGTH bytes. * @note The address is copied in network byte order. */ - void Get(uint8_t ptr[LENGTH]) { - memcpy(ptr, reinterpret_cast(&m_address), LENGTH); + void Get(uint8_t ptr[LENGTH]) const { + memcpy(ptr, reinterpret_cast(&m_address), LENGTH); } /** @@ -153,7 +153,7 @@ class IPV4Address { * @brief Write the string representation of this IPV4Address to an * ostream. * @param out the ostream to write to. - * @param address to address to write. + * @param address the address to write. */ friend std::ostream& operator<<(std::ostream &out, const IPV4Address &address) { diff --git a/include/ola/network/Interface.h b/include/ola/network/Interface.h index bc36ceda1f..b51e046834 100644 --- a/include/ola/network/Interface.h +++ b/include/ola/network/Interface.h @@ -47,7 +47,25 @@ class Interface { uint16_t type = ARP_VOID_TYPE); Interface(const Interface &other); Interface& operator=(const Interface &other); - bool operator==(const Interface &other); + bool operator==(const Interface &other) const; + + /** + * @brief Convert the Interface to a string. + * @param separator the separator to use between items, defaults to ", ". + * @returns the string representation of this Interface. + */ + std::string ToString(const std::string &separator = ", ") const; + + /** + * @brief Write the string representation of this Interface to an + * ostream. + * @param out the ostream to write to. + * @param iface the iface to write. + */ + friend std::ostream& operator<<(std::ostream &out, + const Interface &iface) { + return out << iface.ToString(); + } std::string name; IPV4Address ip_address; diff --git a/include/ola/testing/TestUtils.h b/include/ola/testing/TestUtils.h index dac3993db0..9082e14b3d 100644 --- a/include/ola/testing/TestUtils.h +++ b/include/ola/testing/TestUtils.h @@ -168,7 +168,7 @@ inline void _FailIf(const SourceLine &source_line, ola::testing::ASSERT_DATA_EQUALS(OLA_SOURCELINE(), \ (expected.GetRaw()), (expected.Size()), \ (actual.GetRaw()), (actual.Size())); \ - OLA_ASSERT_TRUE(expected == actual) + OLA_ASSERT_EQ(expected, actual) #define OLA_ASSERT_NULL(value) \ CPPUNIT_NS::Asserter::failIf( \ diff --git a/include/olad/PluginAdaptor.h b/include/olad/PluginAdaptor.h index 59afbab380..222a56d157 100644 --- a/include/olad/PluginAdaptor.h +++ b/include/olad/PluginAdaptor.h @@ -96,7 +96,7 @@ class PluginAdaptor: public ola::io::SelectServerInterface { * @brief Return the instance name for the OLA server * @return a string which is the instance name */ - const std::string InstanceName(); + const std::string InstanceName() const; ExportMap *GetExportMap() const { return m_export_map; diff --git a/libs/acn/E131Node.cpp b/libs/acn/E131Node.cpp index a921962ca8..58e8f5578f 100644 --- a/libs/acn/E131Node.cpp +++ b/libs/acn/E131Node.cpp @@ -171,12 +171,14 @@ bool E131Node::Start() { return false; } - if (!m_socket.Bind( - IPV4SocketAddress(IPV4Address::WildCard(), m_options.port))) + if (!m_socket.Bind(IPV4SocketAddress(IPV4Address::WildCard(), + m_options.port))) { return false; + } - if (!m_socket.EnableBroadcast()) + if (!m_socket.EnableBroadcast()) { return false; + } m_socket.SetTos(m_options.dscp); m_socket.SetMulticastInterface(m_interface.ip_address); diff --git a/libs/acn/e131_loadtest.cpp b/libs/acn/e131_loadtest.cpp index db9f442061..abd329923c 100644 --- a/libs/acn/e131_loadtest.cpp +++ b/libs/acn/e131_loadtest.cpp @@ -52,8 +52,9 @@ bool SendFrames(E131Node *node, DmxBuffer *buffer, int main(int argc, char* argv[]) { ola::AppInit(&argc, argv, "", "Run the E1.31 load test."); - if (FLAGS_universes == 0 || FLAGS_fps == 0) + if (FLAGS_universes == 0 || FLAGS_fps == 0) { return -1; + } unsigned int fps = min(40u, static_cast(FLAGS_fps)); uint16_t universes = FLAGS_universes; @@ -63,8 +64,9 @@ int main(int argc, char* argv[]) { SelectServer ss; E131Node node(&ss, "", E131Node::Options()); - if (!node.Start()) + if (!node.Start()) { return -1; + } ss.AddReadDescriptor(node.GetSocket()); ss.RegisterRepeatingTimeout( diff --git a/olad/plugin_api/PluginAdaptor.cpp b/olad/plugin_api/PluginAdaptor.cpp index 0278825c16..da50565cf9 100644 --- a/olad/plugin_api/PluginAdaptor.cpp +++ b/olad/plugin_api/PluginAdaptor.cpp @@ -129,7 +129,7 @@ const TimeStamp *PluginAdaptor::WakeUpTime() const { return m_ss->WakeUpTime(); } -const std::string PluginAdaptor::InstanceName() { +const std::string PluginAdaptor::InstanceName() const { if (m_instance_name) { return *m_instance_name; } else { diff --git a/olad/plugin_api/Preferences.cpp b/olad/plugin_api/Preferences.cpp index 0797f76f7f..a2378f0a3d 100644 --- a/olad/plugin_api/Preferences.cpp +++ b/olad/plugin_api/Preferences.cpp @@ -306,8 +306,9 @@ string MemoryPreferences::GetValue(const string &key) const { PreferencesMap::const_iterator iter; iter = m_pref_map.find(key); - if (iter != m_pref_map.end()) + if (iter != m_pref_map.end()) { return iter->second; + } return ""; } @@ -338,16 +339,15 @@ bool MemoryPreferences::GetValueAsBool(const string &key) const { PreferencesMap::const_iterator iter; iter = m_pref_map.find(key); - if (iter != m_pref_map.end()) + if (iter != m_pref_map.end()) { return iter->second == BoolValidator::ENABLED; + } return false; } void MemoryPreferences::SetValueAsBool(const string &key, bool value) { - m_pref_map.erase(key); - m_pref_map.insert(make_pair(key, (value ? BoolValidator::ENABLED : - BoolValidator::DISABLED))); + SetValue(key, (value ? BoolValidator::ENABLED : BoolValidator::DISABLED)); } diff --git a/plugins/espnet/EspNetNode.cpp b/plugins/espnet/EspNetNode.cpp index 35a791f837..1f4df9966d 100644 --- a/plugins/espnet/EspNetNode.cpp +++ b/plugins/espnet/EspNetNode.cpp @@ -80,8 +80,9 @@ EspNetNode::~EspNetNode() { * Start this node */ bool EspNetNode::Start() { - if (m_running) + if (m_running) { return false; + } ola::network::InterfacePicker *picker = ola::network::InterfacePicker::NewPicker(); @@ -93,8 +94,9 @@ bool EspNetNode::Start() { } delete picker; - if (!InitNetwork()) + if (!InitNetwork()) { return false; + } m_running = true; return true; @@ -105,8 +107,9 @@ bool EspNetNode::Start() { * Stop this node */ bool EspNetNode::Stop() { - if (!m_running) + if (!m_running) { return false; + } m_running = false; return true; @@ -124,8 +127,9 @@ void EspNetNode::SocketReady() { ssize_t packet_size = sizeof(packet); if (!m_socket.RecvFrom(reinterpret_cast(&packet), &packet_size, - &source)) + &source)) { return; + } if (packet_size < (ssize_t) sizeof(packet.poll.head)) { OLA_WARN << "Small espnet packet received, discarding"; @@ -165,8 +169,9 @@ void EspNetNode::SocketReady() { bool EspNetNode::SetHandler(uint8_t universe, DmxBuffer *buffer, Callback0 *closure) { - if (!closure) + if (!closure) { return false; + } map::iterator iter = m_handlers.find(universe); @@ -192,7 +197,7 @@ bool EspNetNode::SetHandler(uint8_t universe, */ bool EspNetNode::RemoveHandler(uint8_t universe) { map::iterator iter = - m_handlers.find(universe); + m_handlers.find(universe); if (iter != m_handlers.end()) { Callback0 *old_closure = iter->second.closure; @@ -209,8 +214,9 @@ bool EspNetNode::RemoveHandler(uint8_t universe) { * @param full_poll */ bool EspNetNode::SendPoll(bool full_poll) { - if (!m_running) + if (!m_running) { return false; + } return SendEspPoll(m_interface.bcast_address, full_poll); } @@ -223,15 +229,16 @@ bool EspNetNode::SendPoll(bool full_poll) { * @return true if it was send successfully, false otherwise */ bool EspNetNode::SendDMX(uint8_t universe, const ola::DmxBuffer &buffer) { - if (!m_running) + if (!m_running) { return false; + } return SendEspData(m_interface.bcast_address, universe, buffer); } /* - * Setup the networking compoents. + * Setup the networking components. */ bool EspNetNode::InitNetwork() { if (!m_socket.Init()) { @@ -239,8 +246,9 @@ bool EspNetNode::InitNetwork() { return false; } - if (!m_socket.Bind(IPV4SocketAddress(IPV4Address::WildCard(), ESPNET_PORT))) + if (!m_socket.Bind(IPV4SocketAddress(IPV4Address::WildCard(), ESPNET_PORT))) { return false; + } if (!m_socket.EnableBroadcast()) { OLA_WARN << "Failed to enable broadcasting"; @@ -260,48 +268,44 @@ void EspNetNode::HandlePoll(const espnet_poll_t &poll, const IPV4Address &source) { OLA_DEBUG << "Got ESP Poll " << poll.type; if (length < (ssize_t) sizeof(espnet_poll_t)) { - OLA_DEBUG << "Poll size too small " << length << " < " << - sizeof(espnet_poll_t); + OLA_DEBUG << "Poll size too small " << length << " < " + << sizeof(espnet_poll_t); return; } - if (poll.type) + if (poll.type) { SendEspPollReply(source); - else + } else { SendEspAck(source, 0, 0); + } } /* * Handle an Esp reply packet. This does nothing at the moment. */ -void EspNetNode::HandleReply(const espnet_poll_reply_t &reply, +void EspNetNode::HandleReply(OLA_UNUSED const espnet_poll_reply_t &reply, ssize_t length, - const IPV4Address &source) { + OLA_UNUSED const IPV4Address &source) { if (length < (ssize_t) sizeof(espnet_poll_reply_t)) { - OLA_DEBUG << "Poll reply size too small " << length << " < " << - sizeof(espnet_poll_reply_t); + OLA_DEBUG << "Poll reply size too small " << length << " < " + << sizeof(espnet_poll_reply_t); return; } - (void) reply; - (void) source; } /* * Handle a Esp Ack packet */ -void EspNetNode::HandleAck(const espnet_ack_t &ack, +void EspNetNode::HandleAck(OLA_UNUSED const espnet_ack_t &ack, ssize_t length, - const IPV4Address &source) { + OLA_UNUSED const IPV4Address &source) { if (length < (ssize_t) sizeof(espnet_ack_t)) { OLA_DEBUG << "Ack size too small " << length << " < " << sizeof(espnet_ack_t); return; } - - (void) ack; - (void) source; } @@ -310,7 +314,7 @@ void EspNetNode::HandleAck(const espnet_ack_t &ack, */ void EspNetNode::HandleData(const espnet_data_t &data, ssize_t length, - const IPV4Address &source) { + OLA_UNUSED const IPV4Address &source) { static const ssize_t header_size = sizeof(espnet_data_t) - DMX_UNIVERSE_SIZE; if (length < header_size) { OLA_DEBUG << "Data size too small " << length << " < " << header_size; @@ -318,7 +322,7 @@ void EspNetNode::HandleData(const espnet_data_t &data, } map::iterator iter = - m_handlers.find(data.universe); + m_handlers.find(data.universe); if (iter == m_handlers.end()) { OLA_DEBUG << "Not interested in universe " << @@ -345,7 +349,6 @@ void EspNetNode::HandleData(const espnet_data_t &data, return; } iter->second.closure->Run(); - (void) source; } diff --git a/plugins/pathport/PathportNode.cpp b/plugins/pathport/PathportNode.cpp index cbcd6b5de5..1f1c62ed23 100644 --- a/plugins/pathport/PathportNode.cpp +++ b/plugins/pathport/PathportNode.cpp @@ -78,11 +78,12 @@ PathportNode::~PathportNode() { * Start this node */ bool PathportNode::Start() { - if (m_running) + if (m_running) { return false; + } ola::network::InterfacePicker *picker = - ola::network::InterfacePicker::NewPicker(); + ola::network::InterfacePicker::NewPicker(); if (!picker->ChooseInterface(&m_interface, m_preferred_ip)) { delete picker; OLA_INFO << "Failed to find an interface"; @@ -94,8 +95,9 @@ bool PathportNode::Start() { m_status_addr = IPV4Address(HostToNetwork(PATHPORT_STATUS_GROUP)); m_data_addr = IPV4Address(HostToNetwork(PATHPORT_DATA_GROUP)); - if (!InitNetwork()) + if (!InitNetwork()) { return false; + } m_socket.SetTos(m_dscp); m_running = true; @@ -109,8 +111,9 @@ bool PathportNode::Start() { * Stop this node */ bool PathportNode::Stop() { - if (!m_running) + if (!m_running) { return false; + } m_socket.Close(); m_running = false; @@ -131,8 +134,9 @@ void PathportNode::SocketReady(UDPSocket *socket) { return; // skip packets sent by us - if (source.Host() == m_interface.ip_address) + if (source.Host() == m_interface.ip_address) { return; + } if (packet_size < static_cast(sizeof(packet.header))) { OLA_WARN << "Small pathport packet received, discarding"; @@ -177,8 +181,8 @@ void PathportNode::SocketReady(UDPSocket *socket) { OLA_DEBUG << "Got pathport arp reply"; break; default: - OLA_INFO << "Unhandled pathport packet with id: " << - NetworkToHost(pdu->head.type); + OLA_INFO << "Unhandled pathport packet with id: " + << NetworkToHost(pdu->head.type); } } @@ -192,8 +196,9 @@ void PathportNode::SocketReady(UDPSocket *socket) { bool PathportNode::SetHandler(uint8_t universe, DmxBuffer *buffer, Callback0 *closure) { - if (!closure) + if (!closure) { return false; + } universe_handlers::iterator iter = m_handlers.find(universe); @@ -233,8 +238,9 @@ bool PathportNode::RemoveHandler(uint8_t universe) { * Send an arp reply */ bool PathportNode::SendArpReply() { - if (!m_running) + if (!m_running) { return false; + } pathport_packet_s packet; @@ -264,8 +270,9 @@ bool PathportNode::SendArpReply() { * @return true if it was send successfully, false otherwise */ bool PathportNode::SendDMX(unsigned int universe, const DmxBuffer &buffer) { - if (!m_running) + if (!m_running) { return false; + } if (universe > MAX_UNIVERSES) { OLA_WARN << "attempt to send to universe " << universe; @@ -303,7 +310,7 @@ bool PathportNode::SendDMX(unsigned int universe, const DmxBuffer &buffer) { /* - * Setup the networking compoents. + * Setup the networking components. */ bool PathportNode::InitNetwork() { if (!m_socket.Init()) { @@ -341,7 +348,7 @@ bool PathportNode::InitNetwork() { } m_socket.SetOnData( - NewCallback(this, &PathportNode::SocketReady, &m_socket)); + NewCallback(this, &PathportNode::SocketReady, &m_socket)); return true; } @@ -383,8 +390,9 @@ void PathportNode::HandleDmxData(const pathport_pdu_data &packet, } // Don't handle release messages yet - if (NetworkToHost(packet.type) != XDMX_DATA_FLAT) + if (NetworkToHost(packet.type) != XDMX_DATA_FLAT) { return; + } if (packet.start_code) { OLA_INFO << "Non-0 start code packet received, ignoring"; @@ -421,8 +429,9 @@ void PathportNode::HandleDmxData(const pathport_pdu_data &packet, * @param destination the destination to target */ bool PathportNode::SendArpRequest(uint32_t destination) { - if (!m_running) + if (!m_running) { return false; + } pathport_packet_s packet; PopulateHeader(&packet.header, destination); diff --git a/plugins/sandnet/SandNetNode.cpp b/plugins/sandnet/SandNetNode.cpp index af875760ae..bee98b7aa2 100644 --- a/plugins/sandnet/SandNetNode.cpp +++ b/plugins/sandnet/SandNetNode.cpp @@ -85,8 +85,9 @@ SandNetNode::~SandNetNode() { * Start this node */ bool SandNetNode::Start() { - if (m_running) + if (m_running) { return false; + } ola::network::InterfacePicker *picker = ola::network::InterfacePicker::NewPicker(); @@ -110,8 +111,9 @@ bool SandNetNode::Start() { } m_data_addr = IPV4SocketAddress(ip, DATA_PORT); - if (!InitNetwork()) + if (!InitNetwork()) { return false; + } m_running = true; return true; @@ -122,8 +124,9 @@ bool SandNetNode::Start() { * Stop this node */ bool SandNetNode::Stop() { - if (!m_running) + if (!m_running) { return false; + } m_data_socket.Close(); m_control_socket.Close(); @@ -153,12 +156,14 @@ void SandNetNode::SocketReady(UDPSocket *socket) { IPV4SocketAddress source; if (!socket->RecvFrom(reinterpret_cast(&packet), - &packet_size, &source)) + &packet_size, &source)) { return; + } // skip packets sent by us - if (source.Host() == m_interface.ip_address) + if (source.Host() == m_interface.ip_address) { return; + } if (packet_size < static_cast(sizeof(packet.opcode))) { OLA_WARN << "Small sandnet packet received, discarding"; @@ -191,8 +196,9 @@ void SandNetNode::SocketReady(UDPSocket *socket) { bool SandNetNode::SetHandler(uint8_t group, uint8_t universe, DmxBuffer *buffer, Callback0 *closure) { - if (!closure) + if (!closure) { return false; + } group_universe_pair key(group, universe); universe_handlers::iterator iter = m_handlers.find(key); @@ -235,8 +241,9 @@ bool SandNetNode::RemoveHandler(uint8_t group, uint8_t universe) { */ bool SandNetNode::SetPortParameters(uint8_t port_id, sandnet_port_type type, uint8_t group, uint8_t universe) { - if (port_id >= SANDNET_MAX_PORTS) + if (port_id >= SANDNET_MAX_PORTS) { return false; + } m_ports[port_id].group = group; m_ports[port_id].universe = universe; @@ -249,8 +256,9 @@ bool SandNetNode::SetPortParameters(uint8_t port_id, sandnet_port_type type, * Send a Sandnet Advertisement. */ bool SandNetNode::SendAdvertisement() { - if (!m_running) + if (!m_running) { return false; + } sandnet_packet packet; sandnet_advertisement *advertisement = &packet.contents.advertisement; @@ -294,8 +302,9 @@ bool SandNetNode::SendAdvertisement() { * @return true if it was send successfully, false otherwise */ bool SandNetNode::SendDMX(uint8_t port_id, const DmxBuffer &buffer) { - if (!m_running || port_id >= SANDNET_MAX_PORTS) + if (!m_running || port_id >= SANDNET_MAX_PORTS) { return false; + } // Sandnet doesn't seem to understand compressed DMX return SendUncompressedDMX(port_id, buffer); @@ -303,7 +312,7 @@ bool SandNetNode::SendDMX(uint8_t port_id, const DmxBuffer &buffer) { /* - * Setup the networking compoents. + * Setup the networking components. */ bool SandNetNode::InitNetwork() { if (!m_control_socket.Init()) { @@ -375,16 +384,17 @@ bool SandNetNode::HandleCompressedDMX(const sandnet_compressed_dmx &dmx_packet, unsigned int header_size = sizeof(dmx_packet) - sizeof(dmx_packet.dmx); if (size <= header_size) { - OLA_WARN << "Sandnet data size too small, expected at least " << - header_size << ", got " << size; + OLA_WARN << "Sandnet data size too small, expected at least " + << header_size << ", got " << size; return false; } group_universe_pair key(dmx_packet.group, dmx_packet.universe); universe_handlers::iterator iter = m_handlers.find(key); - if (iter == m_handlers.end()) + if (iter == m_handlers.end()) { return false; + } unsigned int data_size = size - header_size; bool r = m_encoder.Decode(0, dmx_packet.dmx, data_size, iter->second.buffer); @@ -405,16 +415,17 @@ bool SandNetNode::HandleDMX(const sandnet_dmx &dmx_packet, unsigned int size) { unsigned int header_size = sizeof(dmx_packet) - sizeof(dmx_packet.dmx); if (size <= header_size) { - OLA_WARN << "Sandnet data size too small, expected at least " << - header_size << ", got " << size; + OLA_WARN << "Sandnet data size too small, expected at least " + << header_size << ", got " << size; return false; } group_universe_pair key(dmx_packet.group, dmx_packet.universe); universe_handlers::iterator iter = m_handlers.find(key); - if (iter == m_handlers.end()) + if (iter == m_handlers.end()) { return false; + } unsigned int data_size = size - header_size; iter->second.buffer->Set(dmx_packet.dmx, data_size); @@ -452,10 +463,11 @@ bool SandNetNode::SendPacket(const sandnet_packet &packet, unsigned int size, bool is_control) { UDPSocket *socket; - if (is_control) + if (is_control) { socket = &m_control_socket; - else + } else { socket = &m_data_socket; + } ssize_t bytes_sent = socket->SendTo( reinterpret_cast(&packet), diff --git a/plugins/shownet/ShowNetNode.cpp b/plugins/shownet/ShowNetNode.cpp index 489c583e59..8626876a57 100644 --- a/plugins/shownet/ShowNetNode.cpp +++ b/plugins/shownet/ShowNetNode.cpp @@ -80,11 +80,12 @@ ShowNetNode::~ShowNetNode() { * Start this node */ bool ShowNetNode::Start() { - if (m_running) + if (m_running) { return false; + } ola::network::InterfacePicker *picker = - ola::network::InterfacePicker::NewPicker(); + ola::network::InterfacePicker::NewPicker(); if (!picker->ChooseInterface(&m_interface, m_preferred_ip)) { delete picker; OLA_INFO << "Failed to find an interface"; @@ -92,8 +93,9 @@ bool ShowNetNode::Start() { } delete picker; - if (!InitNetwork()) + if (!InitNetwork()) { return false; + } m_running = true; return true; @@ -104,8 +106,9 @@ bool ShowNetNode::Start() { * Stop this node */ bool ShowNetNode::Stop() { - if (!m_running) + if (!m_running) { return false; + } if (m_socket) { delete m_socket; @@ -134,12 +137,13 @@ void ShowNetNode::SetName(const string &name) { */ bool ShowNetNode::SendDMX(unsigned int universe, const ola::DmxBuffer &buffer) { - if (!m_running) + if (!m_running) { return false; + } if (universe >= SHOWNET_MAX_UNIVERSES) { - OLA_WARN << "Universe index out of bounds, should be between 0 and" << - SHOWNET_MAX_UNIVERSES << "), was " << universe; + OLA_WARN << "Universe index out of bounds, should be between 0 and" + << SHOWNET_MAX_UNIVERSES << "), was " << universe; return false; } @@ -169,11 +173,12 @@ bool ShowNetNode::SendDMX(unsigned int universe, bool ShowNetNode::SetHandler(unsigned int universe, DmxBuffer *buffer, Callback0 *closure) { - if (!closure) + if (!closure) { return false; + } map::iterator iter = - m_handlers.find(universe); + m_handlers.find(universe); if (iter == m_handlers.end()) { universe_handler handler; @@ -196,7 +201,7 @@ bool ShowNetNode::SetHandler(unsigned int universe, */ bool ShowNetNode::RemoveHandler(unsigned int universe) { map::iterator iter = - m_handlers.find(universe); + m_handlers.find(universe); if (iter != m_handlers.end()) { Callback0 *old_closure = iter->second.closure; @@ -217,12 +222,14 @@ void ShowNetNode::SocketReady() { ola::network::IPV4SocketAddress source; if (!m_socket->RecvFrom(reinterpret_cast(&packet), - &packet_size, &source)) + &packet_size, &source)) { return; + } // skip packets sent by us - if (source.Host() != m_interface.ip_address) + if (source.Host() != m_interface.ip_address) { HandlePacket(&packet, packet_size); + } } @@ -326,8 +333,9 @@ unsigned int ShowNetNode::BuildCompressedPacket(shownet_packet *packet, static_cast(buffer.Size())); unsigned int enc_len = sizeof(packet->data); - if (!m_encoder.Encode(buffer, compressed_dmx->data, &enc_len)) + if (!m_encoder.Encode(buffer, compressed_dmx->data, &enc_len)) { OLA_WARN << "Failed to encode all data (used " << enc_len << " bytes"; + } compressed_dmx->indexBlock[0] = HostToLittleEndian( static_cast(MAGIC_INDEX_OFFSET)); @@ -344,7 +352,7 @@ unsigned int ShowNetNode::BuildCompressedPacket(shownet_packet *packet, /* - * Setup the networking compoents. + * Setup the networking components. */ bool ShowNetNode::InitNetwork() { m_socket = new UDPSocket(); diff --git a/plugins/usbpro/EnttecUsbProWidgetTest.cpp b/plugins/usbpro/EnttecUsbProWidgetTest.cpp index fffa0642e1..3c750722fe 100644 --- a/plugins/usbpro/EnttecUsbProWidgetTest.cpp +++ b/plugins/usbpro/EnttecUsbProWidgetTest.cpp @@ -398,7 +398,7 @@ void EnttecUsbProWidgetTest::testReceiveDMX() { // because this doesn't trigger the callback we have no way to terminate the // select server, so we use a timeout, which is nasty, but fails closed m_ss.RegisterSingleTimeout( - 100, // shold be more than enough time + 100, // should be more than enough time ola::NewSingleCallback(this, &EnttecUsbProWidgetTest::Terminate)); m_ss.Run(); m_endpoint->Verify(); diff --git a/tools/e133/e133-monitor.cpp b/tools/e133/e133-monitor.cpp index 2379265bc9..03327a9d85 100644 --- a/tools/e133/e133-monitor.cpp +++ b/tools/e133/e133-monitor.cpp @@ -182,12 +182,14 @@ int main(int argc, char *argv[]) { } } - if (!pid_helper.Init()) + if (!pid_helper.Init()) { exit(ola::EXIT_OSFILE); + } SimpleE133Monitor monitor(&pid_helper); - if (!monitor.Init()) + if (!monitor.Init()) { exit(ola::EXIT_UNAVAILABLE); + } // manually add the responder IPs vector::const_iterator iter = targets.begin(); diff --git a/tools/rdm/static/rdm_tests.js b/tools/rdm/static/rdm_tests.js index 835dd08efd..33f4e7bda5 100644 --- a/tools/rdm/static/rdm_tests.js +++ b/tools/rdm/static/rdm_tests.js @@ -116,7 +116,7 @@ RDMTests.publisher_url = 'http://rdm.openlighting.org/incoming/model_data'; /** * Prepares the notification div and displays it on the page. * @this {RDMTests} - * @param {Objec} options An object containing title and message to be + * @param {Object} options An object containing title and message to be * displayed. * * {