diff options
author | Jeff Garzik <jgarzik@exmulti.com> | 2012-07-04 08:34:11 -0700 |
---|---|---|
committer | Jeff Garzik <jgarzik@exmulti.com> | 2012-07-04 08:34:11 -0700 |
commit | fe70b09c428585166f1040e9023251c9c250e894 (patch) | |
tree | 31b5dfc6515d922b9abc8f82eb4c97c2a8d0675c | |
parent | 8a05341cf5543eec18f3a1380a0098dbd314e351 (diff) | |
parent | 24154ed64b70ac3c9fdceb6b53f1746b91e53bfa (diff) |
Merge pull request #1555 from TheBlueMatt/warnings
Fix remaining compile warnings.
-rw-r--r-- | src/net.h | 6 | ||||
-rw-r--r-- | src/protocol.h | 12 |
2 files changed, 13 insertions, 5 deletions
@@ -371,14 +371,14 @@ public: // Set the size unsigned int nSize = vSend.size() - nMessageStart; - memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize)); + memcpy((char*)&vSend[nHeaderStart] + CMessageHeader::MESSAGE_SIZE_OFFSET, &nSize, sizeof(nSize)); // Set the checksum uint256 hash = Hash(vSend.begin() + nMessageStart, vSend.end()); unsigned int nChecksum = 0; memcpy(&nChecksum, &hash, sizeof(nChecksum)); - assert(nMessageStart - nHeaderStart >= offsetof(CMessageHeader, nChecksum) + sizeof(nChecksum)); - memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum)); + assert(nMessageStart - nHeaderStart >= CMessageHeader::CHECKSUM_OFFSET + sizeof(nChecksum)); + memcpy((char*)&vSend[nHeaderStart] + CMessageHeader::CHECKSUM_OFFSET, &nChecksum, sizeof(nChecksum)); if (fDebug) { printf("(%d bytes)\n", nSize); diff --git a/src/protocol.h b/src/protocol.h index b516f1b897..36f8b144cd 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -49,8 +49,16 @@ class CMessageHeader // TODO: make private (improves encapsulation) public: - enum { COMMAND_SIZE=12 }; - char pchMessageStart[sizeof(::pchMessageStart)]; + enum { + MESSAGE_START_SIZE=sizeof(::pchMessageStart), + COMMAND_SIZE=12, + MESSAGE_SIZE_SIZE=sizeof(int), + CHECKSUM_SIZE=sizeof(int), + + MESSAGE_SIZE_OFFSET=MESSAGE_START_SIZE+COMMAND_SIZE, + CHECKSUM_OFFSET=MESSAGE_SIZE_OFFSET+MESSAGE_SIZE_SIZE + }; + char pchMessageStart[MESSAGE_START_SIZE]; char pchCommand[COMMAND_SIZE]; unsigned int nMessageSize; unsigned int nChecksum; |