Browse Source

Merge pull request #1555 from TheBlueMatt/warnings

Fix remaining compile warnings.
miguelfreitas
Jeff Garzik 13 years ago
parent
commit
fe70b09c42
  1. 6
      src/net.h
  2. 12
      src/protocol.h

6
src/net.h

@ -371,14 +371,14 @@ public:
// Set the size // Set the size
unsigned int nSize = vSend.size() - nMessageStart; 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 // Set the checksum
uint256 hash = Hash(vSend.begin() + nMessageStart, vSend.end()); uint256 hash = Hash(vSend.begin() + nMessageStart, vSend.end());
unsigned int nChecksum = 0; unsigned int nChecksum = 0;
memcpy(&nChecksum, &hash, sizeof(nChecksum)); memcpy(&nChecksum, &hash, sizeof(nChecksum));
assert(nMessageStart - nHeaderStart >= offsetof(CMessageHeader, nChecksum) + sizeof(nChecksum)); assert(nMessageStart - nHeaderStart >= CMessageHeader::CHECKSUM_OFFSET + sizeof(nChecksum));
memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum)); memcpy((char*)&vSend[nHeaderStart] + CMessageHeader::CHECKSUM_OFFSET, &nChecksum, sizeof(nChecksum));
if (fDebug) { if (fDebug) {
printf("(%d bytes)\n", nSize); printf("(%d bytes)\n", nSize);

12
src/protocol.h

@ -49,8 +49,16 @@ class CMessageHeader
// TODO: make private (improves encapsulation) // TODO: make private (improves encapsulation)
public: public:
enum { COMMAND_SIZE=12 }; enum {
char pchMessageStart[sizeof(::pchMessageStart)]; 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]; char pchCommand[COMMAND_SIZE];
unsigned int nMessageSize; unsigned int nMessageSize;
unsigned int nChecksum; unsigned int nChecksum;

Loading…
Cancel
Save