From 3cc1ed5e0907e9adb3b258ba1b94e3bda64c4219 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 15 Aug 2007 15:11:01 +0000 Subject: [PATCH] 2007-08-10 Ross Smith II gcc 3.4.4 support: * src/DefaultBtContext.cc: int32_t -> int * src/main.cc: int -> int32_t, int32_t -> int * src/messageDigest.h: uint32_t -> unsigned int * src/NameResolver.h: int32_t -> int * src/PeerConnection.cc: int -> int32_t * src/SpeedCalc.cc: int32_t -> int * src/TrackerUpdateCommand.h: int -> int32_t * src/Util.cc: int32_t -> int * src/Util.h: int32_t -> int * src/Xml2MetalinkProcessor.cc: int -> uint32_t, int64_t -> uint64_t * test/AnnounceListTest.cc: int -> int32_t * test/ChunkedEncodingTest.cc: int -> int32_t * test/DataTest.cc: int -> int32_t * test/DefaultBtRequestFactoryTest.cc: int -> int32_t * test/DefaultPeerListProcessorTest.cc: int -> int32_t * test/DefaultPieceStorageTest.cc: int -> int32_t * test/FeatureConfigTest.cc: int -> int32_t * test/MetalinkEntryTest.cc: int -> int32_t * test/MockBtRequestFactory.h: int -> int32_t * test/MockPieceStorage.h: int -> int32_t * test/OptionTest.cc: int -> int32_t * test/RequestTest.cc: int -> int32_t * test/SegmentManTest.cc: int -> int32_t * test/Xml2MetalinkProcessorTest.cc: int -> int32_t --- ChangeLog | 28 ++++++++++++++++++++++++ src/DefaultBtContext.cc | 2 +- src/NameResolver.h | 4 ++-- src/PeerConnection.cc | 6 +++--- src/SpeedCalc.cc | 2 +- src/TrackerUpdateCommand.h | 2 +- src/Util.cc | 2 +- src/Util.h | 2 +- src/Xml2MetalinkProcessor.cc | 14 ++++++------ src/main.cc | 6 +++--- src/messageDigest.h | 8 +++---- test/AnnounceListTest.cc | 32 ++++++++++++++-------------- test/ChunkedEncodingTest.cc | 6 +++--- test/DataTest.cc | 10 ++++----- test/DefaultBtRequestFactoryTest.cc | 8 +++---- test/DefaultPeerListProcessorTest.cc | 6 +++--- test/DefaultPieceStorageTest.cc | 14 ++++++------ test/FeatureConfigTest.cc | 6 +++--- test/MetalinkEntryTest.cc | 10 ++++----- test/MockBtRequestFactory.h | 2 +- test/MockPieceStorage.h | 4 ++-- test/OptionTest.cc | 2 +- test/RequestTest.cc | 18 ++++++++-------- test/SegmentManTest.cc | 14 ++++++------ test/Xml2MetalinkProcessorTest.cc | 4 ++-- 25 files changed, 120 insertions(+), 92 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba1e37dc..49cf639d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2007-08-10 Ross Smith II + + gcc 3.4.4 support: + * src/DefaultBtContext.cc: int32_t -> int + * src/main.cc: int -> int32_t, int32_t -> int + * src/messageDigest.h: uint32_t -> unsigned int + * src/NameResolver.h: int32_t -> int + * src/PeerConnection.cc: int -> int32_t + * src/SpeedCalc.cc: int32_t -> int + * src/TrackerUpdateCommand.h: int -> int32_t + * src/Util.cc: int32_t -> int + * src/Util.h: int32_t -> int + * src/Xml2MetalinkProcessor.cc: int -> uint32_t, int64_t -> uint64_t + * test/AnnounceListTest.cc: int -> int32_t + * test/ChunkedEncodingTest.cc: int -> int32_t + * test/DataTest.cc: int -> int32_t + * test/DefaultBtRequestFactoryTest.cc: int -> int32_t + * test/DefaultPeerListProcessorTest.cc: int -> int32_t + * test/DefaultPieceStorageTest.cc: int -> int32_t + * test/FeatureConfigTest.cc: int -> int32_t + * test/MetalinkEntryTest.cc: int -> int32_t + * test/MockBtRequestFactory.h: int -> int32_t + * test/MockPieceStorage.h: int -> int32_t + * test/OptionTest.cc: int -> int32_t + * test/RequestTest.cc: int -> int32_t + * test/SegmentManTest.cc: int -> int32_t + * test/Xml2MetalinkProcessorTest.cc: int -> int32_t + 2007-08-10 Ross Smith II Move sleep functions to Util class: diff --git a/src/DefaultBtContext.cc b/src/DefaultBtContext.cc index 29c748ce..17bc22a2 100644 --- a/src/DefaultBtContext.cc +++ b/src/DefaultBtContext.cc @@ -185,7 +185,7 @@ void DefaultBtContext::load(const string& torrentFile) { // retrieve infoHash ShaVisitor v; infoDic->accept(&v); - int32_t len; + int len; v.getHash(infoHash, len); infoHashString = Util::toHex(infoHash, INFO_HASH_LENGTH); // calculate the number of pieces diff --git a/src/NameResolver.h b/src/NameResolver.h index 858227c1..2fc19b6b 100644 --- a/src/NameResolver.h +++ b/src/NameResolver.h @@ -48,10 +48,10 @@ extern "C" { } /* end of extern "C" */ #endif -void callback(void* arg, int32_t status, struct hostent* host); +void callback(void* arg, int status, struct hostent* host); class NameResolver { - friend void callback(void* arg, int32_t status, struct hostent* host); + friend void callback(void* arg, int status, struct hostent* host); public: enum STATUS { diff --git a/src/PeerConnection.cc b/src/PeerConnection.cc index bee3fd48..fd231997 100644 --- a/src/PeerConnection.cc +++ b/src/PeerConnection.cc @@ -79,7 +79,7 @@ bool PeerConnection::receiveMessage(unsigned char* data, int32_t& dataLength) { int32_t remain = 4-lenbufLength; int32_t temp = remain; // TODO fix this - socket->readData((char*)lenbuf+lenbufLength, (int&)temp); + socket->readData((char*)lenbuf+lenbufLength, temp); if(temp == 0) { // we got EOF throw new DlAbortEx(EX_EOF_FROM_PEER); @@ -103,7 +103,7 @@ bool PeerConnection::receiveMessage(unsigned char* data, int32_t& dataLength) { // we have currentPayloadLen-resbufLen bytes to read int32_t remaining = currentPayloadLength-resbufLength; if(remaining > 0) { - socket->readData((char*)resbuf+resbufLength, (int&)remaining); + socket->readData((char*)resbuf+resbufLength, remaining); if(remaining == 0) { // we got EOF throw new DlAbortEx(EX_EOF_FROM_PEER); @@ -129,7 +129,7 @@ bool PeerConnection::receiveHandshake(unsigned char* data, int32_t& dataLength) } int32_t remain = BtHandshakeMessage::MESSAGE_LENGTH-resbufLength; int32_t temp = remain; - socket->readData((char*)resbuf+resbufLength, (int&)temp); + socket->readData((char*)resbuf+resbufLength, temp); if(temp == 0) { // we got EOF throw new DlAbortEx(EX_EOF_FROM_PEER); diff --git a/src/SpeedCalc.cc b/src/SpeedCalc.cc index 65346de4..629d7d2d 100644 --- a/src/SpeedCalc.cc +++ b/src/SpeedCalc.cc @@ -92,7 +92,7 @@ public: } }; -void SpeedCalc::update(int32_t bytes) { +void SpeedCalc::update(int bytes) { accumulatedLength += bytes; for_each(&lengthArray[0], &lengthArray[2], Plus(bytes)); if(isIntervalOver()) { diff --git a/src/TrackerUpdateCommand.h b/src/TrackerUpdateCommand.h index 3830639e..3c50fe9d 100644 --- a/src/TrackerUpdateCommand.h +++ b/src/TrackerUpdateCommand.h @@ -46,7 +46,7 @@ private: bool prepareForRetry(); string getTrackerResponse(); public: - TrackerUpdateCommand(int cuid, + TrackerUpdateCommand(int32_t cuid, TorrentDownloadEngine* e, const BtContextHandle& btContext); diff --git a/src/Util.cc b/src/Util.cc index 34b8b6e6..70152d08 100644 --- a/src/Util.cc +++ b/src/Util.cc @@ -560,7 +560,7 @@ bool Util::isNumbersAndDotsNotation(const string& name) { } } -void Util::setGlobalSignalHandler(int32_t sig, void (*handler)(int32_t), int32_t flags) { +void Util::setGlobalSignalHandler(int32_t sig, void (*handler)(int), int32_t flags) { #ifdef HAVE_SIGACTION struct sigaction sigact; sigact.sa_handler = handler; diff --git a/src/Util.h b/src/Util.h index cedd3e01..6d733636 100644 --- a/src/Util.h +++ b/src/Util.h @@ -116,7 +116,7 @@ public: static bool isNumbersAndDotsNotation(const string& name); - static void setGlobalSignalHandler(int32_t signal, void (*handler)(int32_t), int32_t flags); + static void setGlobalSignalHandler(int32_t signal, void (*handler)(int), int32_t flags); static void indexRange(int32_t& startIndex, int32_t& endIndex, int64_t offset, diff --git a/src/Xml2MetalinkProcessor.cc b/src/Xml2MetalinkProcessor.cc index f1743821..93e37174 100644 --- a/src/Xml2MetalinkProcessor.cc +++ b/src/Xml2MetalinkProcessor.cc @@ -75,8 +75,8 @@ MetalinkerHandle Xml2MetalinkProcessor::parseFile(const string& filename) { string xpath = "/m:metalink/m:files/m:file"; MetalinkerHandle metalinker(new Metalinker()); - for(int index = 1; 1; index++) { - MetalinkEntryHandle entry = getEntry(xpath+"["+Util::itos(index)+"]"); + for(uint32_t index = 1; 1; index++) { + MetalinkEntryHandle entry = getEntry(xpath+"["+Util::uitos(index)+"]"); if(!entry.get()) { break; } else { @@ -151,8 +151,8 @@ MetalinkEntryHandle Xml2MetalinkProcessor::getEntry(const string& xpath) { } */ #endif // ENABLE_MESSAGE_DIGEST - for(int index = 1; 1; index++) { - MetalinkResourceHandle resource(getResource(xpath+"/m:resources/m:url["+Util::itos(index)+"]")); + for(uint32_t index = 1; 1; index++) { + MetalinkResourceHandle resource(getResource(xpath+"/m:resources/m:url["+Util::uitos(index)+"]")); if(!resource.get()) { break; } else { @@ -183,11 +183,11 @@ ChunkChecksumHandle Xml2MetalinkProcessor::getPieceHash(const string& xpath, } Strings checksums; - int64_t numPiece = (totalSize+checksumLength-1)/checksumLength; - for(int64_t i = 0; i < numPiece; ++i) { + uint64_t numPiece = (totalSize+checksumLength-1)/checksumLength; + for(uint64_t i = 0; i < numPiece; ++i) { string pieceHash = Util::trim(xpathContent(xpath+"/m:hash[@piece=\""+Util::ullitos(i)+"\"]")); if(pieceHash == "") { - throw new DlAbortEx("Piece hash missing. index=%d", i); + throw new DlAbortEx("Piece hash missing. index=%s", Util::ullitos(i)); } checksums.push_back(pieceHash); } diff --git a/src/main.cc b/src/main.cc index 6a295d04..e8ce8aba 100644 --- a/src/main.cc +++ b/src/main.cc @@ -352,7 +352,7 @@ int main(int argc, char* argv[]) { op->put(PREF_DIR, "."); op->put(PREF_SPLIT, "1"); op->put(PREF_DAEMON, V_FALSE); - op->put(PREF_SEGMENT_SIZE, Util::itos(1024*1024)); + op->put(PREF_SEGMENT_SIZE, Util::itos((int32_t)(1024*1024))); op->put(PREF_HTTP_KEEP_ALIVE, V_FALSE); op->put(PREF_LISTEN_PORT, "-1"); op->put(PREF_METALINK_SERVERS, "5"); @@ -401,8 +401,8 @@ int main(int argc, char* argv[]) { op->put(PREF_MAX_CONCURRENT_DOWNLOADS, "5"); op->put(PREF_DIRECT_DOWNLOAD_TIMEOUT, "15"); while(1) { - int32_t optIndex = 0; - int32_t lopt; + int optIndex = 0; + int lopt; static struct option longOpts[] = { #ifdef HAVE_DAEMON { "daemon", no_argument, NULL, 'D' }, diff --git a/src/messageDigest.h b/src/messageDigest.h index 0f309feb..7bf37685 100644 --- a/src/messageDigest.h +++ b/src/messageDigest.h @@ -121,8 +121,8 @@ public: void digestReset() {EVP_DigestInit(&ctx, algo);} void digestUpdate(const void* data, int32_t length) {EVP_DigestUpdate(&ctx, data, length);} void digestFinal(unsigned char* md) { - int32_t len; - EVP_DigestFinal(&ctx, md, (uint32_t*)&len); + unsigned int len; + EVP_DigestFinal(&ctx, md, &len); } void digestFree() {/*empty*/} int32_t digestLength() const { @@ -144,8 +144,8 @@ public: EVP_DigestUpdate(&ctx, data, length); } void digestFinal(unsigned char* md) { - int32_t len; - EVP_DigestFinal_ex(&ctx, md, (uint32_t*)&len); + unsigned int len; + EVP_DigestFinal_ex(&ctx, md, &len); } void digestFree() { EVP_MD_CTX_cleanup(&ctx); diff --git a/test/AnnounceListTest.cc b/test/AnnounceListTest.cc index a081da39..56b45cdf 100644 --- a/test/AnnounceListTest.cc +++ b/test/AnnounceListTest.cc @@ -174,22 +174,22 @@ void AnnounceListTest::testCountStoppedAllowedTier() { // [ [ tracker1 ], [ tracker2 ], [ tracker3 ] ] AnnounceList announceList(announces); - CPPUNIT_ASSERT_EQUAL(0, announceList.countStoppedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countStoppedAllowedTier()); announceList.setEvent(AnnounceTier::STARTED); - CPPUNIT_ASSERT_EQUAL(0, announceList.countStoppedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countStoppedAllowedTier()); announceList.setEvent(AnnounceTier::STARTED_AFTER_COMPLETION); - CPPUNIT_ASSERT_EQUAL(0, announceList.countStoppedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countStoppedAllowedTier()); announceList.setEvent(AnnounceTier::HALTED); - CPPUNIT_ASSERT_EQUAL(0, announceList.countStoppedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countStoppedAllowedTier()); announceList.setEvent(AnnounceTier::DOWNLOADING); - CPPUNIT_ASSERT_EQUAL(1, announceList.countStoppedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, announceList.countStoppedAllowedTier()); announceList.setEvent(AnnounceTier::STOPPED); - CPPUNIT_ASSERT_EQUAL(1, announceList.countStoppedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, announceList.countStoppedAllowedTier()); announceList.setEvent(AnnounceTier::COMPLETED); - CPPUNIT_ASSERT_EQUAL(1, announceList.countStoppedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, announceList.countStoppedAllowedTier()); announceList.setEvent(AnnounceTier::SEEDING); - CPPUNIT_ASSERT_EQUAL(1, announceList.countStoppedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, announceList.countStoppedAllowedTier()); } @@ -201,22 +201,22 @@ void AnnounceListTest::testCountCompletedAllowedTier() { // [ [ tracker1 ], [ tracker2 ], [ tracker3 ] ] AnnounceList announceList(announces); - CPPUNIT_ASSERT_EQUAL(0, announceList.countCompletedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countCompletedAllowedTier()); announceList.setEvent(AnnounceTier::STARTED); - CPPUNIT_ASSERT_EQUAL(0, announceList.countCompletedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countCompletedAllowedTier()); announceList.setEvent(AnnounceTier::STARTED_AFTER_COMPLETION); - CPPUNIT_ASSERT_EQUAL(0, announceList.countCompletedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countCompletedAllowedTier()); announceList.setEvent(AnnounceTier::STOPPED); - CPPUNIT_ASSERT_EQUAL(0, announceList.countCompletedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countCompletedAllowedTier()); announceList.setEvent(AnnounceTier::SEEDING); - CPPUNIT_ASSERT_EQUAL(0, announceList.countCompletedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countCompletedAllowedTier()); announceList.setEvent(AnnounceTier::HALTED); - CPPUNIT_ASSERT_EQUAL(0, announceList.countCompletedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, announceList.countCompletedAllowedTier()); announceList.setEvent(AnnounceTier::DOWNLOADING); - CPPUNIT_ASSERT_EQUAL(1, announceList.countCompletedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, announceList.countCompletedAllowedTier()); announceList.setEvent(AnnounceTier::COMPLETED); - CPPUNIT_ASSERT_EQUAL(1, announceList.countCompletedAllowedTier()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, announceList.countCompletedAllowedTier()); } diff --git a/test/ChunkedEncodingTest.cc b/test/ChunkedEncodingTest.cc index 0515d80e..648383cb 100644 --- a/test/ChunkedEncodingTest.cc +++ b/test/ChunkedEncodingTest.cc @@ -31,7 +31,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( ChunkedEncodingTest ); void ChunkedEncodingTest::testInflate1() { string msg = "a\r\n1234567890\r\n"; char buf[100]; - int len = sizeof(buf); + int32_t len = sizeof(buf); enc->inflate(buf, len, msg.c_str(), msg.size()); buf[len] = '\0'; CPPUNIT_ASSERT_EQUAL(string("1234567890"), string(buf)); @@ -54,7 +54,7 @@ void ChunkedEncodingTest::testInflateLargeChunk() { string body; is >> body; char buf[4097]; - int len = sizeof(buf); + int32_t len = sizeof(buf); for(int i = 0; i < 2; i++) { string msg = "1000\r\n"+body+"\r\n"; len = sizeof(buf); @@ -63,7 +63,7 @@ void ChunkedEncodingTest::testInflateLargeChunk() { CPPUNIT_ASSERT_EQUAL(body, string(buf)); } enc->inflate(buf, len, "0\r\n", 3); - CPPUNIT_ASSERT_EQUAL(0, len); + CPPUNIT_ASSERT_EQUAL((int32_t)0, len); CPPUNIT_ASSERT(enc->finished()); } diff --git a/test/DataTest.cc b/test/DataTest.cc index da678977..3f0e3287 100644 --- a/test/DataTest.cc +++ b/test/DataTest.cc @@ -39,23 +39,23 @@ void DataTest::testGetData() { Data data("aria2", 5); int len; CPPUNIT_ASSERT_EQUAL(0, memcmp("aria2", data.getData(), 5)); - CPPUNIT_ASSERT_EQUAL(5, data.getLen()); + CPPUNIT_ASSERT_EQUAL((int32_t)5, data.getLen()); Data null(NULL, 0); CPPUNIT_ASSERT_EQUAL((const char*)NULL, null.getData()); - CPPUNIT_ASSERT_EQUAL(0, null.getLen()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, null.getLen()); } void DataTest::testToInt() { Data data("1000", 4); - CPPUNIT_ASSERT_EQUAL(1000, data.toInt()); + CPPUNIT_ASSERT_EQUAL((int32_t)1000, data.toInt()); Data null(NULL, 0); - CPPUNIT_ASSERT_EQUAL(0, null.toInt()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, null.toInt()); Data alpha("abc", 3); - CPPUNIT_ASSERT_EQUAL(0, alpha.toInt()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, alpha.toInt()); } void DataTest::testToLLInt() { diff --git a/test/DefaultBtRequestFactoryTest.cc b/test/DefaultBtRequestFactoryTest.cc index d8d083fa..6c91eedc 100644 --- a/test/DefaultBtRequestFactoryTest.cc +++ b/test/DefaultBtRequestFactoryTest.cc @@ -106,7 +106,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION(DefaultBtRequestFactoryTest); void DefaultBtRequestFactoryTest::testAddTargetPiece() { PieceHandle piece = new Piece(0, 16*1024); btRequestFactory->addTargetPiece(piece); - CPPUNIT_ASSERT_EQUAL(1, btRequestFactory->countTargetPiece()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, btRequestFactory->countTargetPiece()); } void DefaultBtRequestFactoryTest::testRemoveCompletedPiece() { @@ -115,10 +115,10 @@ void DefaultBtRequestFactoryTest::testRemoveCompletedPiece() { piece2->setAllBlock(); btRequestFactory->addTargetPiece(piece1); btRequestFactory->addTargetPiece(piece2); - CPPUNIT_ASSERT_EQUAL(2, btRequestFactory->countTargetPiece()); + CPPUNIT_ASSERT_EQUAL((int32_t)2, btRequestFactory->countTargetPiece()); btRequestFactory->removeCompletedPiece(); - CPPUNIT_ASSERT_EQUAL(1, btRequestFactory->countTargetPiece()); - CPPUNIT_ASSERT_EQUAL(0, btRequestFactory->getTargetPieces().front()->getIndex()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, btRequestFactory->countTargetPiece()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, btRequestFactory->getTargetPieces().front()->getIndex()); } void DefaultBtRequestFactoryTest::testCreateRequestMessages() { diff --git a/test/DefaultPeerListProcessorTest.cc b/test/DefaultPeerListProcessorTest.cc index 0d2e4ef7..f70abee2 100644 --- a/test/DefaultPeerListProcessorTest.cc +++ b/test/DefaultPeerListProcessorTest.cc @@ -36,7 +36,7 @@ void DefaultPeerListProcessorTest::testExtractPeer() { CPPUNIT_ASSERT_EQUAL((size_t)1, peers.size()); PeerHandle peer = *peers.begin(); CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"), peer->ipaddr); - CPPUNIT_ASSERT_EQUAL(2006, peer->port); + CPPUNIT_ASSERT_EQUAL((int32_t)2006, peer->port); } void DefaultPeerListProcessorTest::testExtract2Peers() { @@ -49,9 +49,9 @@ void DefaultPeerListProcessorTest::testExtract2Peers() { CPPUNIT_ASSERT_EQUAL((size_t)2, peers.size()); PeerHandle peer = *peers.begin(); CPPUNIT_ASSERT_EQUAL(string("192.168.0.1"), peer->ipaddr); - CPPUNIT_ASSERT_EQUAL(2006, peer->port); + CPPUNIT_ASSERT_EQUAL((int32_t)2006, peer->port); peer = *(peers.begin()+1); CPPUNIT_ASSERT_EQUAL(string("192.168.0.2"), peer->ipaddr); - CPPUNIT_ASSERT_EQUAL(2007, peer->port); + CPPUNIT_ASSERT_EQUAL((int32_t)2007, peer->port); } diff --git a/test/DefaultPieceStorageTest.cc b/test/DefaultPieceStorageTest.cc index 067309da..a20467cf 100644 --- a/test/DefaultPieceStorageTest.cc +++ b/test/DefaultPieceStorageTest.cc @@ -125,8 +125,8 @@ void DefaultPieceStorageTest::testGetPiece() { DefaultPieceStorage pss(btContext, option); PieceHandle pieceGot = pss.getPiece(0); - CPPUNIT_ASSERT_EQUAL(0, pieceGot->getIndex()); - CPPUNIT_ASSERT_EQUAL(128, pieceGot->getLength()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, pieceGot->getIndex()); + CPPUNIT_ASSERT_EQUAL((int32_t)128, pieceGot->getLength()); CPPUNIT_ASSERT_EQUAL(false, pieceGot->pieceComplete()); } @@ -136,9 +136,9 @@ void DefaultPieceStorageTest::testGetPieceInUsedPieces() { piece->completeBlock(0); pss.addUsedPiece(piece); PieceHandle pieceGot = pss.getPiece(0); - CPPUNIT_ASSERT_EQUAL(0, pieceGot->getIndex()); - CPPUNIT_ASSERT_EQUAL(128, pieceGot->getLength()); - CPPUNIT_ASSERT_EQUAL(1, pieceGot->countCompleteBlock()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, pieceGot->getIndex()); + CPPUNIT_ASSERT_EQUAL((int32_t)128, pieceGot->getLength()); + CPPUNIT_ASSERT_EQUAL((int32_t)1, pieceGot->countCompleteBlock()); } void DefaultPieceStorageTest::testGetPieceCompletedPiece() { @@ -146,7 +146,7 @@ void DefaultPieceStorageTest::testGetPieceCompletedPiece() { PieceHandle piece = PieceHandle(new Piece(0, 128)); pss.completePiece(piece); PieceHandle pieceGot = pss.getPiece(0); - CPPUNIT_ASSERT_EQUAL(0, pieceGot->getIndex()); - CPPUNIT_ASSERT_EQUAL(128, pieceGot->getLength()); + CPPUNIT_ASSERT_EQUAL((int32_t)0, pieceGot->getIndex()); + CPPUNIT_ASSERT_EQUAL((int32_t)128, pieceGot->getLength()); CPPUNIT_ASSERT_EQUAL(true, pieceGot->pieceComplete()); } diff --git a/test/FeatureConfigTest.cc b/test/FeatureConfigTest.cc index ec493974..652fd679 100644 --- a/test/FeatureConfigTest.cc +++ b/test/FeatureConfigTest.cc @@ -20,11 +20,11 @@ public: CPPUNIT_TEST_SUITE_REGISTRATION(FeatureConfigTest); void FeatureConfigTest::testGetDefaultPort() { - CPPUNIT_ASSERT_EQUAL(80, + CPPUNIT_ASSERT_EQUAL((int32_t)80, FeatureConfig::getInstance()->getDefaultPort("http")); - CPPUNIT_ASSERT_EQUAL(443, + CPPUNIT_ASSERT_EQUAL((int32_t)443, FeatureConfig::getInstance()->getDefaultPort("https")); - CPPUNIT_ASSERT_EQUAL(21, + CPPUNIT_ASSERT_EQUAL((int32_t)21, FeatureConfig::getInstance()->getDefaultPort("ftp")); } diff --git a/test/MetalinkEntryTest.cc b/test/MetalinkEntryTest.cc index 37be134a..3cde0d4e 100644 --- a/test/MetalinkEntryTest.cc +++ b/test/MetalinkEntryTest.cc @@ -92,9 +92,9 @@ void MetalinkEntryTest::testReorderResourcesByPreference() { entry->reorderResourcesByPreference(); - CPPUNIT_ASSERT_EQUAL(100, entry->resources.at(0)->preference); - CPPUNIT_ASSERT_EQUAL(90, entry->resources.at(1)->preference); - CPPUNIT_ASSERT_EQUAL(60, entry->resources.at(2)->preference); - CPPUNIT_ASSERT_EQUAL(50, entry->resources.at(3)->preference); - CPPUNIT_ASSERT_EQUAL(10, entry->resources.at(4)->preference); + CPPUNIT_ASSERT_EQUAL((int32_t)100, entry->resources.at(0)->preference); + CPPUNIT_ASSERT_EQUAL((int32_t)90, entry->resources.at(1)->preference); + CPPUNIT_ASSERT_EQUAL((int32_t)60, entry->resources.at(2)->preference); + CPPUNIT_ASSERT_EQUAL((int32_t)50, entry->resources.at(3)->preference); + CPPUNIT_ASSERT_EQUAL((int32_t)10, entry->resources.at(4)->preference); } diff --git a/test/MockBtRequestFactory.h b/test/MockBtRequestFactory.h index 7331c40a..0e38e07c 100644 --- a/test/MockBtRequestFactory.h +++ b/test/MockBtRequestFactory.h @@ -13,7 +13,7 @@ public: virtual void removeAllTargetPiece() {} - virtual int countTargetPiece() { return 0; } + virtual int32_t countTargetPiece() { return 0; } virtual void removeCompletedPiece() {} diff --git a/test/MockPieceStorage.h b/test/MockPieceStorage.h index e53c3d60..59db1dc8 100644 --- a/test/MockPieceStorage.h +++ b/test/MockPieceStorage.h @@ -31,7 +31,7 @@ public: return new Piece(); } - virtual PieceHandle getPiece(int index) { + virtual PieceHandle getPiece(int32_t index) { return new Piece(); } @@ -39,7 +39,7 @@ public: virtual void cancelPiece(const PieceHandle& piece) {} - virtual bool hasPiece(int index) { + virtual bool hasPiece(int32_t index) { return false; } diff --git a/test/OptionTest.cc b/test/OptionTest.cc index 3bb1b683..c3fc830b 100644 --- a/test/OptionTest.cc +++ b/test/OptionTest.cc @@ -38,7 +38,7 @@ void OptionTest::testPutAndGetAsInt() { op.put("key", "1000"); CPPUNIT_ASSERT(op.defined("key")); - CPPUNIT_ASSERT_EQUAL(1000, op.getAsInt("key")); + CPPUNIT_ASSERT_EQUAL((int32_t)1000, op.getAsInt("key")); } void OptionTest::testPutAndGetAsDouble() { diff --git a/test/RequestTest.cc b/test/RequestTest.cc index 3840ea22..c026e8c1 100644 --- a/test/RequestTest.cc +++ b/test/RequestTest.cc @@ -72,7 +72,7 @@ void RequestTest::testSetUrl1() { CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.com/"), req.getCurrentUrl()); CPPUNIT_ASSERT_EQUAL(string(""), req.getPreviousUrl()); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); - CPPUNIT_ASSERT_EQUAL(80, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)80, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost()); CPPUNIT_ASSERT_EQUAL(string("/"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string(""), req.getFile()); @@ -90,7 +90,7 @@ void RequestTest::testSetUrl2() { // previousUrl must equal to referer; CPPUNIT_ASSERT_EQUAL(req.getReferer(), req.getPreviousUrl()); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); - CPPUNIT_ASSERT_EQUAL(8080, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)8080, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost()); CPPUNIT_ASSERT_EQUAL(string("/"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string("index.html"), req.getFile()); @@ -102,7 +102,7 @@ void RequestTest::testSetUrl3() { CPPUNIT_ASSERT(v); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); - CPPUNIT_ASSERT_EQUAL(80, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)80, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost()); CPPUNIT_ASSERT_EQUAL(string("/aria2"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string("index.html"), req.getFile()); @@ -114,7 +114,7 @@ void RequestTest::testSetUrl4() { CPPUNIT_ASSERT(v); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); - CPPUNIT_ASSERT_EQUAL(80, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)80, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost()); CPPUNIT_ASSERT_EQUAL(string("/aria2/aria3"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string("index.html"), req.getFile()); @@ -126,7 +126,7 @@ void RequestTest::testSetUrl5() { CPPUNIT_ASSERT(v); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); - CPPUNIT_ASSERT_EQUAL(80, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)80, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost()); CPPUNIT_ASSERT_EQUAL(string("/aria2/aria3"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string(""), req.getFile()); @@ -138,7 +138,7 @@ void RequestTest::testSetUrl6() { CPPUNIT_ASSERT(v); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); - CPPUNIT_ASSERT_EQUAL(80, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)80, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost()); CPPUNIT_ASSERT_EQUAL(string("/aria2"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string("aria3"), req.getFile()); @@ -212,7 +212,7 @@ void RequestTest::testSetUrl14() { CPPUNIT_ASSERT(v); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); CPPUNIT_ASSERT_EQUAL(string("host"), req.getHost()); - CPPUNIT_ASSERT_EQUAL(8080, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)8080, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("/"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string("abc?query"), req.getFile()); } @@ -232,7 +232,7 @@ void RequestTest::testRedirectUrl() { CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.com:8080/aria2/index.html"), req.getPreviousUrl()); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.co.jp"), req.getHost()); - CPPUNIT_ASSERT_EQUAL(80, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)80, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("/"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string(""), req.getFile()); } @@ -273,7 +273,7 @@ void RequestTest::testResetUrl() { // referer is unchanged CPPUNIT_ASSERT_EQUAL(string("http://aria.rednoah.com:8080/"), req.getReferer()); CPPUNIT_ASSERT_EQUAL(string("http"), req.getProtocol()); - CPPUNIT_ASSERT_EQUAL(8080, req.getPort()); + CPPUNIT_ASSERT_EQUAL((int32_t)8080, req.getPort()); CPPUNIT_ASSERT_EQUAL(string("aria.rednoah.com"), req.getHost()); CPPUNIT_ASSERT_EQUAL(string("/aria2"), req.getDir()); CPPUNIT_ASSERT_EQUAL(string("index.html"), req.getFile()); diff --git a/test/SegmentManTest.cc b/test/SegmentManTest.cc index 2d124159..335f4fa2 100644 --- a/test/SegmentManTest.cc +++ b/test/SegmentManTest.cc @@ -83,15 +83,15 @@ void SegmentManTest::testSaveAndLoad() { void SegmentManTest::testNullBitfield() { SegmentMan segmentMan; Option op; - op.put(PREF_SEGMENT_SIZE, Util::itos(1024*1024)); + op.put(PREF_SEGMENT_SIZE, Util::itos((int32_t)(1024*1024))); segmentMan.option = &op; SegmentHandle segment = segmentMan.getSegment(1); CPPUNIT_ASSERT(!segment.isNull()); - CPPUNIT_ASSERT_EQUAL(0, segment->index); - CPPUNIT_ASSERT_EQUAL(0, segment->length); - CPPUNIT_ASSERT_EQUAL(0, segment->segmentLength); - CPPUNIT_ASSERT_EQUAL(0, segment->writtenLength); + CPPUNIT_ASSERT_EQUAL((int32_t)0, segment->index); + CPPUNIT_ASSERT_EQUAL((int32_t)0, segment->length); + CPPUNIT_ASSERT_EQUAL((int32_t)0, segment->segmentLength); + CPPUNIT_ASSERT_EQUAL((int32_t)0, segment->writtenLength); SegmentHandle segment2 = segmentMan.getSegment(2); CPPUNIT_ASSERT(segment2.isNull()); @@ -145,8 +145,8 @@ void SegmentManTest::testMarkPieceDone_usedSegment() SegmentHandle segment = segmentMan.getSegment(0, 5); CPPUNIT_ASSERT(!segment.isNull()); - CPPUNIT_ASSERT_EQUAL(5, segment->index); + CPPUNIT_ASSERT_EQUAL((int32_t)5, segment->index); CPPUNIT_ASSERT_EQUAL(pieceLength, (int32_t) segment->length); CPPUNIT_ASSERT_EQUAL(pieceLength, (int32_t) segment->segmentLength); - CPPUNIT_ASSERT_EQUAL(100, segment->writtenLength); + CPPUNIT_ASSERT_EQUAL((int32_t)100, segment->writtenLength); } diff --git a/test/Xml2MetalinkProcessorTest.cc b/test/Xml2MetalinkProcessorTest.cc index 801e05c1..53b5058d 100644 --- a/test/Xml2MetalinkProcessorTest.cc +++ b/test/Xml2MetalinkProcessorTest.cc @@ -46,14 +46,14 @@ void Xml2MetalinkProcessorTest::testParseFile() { MetalinkResourceHandle resource1 = *resourceItr1; CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_FTP, resource1->type); CPPUNIT_ASSERT_EQUAL(string("jp"), resource1->location); - CPPUNIT_ASSERT_EQUAL(100, resource1->preference); + CPPUNIT_ASSERT_EQUAL((int32_t)100, resource1->preference); CPPUNIT_ASSERT_EQUAL(string("ftp://ftphost/aria2-0.5.2.tar.bz2"), resource1->url); resourceItr1++; MetalinkResourceHandle resource2 = *resourceItr1; CPPUNIT_ASSERT_EQUAL(MetalinkResource::TYPE_HTTP, resource2->type); CPPUNIT_ASSERT_EQUAL(string("us"), resource2->location); - CPPUNIT_ASSERT_EQUAL(100, resource2->preference); + CPPUNIT_ASSERT_EQUAL((int32_t)100, resource2->preference); CPPUNIT_ASSERT_EQUAL(string("http://httphost/aria2-0.5.2.tar.bz2"), resource2->url);