Selaa lähdekoodia

2010-10-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	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
Tatsuhiro Tsujikawa 15 vuotta sitten
vanhempi
commit
983b6006fd

+ 23 - 0
ChangeLog

@@ -1,3 +1,26 @@
+2010-10-10  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	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  <t-tujikawa@users.sourceforge.net>
 
 	Added util::lowercase() and util::uppercase().

+ 9 - 9
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;
 }

+ 2 - 2
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;
     }
   }

+ 5 - 5
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<BtHandshakeMessage>
@@ -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)

+ 2 - 2
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;
     }
   }
 

+ 1 - 1
src/DHTBucket.cc

@@ -68,7 +68,7 @@ DHTBucket::DHTBucket(const SharedHandle<DHTNode>& 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);
 }
 

+ 8 - 8
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));

+ 4 - 4
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));

+ 1 - 1
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

+ 2 - 2
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:

+ 0 - 4
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;

+ 1 - 1
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 <winsock2.h>
 #undef ERROR

+ 1 - 1
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;
 }

+ 2 - 2
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),

+ 1 - 1
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

+ 3 - 3
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]);

+ 2 - 2
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;
     }

+ 4 - 4
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];

+ 3 - 3
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<unsigned char>(*first), 0x30U, 0x39U);
+  for(; first != last && in(static_cast<unsigned char>(*first), 0x30u, 0x39u);
       ++first);
   return first;
 }

+ 1 - 1
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;
 }