diff --git a/ChangeLog b/ChangeLog index 122f537f..52f5df0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2010-10-10 Tatsuhiro Tsujikawa + + Append 'u' to hex mask. + * src/Base64.cc + * src/BitfieldMan.cc + * src/BtHandshakeMessage.cc + * src/BtHandshakeMessage.h + * src/DHTBucket.cc + * src/DHTRoutingTableDeserializer.cc + * src/DHTRoutingTableSerializer.cc + * src/DefaultBtProgressInfoFile.cc + * src/MSEHandshake.h + * src/MultiUrlRequestInfo.cc + * src/Platform.cc + * src/SpeedCalc.cc + * src/UTPexExtensionMessage.cc + * src/a2netcompat.h + * src/base32.cc + * src/bitfield.h + * src/bittorrent_helper.cc + * src/cookie_helper.cc + * src/util.h + 2010-10-10 Tatsuhiro Tsujikawa Added util::lowercase() and util::uppercase(). diff --git a/src/Base64.cc b/src/Base64.cc index 407ecb49..4b7b6afd 100644 --- a/src/Base64.cc +++ b/src/Base64.cc @@ -86,21 +86,21 @@ void Base64::encode(unsigned char*& result, size_t& rlength, n += *s++ << 8; n += *s++; *p++ = CHAR_TABLE[n >> 18]; - *p++ = CHAR_TABLE[n >> 12&0x3f]; - *p++ = CHAR_TABLE[n >> 6&0x3f]; - *p++ = CHAR_TABLE[n&0x3f]; + *p++ = CHAR_TABLE[n >> 12&0x3fu]; + *p++ = CHAR_TABLE[n >> 6&0x3fu]; + *p++ = CHAR_TABLE[n&0x3fu]; } if(r == 2) { int n = *s++ << 16; n += *s++ << 8; *p++ = CHAR_TABLE[n >> 18]; - *p++ = CHAR_TABLE[n >> 12&0x3f]; - *p++ = CHAR_TABLE[n >> 6&0x3f]; + *p++ = CHAR_TABLE[n >> 12&0x3fu]; + *p++ = CHAR_TABLE[n >> 6&0x3fu]; *p++ = '='; } else if(r == 1) { int n = *s++ << 16; *p++ = CHAR_TABLE[n >> 18]; - *p++ = CHAR_TABLE[n >> 12&0x3f]; + *p++ = CHAR_TABLE[n >> 12&0x3fu]; *p++ = '='; *p++ = '='; } @@ -164,8 +164,8 @@ void Base64::decode(unsigned char*& result, size_t& rlength, n += INDEX_TABLE[*s++] << 6; n += INDEX_TABLE[*s++]; *p++ = n >> 16; - *p++ = n >> 8&0xff; - *p++ = n&0xff; + *p++ = n >> 8&0xffu; + *p++ = n&0xffu; } if(r == 2) { int n = INDEX_TABLE[*s++] << 18; @@ -176,7 +176,7 @@ void Base64::decode(unsigned char*& result, size_t& rlength, n += INDEX_TABLE[*s++] << 12; n += INDEX_TABLE[*s++] << 6; *p++ = n >> 16; - *p++ = n >> 8&0xff; + *p++ = n >> 8&0xffu; } delete [] nsrc; } diff --git a/src/BitfieldMan.cc b/src/BitfieldMan.cc index 427e02de..9e7771e4 100644 --- a/src/BitfieldMan.cc +++ b/src/BitfieldMan.cc @@ -154,7 +154,7 @@ bool BitfieldMan::hasMissingPiece if(filterEnabled_) { temp &= filterBitfield_[i]; } - if(temp&0xff) { + if(temp&0xffu) { retval = true; break; } @@ -445,7 +445,7 @@ static bool testAllBitSet return true; } for(size_t i = 0; i < length-1; ++i) { - if(bitfield[i] != 0xff) { + if(bitfield[i] != 0xffu) { return false; } } diff --git a/src/BtHandshakeMessage.cc b/src/BtHandshakeMessage.cc index bd209250..d30601d9 100644 --- a/src/BtHandshakeMessage.cc +++ b/src/BtHandshakeMessage.cc @@ -70,9 +70,9 @@ void BtHandshakeMessage::init() { memcpy(pstr_, BT_PSTR, PSTR_LENGTH); memset(reserved_, 0, RESERVED_LENGTH); // fast extension - reserved_[7] |= 0x04; + reserved_[7] |= 0x04u; // extended messaging - reserved_[5] |= 0x10; + reserved_[5] |= 0x10u; } SharedHandle @@ -110,17 +110,17 @@ std::string BtHandshakeMessage::toString() const { } bool BtHandshakeMessage::isFastExtensionSupported() const { - return reserved_[7]&0x04; + return reserved_[7]&0x04u; } bool BtHandshakeMessage::isExtendedMessagingEnabled() const { - return reserved_[5]&0x10; + return reserved_[5]&0x10u; } bool BtHandshakeMessage::isDHTEnabled() const { - return reserved_[7]&0x01; + return reserved_[7]&0x01u; } void BtHandshakeMessage::setInfoHash(const unsigned char* infoHash) diff --git a/src/BtHandshakeMessage.h b/src/BtHandshakeMessage.h index b52b10f8..4be27629 100644 --- a/src/BtHandshakeMessage.h +++ b/src/BtHandshakeMessage.h @@ -91,9 +91,9 @@ public: void setDHTEnabled(bool enabled) { if(enabled) { - reserved_[7] |= 0x01; + reserved_[7] |= 0x01u; } else { - reserved_[7] &= ~0x01; + reserved_[7] &= ~0x01u; } } diff --git a/src/DHTBucket.cc b/src/DHTBucket.cc index ebe0936a..a54cb89b 100644 --- a/src/DHTBucket.cc +++ b/src/DHTBucket.cc @@ -68,7 +68,7 @@ DHTBucket::DHTBucket(const SharedHandle& localNode): lastUpdated_(global::wallclock), logger_(LogFactory::getInstance()) { - memset(max_, 0xff, DHT_ID_LENGTH); + memset(max_, 0xffu, DHT_ID_LENGTH); memset(min_, 0, DHT_ID_LENGTH); } diff --git a/src/DHTRoutingTableDeserializer.cc b/src/DHTRoutingTableDeserializer.cc index d06de4b3..b3f372e6 100644 --- a/src/DHTRoutingTableDeserializer.cc +++ b/src/DHTRoutingTableDeserializer.cc @@ -81,24 +81,24 @@ void DHTRoutingTableDeserializer::deserialize(std::istream& in) char header[8]; memset(header, 0, sizeof(header)); // magic - header[0] = 0xa1; - header[1] = 0xa2; + header[0] = 0xa1u; + header[1] = 0xa2u; // format ID - header[2] = 0x02; + header[2] = 0x02u; // version header[6] = 0; - header[7] = 0x03; + header[7] = 0x03u; char headerCompat[8]; memset(headerCompat, 0, sizeof(headerCompat)); // magic - headerCompat[0] = 0xa1; - headerCompat[1] = 0xa2; + headerCompat[0] = 0xa1u; + headerCompat[1] = 0xa2u; // format ID - headerCompat[2] = 0x02; + headerCompat[2] = 0x02u; // version headerCompat[6] = 0; - headerCompat[7] = 0x02; + headerCompat[7] = 0x02u; char zero[18]; memset(zero, 0, sizeof(zero)); diff --git a/src/DHTRoutingTableSerializer.cc b/src/DHTRoutingTableSerializer.cc index d1bfa3f4..2228e422 100644 --- a/src/DHTRoutingTableSerializer.cc +++ b/src/DHTRoutingTableSerializer.cc @@ -72,13 +72,13 @@ void DHTRoutingTableSerializer::serialize(std::ostream& o) char header[8]; memset(header, 0, sizeof(header)); // magic - header[0] = 0xa1; - header[1] = 0xa2; + header[0] = 0xa1u; + header[1] = 0xa2u; // format ID - header[2] = 0x02; + header[2] = 0x02u; // version header[6] = 0; - header[7] = 0x03; + header[7] = 0x03u; char zero[18]; memset(zero, 0, sizeof(zero)); diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index 65b300c5..63923671 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -120,7 +120,7 @@ void DefaultBtProgressInfoFile::save() // file version: 16 bits // values: '1' - char version[] = { 0x00, 0x01 }; + char version[] = { 0x00u, 0x01u }; o.write(version, sizeof(version)); // extension: 32 bits // If this is BitTorrent download, then 0x00000001 diff --git a/src/MSEHandshake.h b/src/MSEHandshake.h index ebb06baa..da372b18 100644 --- a/src/MSEHandshake.h +++ b/src/MSEHandshake.h @@ -64,8 +64,8 @@ public: enum CRYPTO_TYPE { CRYPTO_NONE = 0, - CRYPTO_PLAIN_TEXT = 0x01, - CRYPTO_ARC4 = 0x02 + CRYPTO_PLAIN_TEXT = 0x01u, + CRYPTO_ARC4 = 0x02u }; private: diff --git a/src/MultiUrlRequestInfo.cc b/src/MultiUrlRequestInfo.cc index 30d8ce60..5d405a9f 100644 --- a/src/MultiUrlRequestInfo.cc +++ b/src/MultiUrlRequestInfo.cc @@ -67,10 +67,6 @@ namespace aria2 { -#ifndef SA_RESETHAND -# define SA_RESETHAND 0x80000000 -#endif // SA_RESETHAND - namespace global { extern volatile sig_atomic_t globalHaltRequested; diff --git a/src/Platform.cc b/src/Platform.cc index be2acd63..57638f92 100644 --- a/src/Platform.cc +++ b/src/Platform.cc @@ -44,7 +44,7 @@ #ifdef HAVE_WINSOCK2_H #ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x501 +# define _WIN32_WINNT 0x501u #endif // _WIN32_WINNT #include #undef ERROR diff --git a/src/SpeedCalc.cc b/src/SpeedCalc.cc index 0e5bd296..02b04801 100644 --- a/src/SpeedCalc.cc +++ b/src/SpeedCalc.cc @@ -97,7 +97,7 @@ bool SpeedCalc::isIntervalOver(int64_t milliElapsed) const void SpeedCalc::changeSw() { lengthArray_[sw_] = 0; cpArray_[sw_] = global::wallclock; - sw_ ^= 0x01; + sw_ ^= 0x01u; nextInterval_ = cpArray_[sw_].difference(global::wallclock)+CHANGE_INTERVAL_SEC; } diff --git a/src/UTPexExtensionMessage.cc b/src/UTPexExtensionMessage.cc index 3ac1e9a1..f43c291a 100644 --- a/src/UTPexExtensionMessage.cc +++ b/src/UTPexExtensionMessage.cc @@ -100,10 +100,10 @@ UTPexExtensionMessage::createCompactPeerListAndFlag (compact, (*itr)->getIPAddress(), (*itr)->getPort()); if(compactlen == COMPACT_LEN_IPV4) { addrstring.append(&compact[0], &compact[compactlen]); - flagstring += (*itr)->isSeeder() ? 0x02 : 0x00; + flagstring += (*itr)->isSeeder() ? 0x02u : 0x00u; } else if(compactlen == COMPACT_LEN_IPV6) { addrstring6.append(&compact[0], &compact[compactlen]); - flagstring6 += (*itr)->isSeeder() ? 0x02 : 0x00; + flagstring6 += (*itr)->isSeeder() ? 0x02u : 0x00u; } } return std::make_pair(std::make_pair(addrstring, flagstring), diff --git a/src/a2netcompat.h b/src/a2netcompat.h index 71bdc481..068ba536 100644 --- a/src/a2netcompat.h +++ b/src/a2netcompat.h @@ -38,7 +38,7 @@ #ifdef __MINGW32__ # ifndef WINVER -# define WINVER 0x501 +# define WINVER 0x501u # endif // !WINVER # ifdef HAVE_WINSOCK2_H # ifndef FD_SETSIZE diff --git a/src/base32.cc b/src/base32.cc index 9c30596d..5e1484b3 100644 --- a/src/base32.cc +++ b/src/base32.cc @@ -53,12 +53,12 @@ std::string encode(const std::string& src) uint64_t buf = 0; for(size_t i = 0; i < src.size(); ++i) { buf <<= 8; - buf += src[i]&0xff; + buf += src[i]&0xffu; ++count; if(count == 5) { char temp[8]; for(size_t j = 0; j < 8; ++j) { - temp[7-j] = B32TABLE[buf&0x1f]; + temp[7-j] = B32TABLE[buf&0x1fu]; buf >>= 5; } ret += std::string(&temp[0], &temp[8]); @@ -82,7 +82,7 @@ std::string encode(const std::string& src) } char temp[7]; for(size_t j = 0; j < r; ++j) { - temp[r-1-j] = B32TABLE[buf&0x1f]; + temp[r-1-j] = B32TABLE[buf&0x1fu]; buf >>= 5; } ret += std::string(&temp[0], &temp[r]); diff --git a/src/bitfield.h b/src/bitfield.h index 94fb563d..eaf3f0a0 100644 --- a/src/bitfield.h +++ b/src/bitfield.h @@ -48,7 +48,7 @@ namespace aria2 { namespace bitfield { // Returns the bit mask for the last byte. For example, nbits = 9, -// then 0x80 is returned. nbits = 12, then 0xf0 is returned. +// then 0x80u is returned. nbits = 12, then 0xf0u is returned. inline unsigned char lastByteMask(size_t nbits) { if(nbits == 0) { @@ -56,7 +56,7 @@ inline unsigned char lastByteMask(size_t nbits) } else { int s = nbits%8; if(s == 0) { - return 0xff; + return 0xffu; } else { return -256 >> s; } diff --git a/src/bittorrent_helper.cc b/src/bittorrent_helper.cc index f0793100..a929f2d3 100644 --- a/src/bittorrent_helper.cc +++ b/src/bittorrent_helper.cc @@ -637,11 +637,11 @@ void computeFastSet } unsigned char tx[24]; memcpy(tx, compact, 4); - if((tx[0] & 0x80) == 0 || (tx[0] & 0x40) == 0) { - tx[2] = 0x00; - tx[3] = 0x00; + if((tx[0] & 0x80u) == 0 || (tx[0] & 0x40u) == 0) { + tx[2] = 0x00u; + tx[3] = 0x00u; } else { - tx[3] = 0x00; + tx[3] = 0x00u; } memcpy(tx+4, infoHash, 20); unsigned char x[20]; diff --git a/src/cookie_helper.cc b/src/cookie_helper.cc index 59df9de2..8db83a10 100644 --- a/src/cookie_helper.cc +++ b/src/cookie_helper.cc @@ -49,8 +49,8 @@ namespace cookie { namespace { bool isDelimiter(unsigned char c) { - return c == 0x09U || in(c, 0x20U, 0x2fU) || in(c, 0x3bU, 0x40U) || - in(c, 0x5bU, 0x60U) || in(c, 0x7bU, 0x7eU); + return c == 0x09u || in(c, 0x20u, 0x2fu) || in(c, 0x3bu, 0x40u) || + in(c, 0x5bu, 0x60u) || in(c, 0x7bu, 0x7eu); } } // namespace @@ -58,7 +58,7 @@ namespace { std::string::const_iterator getNextDigit (std::string::const_iterator first, std::string::const_iterator last) { - for(; first != last && in(static_cast(*first), 0x30U, 0x39U); + for(; first != last && in(static_cast(*first), 0x30u, 0x39u); ++first); return first; } diff --git a/src/util.h b/src/util.h index 216c7673..0e344bfc 100644 --- a/src/util.h +++ b/src/util.h @@ -78,7 +78,7 @@ inline uint64_t ntoh64(uint64_t x) { return x; } inline uint64_t hton64(uint64_t x) { return x; } #else // !WORDS_BIGENDIAN inline uint64_t byteswap64(uint64_t x) { - uint64_t v1 = ntohl(x & 0x00000000ffffffff); + uint64_t v1 = ntohl(x & 0x00000000ffffffffllu); uint64_t v2 = ntohl(x >> 32); return (v1 << 32)|v2; }