From 4a59e5899a40e027fc8ccc57b21fe175e857913c Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 29 Nov 2007 11:33:50 +0000 Subject: [PATCH] 2007-11-29 Tatsuhiro Tsujikawa Eliminated g++-4.2 warning * src/DownloadHandlerConstants.{h, cc} * src/Util.cc * test/MetaFileUtilTest.cc * test/PStringBuildVisitorTest.cc Fixed bug: --check-integrity dones't work for multi file torrent. * src/RequestGroup.cc * src/BtCheckIntegrityEntry.cc --- ChangeLog | 12 ++++++++++++ src/BtCheckIntegrityEntry.cc | 2 ++ src/DownloadHandlerConstants.cc | 8 ++++---- src/DownloadHandlerConstants.h | 8 ++++---- src/RequestGroup.cc | 3 +-- src/Util.cc | 2 +- test/MetaFileUtilTest.cc | 8 ++++---- test/PStringBuildVisitorTest.cc | 4 ++-- 8 files changed, 30 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14e52ac2..937fc75e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-11-29 Tatsuhiro Tsujikawa + + Eliminated g++-4.2 warning + * src/DownloadHandlerConstants.{h, cc} + * src/Util.cc + * test/MetaFileUtilTest.cc + * test/PStringBuildVisitorTest.cc + + Fixed bug: --check-integrity dones't work for multi file torrent. + * src/RequestGroup.cc + * src/BtCheckIntegrityEntry.cc + 2007-11-29 Tatsuhiro Tsujikawa Fixed a2io.h diff --git a/src/BtCheckIntegrityEntry.cc b/src/BtCheckIntegrityEntry.cc index 284ade50..1481e86e 100644 --- a/src/BtCheckIntegrityEntry.cc +++ b/src/BtCheckIntegrityEntry.cc @@ -40,6 +40,7 @@ #include "PieceStorage.h" #include "DownloadEngine.h" #include "FileAllocationMan.h" +#include "DiskAdaptor.h" BtCheckIntegrityEntry::BtCheckIntegrityEntry(RequestGroup* requestGroup): PieceHashCheckIntegrityEntry(requestGroup, 0) {} @@ -60,6 +61,7 @@ Commands BtCheckIntegrityEntry::onDownloadIncomplete(DownloadEngine* e) Commands BtCheckIntegrityEntry::onDownloadFinished(DownloadEngine* e) { + _requestGroup->getPieceStorage()->getDiskAdaptor()->onDownloadComplete(); // TODO Currently,when all the checksums // are valid, then aira2 goes to seeding mode. Sometimes it is better // to exit rather than doing seeding. So, it would be good to toggle this diff --git a/src/DownloadHandlerConstants.cc b/src/DownloadHandlerConstants.cc index 92a4ecff..6227df05 100644 --- a/src/DownloadHandlerConstants.cc +++ b/src/DownloadHandlerConstants.cc @@ -34,15 +34,15 @@ /* copyright --> */ #include "DownloadHandlerConstants.h" -char* DownloadHandlerConstants::METALINK_EXTENSIONS[] = { ".metalink" }; +const char* DownloadHandlerConstants::METALINK_EXTENSIONS[] = { ".metalink" }; -char* DownloadHandlerConstants::METALINK_CONTENT_TYPES[] = { +const char* DownloadHandlerConstants::METALINK_CONTENT_TYPES[] = { "application/metalink+xml" }; -char* DownloadHandlerConstants::BT_EXTENSIONS[] = { ".torrent" }; +const char* DownloadHandlerConstants::BT_EXTENSIONS[] = { ".torrent" }; -char* DownloadHandlerConstants::BT_CONTENT_TYPES[] = { +const char* DownloadHandlerConstants::BT_CONTENT_TYPES[] = { "application/x-bittorrent" }; diff --git a/src/DownloadHandlerConstants.h b/src/DownloadHandlerConstants.h index 0e4e42df..246885b4 100644 --- a/src/DownloadHandlerConstants.h +++ b/src/DownloadHandlerConstants.h @@ -41,19 +41,19 @@ class DownloadHandlerConstants { public: - static char* METALINK_EXTENSIONS[]; + static const char* METALINK_EXTENSIONS[]; static Strings getMetalinkExtensions(); - static char* METALINK_CONTENT_TYPES[]; + static const char* METALINK_CONTENT_TYPES[]; static Strings getMetalinkContentTypes(); - static char* BT_EXTENSIONS[]; + static const char* BT_EXTENSIONS[]; static Strings getBtExtensions(); - static char* BT_CONTENT_TYPES[]; + static const char* BT_CONTENT_TYPES[]; static Strings getBtContentTypes(); }; diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 03cb791a..c989b5c9 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -237,8 +237,7 @@ Commands RequestGroup::createInitialCommand(DownloadEngine* e) Commands RequestGroup::processCheckIntegrityEntry(const CheckIntegrityEntryHandle& entry, DownloadEngine* e) { #ifdef ENABLE_MESSAGE_DIGEST - if(//File(getFilePath()).size() > 0 && - e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE && + if(e->option->get(PREF_CHECK_INTEGRITY) == V_TRUE && entry->isValidationReady()) { entry->initValidator(); CheckIntegrityCommand* command = diff --git a/src/Util.cc b/src/Util.cc index 5e161fd5..186f012b 100644 --- a/src/Util.cc +++ b/src/Util.cc @@ -581,7 +581,7 @@ int32_t Util::countBit(uint32_t n) { } string Util::randomAlpha(int32_t length, const RandomizerHandle& randomizer) { - static char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + static const char *random_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; string str; for(int32_t i = 0; i < length; i++) { int32_t index = randomizer->getRandomNumber(strlen(random_chars)); diff --git a/test/MetaFileUtilTest.cc b/test/MetaFileUtilTest.cc index fcfb6872..b8280d91 100644 --- a/test/MetaFileUtilTest.cc +++ b/test/MetaFileUtilTest.cc @@ -35,7 +35,7 @@ void MetaFileUtilTest::testParseMetaFile() { void MetaFileUtilTest::testBdecoding() { try { - char* str = "5:abcd"; + const char* str = "5:abcd"; MetaEntry* entry = MetaFileUtil::bdecoding(str, strlen(str)); CPPUNIT_FAIL("DlAbortEx exception must be thrown."); } catch(DlAbortEx* ex) { @@ -45,7 +45,7 @@ void MetaFileUtilTest::testBdecoding() { } try { - char* str = "i1234"; + const char* str = "i1234"; MetaEntry* entry = MetaFileUtil::bdecoding(str, strlen(str)); CPPUNIT_FAIL("DlAbortEx exception must be thrown."); } catch(DlAbortEx* ex) { @@ -55,7 +55,7 @@ void MetaFileUtilTest::testBdecoding() { } try { - char* str = "5abcd"; + const char* str = "5abcd"; MetaEntry* entry = MetaFileUtil::bdecoding(str, strlen(str)); CPPUNIT_FAIL("DlAbortEx exception must be thrown."); } catch(DlAbortEx* ex) { @@ -65,7 +65,7 @@ void MetaFileUtilTest::testBdecoding() { } try { - char* str = "d"; + const char* str = "d"; MetaEntry* entry = MetaFileUtil::bdecoding(str, strlen(str)); CPPUNIT_FAIL("DlAbortEx exception must be thrown."); } catch(DlAbortEx* ex) { diff --git a/test/PStringBuildVisitorTest.cc b/test/PStringBuildVisitorTest.cc index a3ff8991..92717e29 100644 --- a/test/PStringBuildVisitorTest.cc +++ b/test/PStringBuildVisitorTest.cc @@ -30,7 +30,7 @@ void PStringBuildVisitorTest::testVisit_select() { PStringSegmentHandle segment1 = new PStringSegment("/tango"); - char* select1data[] = { "alpha", "bravo", "charlie" }; + const char* select1data[] = { "alpha", "bravo", "charlie" }; PStringSelectHandle select1 = new PStringSelect(Strings(&select1data[0], &select1data[3]), segment1); @@ -66,7 +66,7 @@ void PStringBuildVisitorTest::testVisit_select_numLoop() { PStringSegmentHandle segment1 = new PStringSegment("/tango"); - char* select1data[] = { "alpha", "bravo", "charlie" }; + const char* select1data[] = { "alpha", "bravo", "charlie" }; PStringSelectHandle select1 = new PStringSelect(Strings(&select1data[0], &select1data[3]), segment1);