Procházet zdrojové kódy

Fix compile warning with Mingw64 x86 build

Tatsuhiro Tsujikawa před 10 roky
rodič
revize
1adef4db0c

+ 1 - 1
src/BtPieceMessage.cc

@@ -213,7 +213,7 @@ void BtPieceMessage::send()
 
 void BtPieceMessage::pushPieceData(int64_t offset, int32_t length) const
 {
-  assert(length <= 16_k);
+  assert(length <= static_cast<int32_t>(16_k));
   auto buf = make_unique<unsigned char[]>(length+MESSAGE_HEADER_LENGTH);
   createMessageHeader(buf.get());
   ssize_t r;

+ 1 - 1
src/HandshakeExtensionMessage.cc

@@ -215,7 +215,7 @@ HandshakeExtensionMessage::create(const unsigned char* data, size_t length)
 
     // Only accept metadata smaller than 1MiB.  Be aware that broken
     // client can send negative size!
-    if(size > 0 && size <= 1_m) {
+    if(size > 0 && size <= static_cast<int64_t>(1_m)) {
       msg->metadataSize_ = size;
     }
   }

+ 3 - 3
src/bittorrent_helper.cc

@@ -792,9 +792,9 @@ void checkBegin(int32_t begin, int32_t pieceLength)
 
 void checkLength(int32_t length)
 {
-  if(length > MAX_BLOCK_LENGTH) {
-    throw DL_ABORT_EX
-      (fmt("Length too long: %d > %luKB", length, MAX_BLOCK_LENGTH/1024));
+  if(length > static_cast<int32_t>(MAX_BLOCK_LENGTH)) {
+    throw DL_ABORT_EX(fmt("Length too long: %d > %dKB", length,
+                          static_cast<int32_t>(MAX_BLOCK_LENGTH / 1024)));
   }
   if(length == 0) {
     throw DL_ABORT_EX(fmt("Invalid length: %d", length));

+ 2 - 1
src/util.cc

@@ -1405,7 +1405,8 @@ std::string abbrevSize(int64_t size)
   int64_t t = size;
   size_t uidx = 0;
   int r = 0;
-  while(t >= 1_k && uidx+1 < sizeof(UNITS)/sizeof(UNITS[0])) {
+  while(t >= static_cast<int64_t>(1_k) &&
+        uidx + 1 < sizeof(UNITS) / sizeof(UNITS[0])) {
     lldiv_t d = lldiv(t, 1_k);
     t = d.quot;
     r = d.rem;