From 284e5d83b50dc99dbc916237f26915bcce745960 Mon Sep 17 00:00:00 2001
From: Adam Ierymenko <adam.ierymenko@gmail.com>
Date: Mon, 28 Mar 2016 12:15:24 -0700
Subject: [PATCH] Fix some broken TRACEs and a tiny reorder in a few ifs.

---
 node/Peer.cpp   | 6 +++---
 node/Switch.hpp | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/node/Peer.cpp b/node/Peer.cpp
index b9d11292e..87ca94e17 100644
--- a/node/Peer.cpp
+++ b/node/Peer.cpp
@@ -386,7 +386,7 @@ bool Peer::validateAndSetNetworkMembershipCertificate(uint64_t nwid,const Certif
 
 	// Check signature, log and return if cert is invalid
 	if (com.signedBy() != Network::controllerFor(nwid)) {
-		TRACE("rejected network membership certificate for %.16llx signed by %s: signer not a controller of this network",(unsigned long long)_id,com.signedBy().toString().c_str());
+		TRACE("rejected network membership certificate for %.16llx signed by %s: signer not a controller of this network",(unsigned long long)nwid,com.signedBy().toString().c_str());
 		return false; // invalid signer
 	}
 
@@ -395,7 +395,7 @@ bool Peer::validateAndSetNetworkMembershipCertificate(uint64_t nwid,const Certif
 		// We are the controller: RR->identity.address() == controller() == cert.signedBy()
 		// So, verify that we signed th cert ourself
 		if (!com.verify(RR->identity)) {
-			TRACE("rejected network membership certificate for %.16llx self signed by %s: signature check failed",(unsigned long long)_id,com.signedBy().toString().c_str());
+			TRACE("rejected network membership certificate for %.16llx self signed by %s: signature check failed",(unsigned long long)nwid,com.signedBy().toString().c_str());
 			return false; // invalid signature
 		}
 
@@ -411,7 +411,7 @@ bool Peer::validateAndSetNetworkMembershipCertificate(uint64_t nwid,const Certif
 		}
 
 		if (!com.verify(signer->identity())) {
-			TRACE("rejected network membership certificate for %.16llx signed by %s: signature check failed",(unsigned long long)_id,com.signedBy().toString().c_str());
+			TRACE("rejected network membership certificate for %.16llx signed by %s: signature check failed",(unsigned long long)nwid,com.signedBy().toString().c_str());
 			return false; // invalid signature
 		}
 	}
diff --git a/node/Switch.hpp b/node/Switch.hpp
index 3ba2736db..219bfb416 100644
--- a/node/Switch.hpp
+++ b/node/Switch.hpp
@@ -191,10 +191,10 @@ private:
 		unsigned long i = ZT_RX_QUEUE_SIZE;
 		while (i) {
 			rq = &(_rxQueue[--i]);
-			if (rq->timestamp < oldest->timestamp)
-				oldest = rq;
 			if ((rq->packetId == packetId)&&(rq->timestamp))
 				return rq;
+			if (rq->timestamp < oldest->timestamp)
+				oldest = rq;
 		}
 		return oldest;
 	}