From bc59db5e6f5a1207d31b9a44dee45f93529ceb0c Mon Sep 17 00:00:00 2001 From: Thad House Date: Fri, 6 Sep 2019 18:45:52 -0700 Subject: [PATCH] Rename DEBUG macro to DEBUG0 (#1871) This avoids conflicts with the platform DEBUG macro on some platforms. --- cscore/src/main/native/cpp/Log.h | 6 +-- ntcore/src/main/native/cpp/Dispatcher.cpp | 40 +++++++++---------- ntcore/src/main/native/cpp/EntryNotifier.cpp | 6 +-- ntcore/src/main/native/cpp/Log.h | 4 +- .../src/main/native/cpp/NetworkConnection.cpp | 3 +- ntcore/src/main/native/cpp/Storage.cpp | 24 +++++------ ntcore/src/main/native/cpp/Storage_save.cpp | 6 +-- 7 files changed, 45 insertions(+), 44 deletions(-) diff --git a/cscore/src/main/native/cpp/Log.h b/cscore/src/main/native/cpp/Log.h index 9ca0e1bd57..b9fd9abb1d 100644 --- a/cscore/src/main/native/cpp/Log.h +++ b/cscore/src/main/native/cpp/Log.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -17,7 +17,7 @@ #define WARNING(x) WPI_WARNING(m_logger, x) #define INFO(x) WPI_INFO(m_logger, x) -#define DEBUG(x) WPI_DEBUG(m_logger, x) +#define DEBUG0(x) WPI_DEBUG(m_logger, x) #define DEBUG1(x) WPI_DEBUG1(m_logger, x) #define DEBUG2(x) WPI_DEBUG2(m_logger, x) #define DEBUG3(x) WPI_DEBUG3(m_logger, x) @@ -27,7 +27,7 @@ #define SWARNING(x) WARNING(GetName() << ": " << x) #define SINFO(x) INFO(GetName() << ": " << x) -#define SDEBUG(x) DEBUG(GetName() << ": " << x) +#define SDEBUG(x) DEBUG0(GetName() << ": " << x) #define SDEBUG1(x) DEBUG1(GetName() << ": " << x) #define SDEBUG2(x) DEBUG2(GetName() << ": " << x) #define SDEBUG3(x) DEBUG3(GetName() << ": " << x) diff --git a/ntcore/src/main/native/cpp/Dispatcher.cpp b/ntcore/src/main/native/cpp/Dispatcher.cpp index e07972202a..8164f45662 100644 --- a/ntcore/src/main/native/cpp/Dispatcher.cpp +++ b/ntcore/src/main/native/cpp/Dispatcher.cpp @@ -323,7 +323,7 @@ void DispatcherBase::DispatchThreadMain() { bool reconnect = false; if (++count > 10) { - DEBUG("dispatch running " << m_connections.size() << " connections"); + DEBUG0("dispatch running " << m_connections.size() << " connections"); count = 0; } @@ -379,8 +379,8 @@ void DispatcherBase::ServerThreadMain() { m_networkMode = NT_NET_MODE_NONE; return; } - DEBUG("server: client connection from " << stream->getPeerIP() << " port " - << stream->getPeerPort()); + DEBUG0("server: client connection from " << stream->getPeerIP() << " port " + << stream->getPeerPort()); // add to connections list using namespace std::placeholders; @@ -430,13 +430,13 @@ void DispatcherBase::ClientThreadMain() { } // try to connect (with timeout) - DEBUG("client trying to connect"); + DEBUG0("client trying to connect"); auto stream = connect(); if (!stream) { m_networkMode = NT_NET_MODE_CLIENT | NT_NET_MODE_FAILURE; continue; // keep retrying } - DEBUG("client connected"); + DEBUG0("client connected"); m_networkMode = NT_NET_MODE_CLIENT; std::unique_lock lock(m_user_mutex); @@ -474,14 +474,14 @@ bool DispatcherBase::ClientHandshake( } // send client hello - DEBUG("client: sending hello"); + DEBUG0("client: sending hello"); send_msgs(Message::ClientHello(self_id)); // wait for response auto msg = get_msg(); if (!msg) { // disconnected, retry - DEBUG("client: server disconnected before first response"); + DEBUG0("client: server disconnected before first response"); return false; } @@ -505,7 +505,7 @@ bool DispatcherBase::ClientHandshake( for (;;) { if (!msg) { // disconnected, retry - DEBUG("client: server disconnected during initial entries"); + DEBUG0("client: server disconnected during initial entries"); return false; } DEBUG4("received init str=" << msg->str() << " id=" << msg->id() @@ -518,9 +518,9 @@ bool DispatcherBase::ClientHandshake( } if (!msg->Is(Message::kEntryAssign)) { // unexpected message - DEBUG("client: received message (" - << msg->type() - << ") other than entry assignment during initial handshake"); + DEBUG0("client: received message (" + << msg->type() + << ") other than entry assignment during initial handshake"); return false; } incoming.emplace_back(std::move(msg)); @@ -549,18 +549,18 @@ bool DispatcherBase::ServerHandshake( // Wait for the client to send us a hello. auto msg = get_msg(); if (!msg) { - DEBUG("server: client disconnected before sending hello"); + DEBUG0("server: client disconnected before sending hello"); return false; } if (!msg->Is(Message::kClientHello)) { - DEBUG("server: client initial message was not client hello"); + DEBUG0("server: client initial message was not client hello"); return false; } // Check that the client requested version is not too high. unsigned int proto_rev = msg->id(); if (proto_rev > 0x0300) { - DEBUG("server: client requested proto > 0x0300"); + DEBUG0("server: client requested proto > 0x0300"); send_msgs(Message::ProtoUnsup()); return false; } @@ -568,7 +568,7 @@ bool DispatcherBase::ServerHandshake( if (proto_rev >= 0x0300) conn.set_remote_id(msg->str()); // Set the proto version to the client requested version - DEBUG("server: client protocol " << proto_rev); + DEBUG0("server: client protocol " << proto_rev); conn.set_proto_rev(proto_rev); // Send initial set of assignments @@ -587,7 +587,7 @@ bool DispatcherBase::ServerHandshake( outgoing.emplace_back(Message::ServerHelloDone()); // Batch transmit - DEBUG("server: sending initial assignments"); + DEBUG0("server: sending initial assignments"); send_msgs(outgoing); // In proto rev 3.0 and later, the handshake concludes with a client hello @@ -601,7 +601,7 @@ bool DispatcherBase::ServerHandshake( for (;;) { if (!msg) { // disconnected, retry - DEBUG("server: disconnected waiting for initial entries"); + DEBUG0("server: disconnected waiting for initial entries"); return false; } if (msg->Is(Message::kClientHelloDone)) break; @@ -612,9 +612,9 @@ bool DispatcherBase::ServerHandshake( } if (!msg->Is(Message::kEntryAssign)) { // unexpected message - DEBUG("server: received message (" - << msg->type() - << ") other than entry assignment during initial handshake"); + DEBUG0("server: received message (" + << msg->type() + << ") other than entry assignment during initial handshake"); return false; } incoming.push_back(msg); diff --git a/ntcore/src/main/native/cpp/EntryNotifier.cpp b/ntcore/src/main/native/cpp/EntryNotifier.cpp index 5fde687d61..c8f8d76842 100644 --- a/ntcore/src/main/native/cpp/EntryNotifier.cpp +++ b/ntcore/src/main/native/cpp/EntryNotifier.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -82,8 +82,8 @@ void EntryNotifier::NotifyEntry(unsigned int local_id, StringRef name, // optimization: don't generate needless local queue entries if we have // no local listeners (as this is a common case on the server side) if ((flags & NT_NOTIFY_LOCAL) != 0 && !m_local_notifiers) return; - DEBUG("notifying '" << name << "' (local=" << local_id - << "), flags=" << flags); + DEBUG0("notifying '" << name << "' (local=" << local_id + << "), flags=" << flags); Send(only_listener, 0, Handle(m_inst, local_id, Handle::kEntry).handle(), name, value, flags); } diff --git a/ntcore/src/main/native/cpp/Log.h b/ntcore/src/main/native/cpp/Log.h index b8a3daf79e..eba8f04a0d 100644 --- a/ntcore/src/main/native/cpp/Log.h +++ b/ntcore/src/main/native/cpp/Log.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -17,7 +17,7 @@ #define WARNING(x) WPI_WARNING(m_logger, x) #define INFO(x) WPI_INFO(m_logger, x) -#define DEBUG(x) WPI_DEBUG(m_logger, x) +#define DEBUG0(x) WPI_DEBUG(m_logger, x) #define DEBUG1(x) WPI_DEBUG1(m_logger, x) #define DEBUG2(x) WPI_DEBUG2(m_logger, x) #define DEBUG3(x) WPI_DEBUG3(m_logger, x) diff --git a/ntcore/src/main/native/cpp/NetworkConnection.cpp b/ntcore/src/main/native/cpp/NetworkConnection.cpp index cb1e725a35..8cc8312a51 100644 --- a/ntcore/src/main/native/cpp/NetworkConnection.cpp +++ b/ntcore/src/main/native/cpp/NetworkConnection.cpp @@ -140,7 +140,8 @@ void NetworkConnection::ReadThreadMain() { decoder.set_proto_rev(m_proto_rev); auto msg = Message::Read(decoder, m_get_entry_type); if (!msg && decoder.error()) - DEBUG("error reading in handshake: " << decoder.error()); + DEBUG0( + "error reading in handshake: " << decoder.error()); return msg; }, [&](wpi::ArrayRef> msgs) { diff --git a/ntcore/src/main/native/cpp/Storage.cpp b/ntcore/src/main/native/cpp/Storage.cpp index 611d455a04..cf0d26ca64 100644 --- a/ntcore/src/main/native/cpp/Storage.cpp +++ b/ntcore/src/main/native/cpp/Storage.cpp @@ -110,7 +110,7 @@ void Storage::ProcessIncomingEntryAssign(std::shared_ptr msg, // ignore arbitrary entry assignments // this can happen due to e.g. assignment to deleted entry lock.unlock(); - DEBUG("server: received assignment to unknown entry"); + DEBUG0("server: received assignment to unknown entry"); return; } entry = m_idmap[id]; @@ -118,7 +118,7 @@ void Storage::ProcessIncomingEntryAssign(std::shared_ptr msg, // clients simply accept new assignments if (id == 0xffff) { lock.unlock(); - DEBUG("client: received entry assignment request?"); + DEBUG0("client: received entry assignment request?"); return; } if (id >= m_idmap.size()) m_idmap.resize(id + 1); @@ -171,7 +171,7 @@ void Storage::ProcessIncomingEntryAssign(std::shared_ptr msg, // sanity check: name should match id if (msg->str() != entry->name) { lock.unlock(); - DEBUG("entry assignment for same id with different name?"); + DEBUG0("entry assignment for same id with different name?"); return; } @@ -217,7 +217,7 @@ void Storage::ProcessIncomingEntryUpdate(std::shared_ptr msg, // ignore arbitrary entry updates; // this can happen due to deleted entries lock.unlock(); - DEBUG("received update to unknown entry"); + DEBUG0("received update to unknown entry"); return; } Entry* entry = m_idmap[id]; @@ -254,7 +254,7 @@ void Storage::ProcessIncomingFlagsUpdate(std::shared_ptr msg, // ignore arbitrary entry updates; // this can happen due to deleted entries lock.unlock(); - DEBUG("received flags update to unknown entry"); + DEBUG0("received flags update to unknown entry"); return; } @@ -278,7 +278,7 @@ void Storage::ProcessIncomingEntryDelete(std::shared_ptr msg, // ignore arbitrary entry updates; // this can happen due to deleted entries lock.unlock(); - DEBUG("received delete to unknown entry"); + DEBUG0("received delete to unknown entry"); return; } @@ -319,13 +319,13 @@ void Storage::ProcessIncomingExecuteRpc( // ignore call to non-existent RPC // this can happen due to deleted entries lock.unlock(); - DEBUG("received RPC call to unknown entry"); + DEBUG0("received RPC call to unknown entry"); return; } Entry* entry = m_idmap[id]; if (!entry->value || !entry->value->IsRpc()) { lock.unlock(); - DEBUG("received RPC call to non-RPC entry"); + DEBUG0("received RPC call to non-RPC entry"); return; } ConnectionInfo conn_info; @@ -358,13 +358,13 @@ void Storage::ProcessIncomingRpcResponse(std::shared_ptr msg, // ignore response to non-existent RPC // this can happen due to deleted entries lock.unlock(); - DEBUG("received rpc response to unknown entry"); + DEBUG0("received rpc response to unknown entry"); return; } Entry* entry = m_idmap[id]; if (!entry->value || !entry->value->IsRpc()) { lock.unlock(); - DEBUG("received RPC response to non-RPC entry"); + DEBUG0("received RPC response to non-RPC entry"); return; } m_rpc_results.insert(std::make_pair( @@ -404,13 +404,13 @@ void Storage::ApplyInitialAssignments( // apply assignments for (auto& msg : msgs) { if (!msg->Is(Message::kEntryAssign)) { - DEBUG("client: received non-entry assignment request?"); + DEBUG0("client: received non-entry assignment request?"); continue; } unsigned int id = msg->id(); if (id == 0xffff) { - DEBUG("client: received entry assignment request?"); + DEBUG0("client: received entry assignment request?"); continue; } diff --git a/ntcore/src/main/native/cpp/Storage_save.cpp b/ntcore/src/main/native/cpp/Storage_save.cpp index 3f352da82f..797eb8bf73 100644 --- a/ntcore/src/main/native/cpp/Storage_save.cpp +++ b/ntcore/src/main/native/cpp/Storage_save.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */ +/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -203,7 +203,7 @@ const char* Storage::SavePersistent(const Twine& filename, err = "could not open file"; goto done; } - DEBUG("saving persistent file '" << filename << "'"); + DEBUG0("saving persistent file '" << filename << "'"); SavePersistentImpl(os).Save(entries); os.close(); if (os.has_error()) { @@ -252,7 +252,7 @@ const char* Storage::SaveEntries(const Twine& filename, if (ec.value() != 0) { return "could not open file"; } - DEBUG("saving file '" << filename << "'"); + DEBUG0("saving file '" << filename << "'"); SavePersistentImpl(os).Save(entries); os.close(); if (os.has_error()) {