From f860bf0d50c7fccb4ecf71478b3763cc78e0944b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 2 Dec 2011 21:36:11 +0900 Subject: [PATCH] Use %lld to fomat a2_gid_t --- src/BtDependency.cc | 12 +++---- src/BtStopDownloadCommand.cc | 4 +-- src/CheckIntegrityDispatcherCommand.cc | 5 ++- src/FtpNegotiationCommand.cc | 2 +- src/HttpResponseCommand.cc | 4 +-- src/RequestGroup.cc | 17 ++++----- src/RequestGroup.h | 3 +- src/RequestGroupMan.cc | 8 ++--- src/RpcMethodImpl.cc | 50 +++++++------------------- src/TrackerWatcherCommand.cc | 3 +- src/message.h | 2 +- 11 files changed, 39 insertions(+), 71 deletions(-) diff --git a/src/BtDependency.cc b/src/BtDependency.cc index 9b7c156c..41f5f63c 100644 --- a/src/BtDependency.cc +++ b/src/BtDependency.cc @@ -142,20 +142,20 @@ bool BtDependency::resolve() } } catch(RecoverableException& e) { A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e); - A2_LOG_INFO(fmt("BtDependency for GID#%s failed. Go without Bt.", - util::itos(dependant_->getGID()).c_str())); + A2_LOG_INFO(fmt("BtDependency for GID#%lld failed. Go without Bt.", + dependant_->getGID())); return true; } - A2_LOG_INFO(fmt("Dependency resolved for GID#%s", - util::itos(dependant_->getGID()).c_str())); + A2_LOG_INFO(fmt("Dependency resolved for GID#%lld", + dependant_->getGID())); dependant_->setDownloadContext(context); return true; } else if(dependee_->getNumCommand() == 0) { // dependee_'s download failed. // cut reference here dependee_.reset(); - A2_LOG_INFO(fmt("BtDependency for GID#%s failed. Go without Bt.", - util::itos(dependant_->getGID()).c_str())); + A2_LOG_INFO(fmt("BtDependency for GID#%lld failed. Go without Bt.", + dependant_->getGID())); return true; } else { return false; diff --git a/src/BtStopDownloadCommand.cc b/src/BtStopDownloadCommand.cc index c0cb922a..446b24d6 100644 --- a/src/BtStopDownloadCommand.cc +++ b/src/BtStopDownloadCommand.cc @@ -61,9 +61,9 @@ void BtStopDownloadCommand::preProcess() enableExit(); } if(checkPoint_.difference(global::wallclock()) >= timeout_) { - A2_LOG_NOTICE(fmt("GID#%s Stop downloading torrent due to" + A2_LOG_NOTICE(fmt("GID#%lld Stop downloading torrent due to" " --bt-stop-timeout option.", - util::itos(requestGroup_->getGID()).c_str())); + requestGroup_->getGID())); requestGroup_->setForceHaltRequested(true); getDownloadEngine()->setRefreshInterval(0); enableExit(); diff --git a/src/CheckIntegrityDispatcherCommand.cc b/src/CheckIntegrityDispatcherCommand.cc index 73ebc05f..ca72316c 100644 --- a/src/CheckIntegrityDispatcherCommand.cc +++ b/src/CheckIntegrityDispatcherCommand.cc @@ -56,9 +56,8 @@ Command* CheckIntegrityDispatcherCommand::createCommand (const SharedHandle& entry) { cuid_t newCUID = getDownloadEngine()->newCUID(); - A2_LOG_INFO(fmt("CUID#%lld - Dispatching CheckIntegrityCommand CUID#%s.", - getCuid(), - util::itos(newCUID).c_str())); + A2_LOG_INFO(fmt("CUID#%lld - Dispatching CheckIntegrityCommand CUID#%lld.", + getCuid(), newCUID)); return new CheckIntegrityCommand (newCUID, entry->getRequestGroup(), getDownloadEngine(), entry); } diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index 45e7a69b..4bdc7ec9 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -409,7 +409,7 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength) sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED; A2_LOG_NOTICE (fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, - util::itos(getRequestGroup()->getGID()).c_str(), + getRequestGroup()->getGID(), getRequestGroup()->getFirstFilePath().c_str())); poolConnection(); diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index ba4fefbc..f9242591 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -188,7 +188,7 @@ bool HttpResponseCommand::executeInternal() getDownloadContext()->setChecksumVerified(true); A2_LOG_NOTICE (fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, - util::itos(getRequestGroup()->getGID()).c_str(), + getRequestGroup()->getGID(), getRequestGroup()->getFirstFilePath().c_str())); poolConnection(); getFileEntry()->poolRequest(getRequest()); @@ -441,7 +441,7 @@ bool HttpResponseCommand::handleOtherEncoding getDownloadContext()->setChecksumVerified(true); A2_LOG_NOTICE (fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, - util::itos(getRequestGroup()->getGID()).c_str(), + getRequestGroup()->getGID(), getRequestGroup()->getFirstFilePath().c_str())); poolConnection(); return true; diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 787889f3..a89a3840 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -246,10 +246,8 @@ SharedHandle RequestGroup::createCheckIntegrityEntry() #endif // ENABLE_MESSAGE_DIGEST { downloadContext_->setChecksumVerified(true); - A2_LOG_NOTICE - (fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, - util::itos(gid_).c_str(), - downloadContext_->getBasePath().c_str())); + A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, + gid_, downloadContext_->getBasePath().c_str())); } } else { checkEntry.reset(new StreamCheckIntegrityEntry(this)); @@ -268,10 +266,8 @@ SharedHandle RequestGroup::createCheckIntegrityEntry() #endif // ENABLE_MESSAGE_DIGEST { downloadContext_->setChecksumVerified(true); - A2_LOG_NOTICE - (fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, - util::itos(gid_).c_str(), - downloadContext_->getBasePath().c_str())); + A2_LOG_NOTICE(fmt(MSG_DOWNLOAD_ALREADY_COMPLETED, + gid_, downloadContext_->getBasePath().c_str())); } } else { loadAndOpenFile(infoFile); @@ -970,7 +966,7 @@ void RequestGroup::decreaseNumCommand() { --numCommand_; if(!numCommand_ && requestGroupMan_) { - A2_LOG_DEBUG(fmt("GID#%s - Request queue check", util::itos(gid_).c_str())); + A2_LOG_DEBUG(fmt("GID#%lld - Request queue check", gid_)); requestGroupMan_->requestQueueCheck(); } } @@ -1165,8 +1161,7 @@ bool RequestGroup::needsFileAllocation() const DownloadResultHandle RequestGroup::createDownloadResult() const { - A2_LOG_DEBUG(fmt("GID#%s - Creating DownloadResult.", - util::itos(gid_).c_str())); + A2_LOG_DEBUG(fmt("GID#%lld - Creating DownloadResult.", gid_)); TransferStat st = calculateStat(); SharedHandle res(new DownloadResult()); res->gid = gid_; diff --git a/src/RequestGroup.h b/src/RequestGroup.h index 7458cb96..bd694ad7 100644 --- a/src/RequestGroup.h +++ b/src/RequestGroup.h @@ -73,7 +73,8 @@ class BtRuntime; class PeerStorage; #endif // ENABLE_BITTORRENT -typedef int64_t a2_gid_t; +// To make %lld happy, we use long long int instead of int64_t. +typedef long long int a2_gid_t; class RequestGroup { public: diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 5d33d03e..52fd6e81 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -200,9 +200,7 @@ size_t RequestGroupMan::changeReservedGroupPosition std::deque >::iterator i = findByGID(reservedGroups_.begin(), reservedGroups_.end(), gid); if(i == reservedGroups_.end()) { - throw DL_ABORT_EX - (fmt("GID#%s not found in the waiting queue.", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("GID#%lld not found in the waiting queue.", gid)); } SharedHandle rg = *i; const size_t maxPos = reservedGroups_.size()-1; @@ -341,8 +339,8 @@ public: } } else { A2_LOG_NOTICE - (fmt("Download GID#%s not complete: %s", - util::itos(group->getGID()).c_str(), + (fmt("Download GID#%lld not complete: %s", + group->getGID(), group->getDownloadContext()->getBasePath().c_str())); group->saveControlFile(); } diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc index a9dcf0f3..99f113ee 100644 --- a/src/RpcMethodImpl.cc +++ b/src/RpcMethodImpl.cc @@ -381,16 +381,12 @@ SharedHandle removeDownload if(!group) { group = e->getRequestGroupMan()->findReservedGroup(gid); if(!group) { - throw DL_ABORT_EX - (fmt("Active Download not found for GID#%s", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("Active Download not found for GID#%lld", gid)); } if(group->isDependencyResolved()) { e->getRequestGroupMan()->removeReservedGroup(gid); } else { - throw DL_ABORT_EX - (fmt("GID#%s cannot be removed now", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("GID#%lld cannot be removed now", gid)); } } else { if(forceRemove) { @@ -460,9 +456,7 @@ SharedHandle pauseDownload e->setRefreshInterval(0); return createGIDResponse(gid); } else { - throw DL_ABORT_EX - (fmt("GID#%s cannot be paused now", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("GID#%lld cannot be paused now", gid)); } } } // namespace @@ -526,9 +520,7 @@ SharedHandle UnpauseRpcMethod::process SharedHandle group = e->getRequestGroupMan()->findReservedGroup(gid); if(!group || !group->isPauseRequested()) { - throw DL_ABORT_EX - (fmt("GID#%s cannot be unpaused now", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("GID#%lld cannot be unpaused now", gid)); } else { group->setPauseRequested(false); e->getRequestGroupMan()->requestQueueCheck(); @@ -931,9 +923,7 @@ SharedHandle GetFilesRpcMethod::process SharedHandle dr = e->getRequestGroupMan()->findDownloadResult(gid); if(!dr) { - throw DL_ABORT_EX - (fmt("No file data is available for GID#%s", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("No file data is available for GID#%lld", gid)); } else { createFileEntry(files, dr->fileEntries.begin(), dr->fileEntries.end(), dr->totalLength, dr->pieceLength, dr->bitfield); @@ -960,9 +950,7 @@ SharedHandle GetUrisRpcMethod::process SharedHandle group = findRequestGroup(e->getRequestGroupMan(), gid); if(!group) { - throw DL_ABORT_EX - (fmt("No URI data is available for GID#%s", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("No URI data is available for GID#%lld", gid)); } SharedHandle uriList = List::g(); // TODO Current implementation just returns first FileEntry's URIs. @@ -982,9 +970,7 @@ SharedHandle GetPeersRpcMethod::process SharedHandle group = findRequestGroup(e->getRequestGroupMan(), gid); if(!group) { - throw DL_ABORT_EX - (fmt("No peer data is available for GID#%s", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("No peer data is available for GID#%lld", gid)); } SharedHandle peers = List::g(); const SharedHandle& btObject = @@ -1017,9 +1003,7 @@ SharedHandle TellStatusRpcMethod::process SharedHandle ds = e->getRequestGroupMan()->findDownloadResult(gid); if(!ds) { - throw DL_ABORT_EX - (fmt("No such download for GID#%s", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("No such download for GID#%lld", gid)); } gatherStoppedDownload(entryDict, ds, keys); } else { @@ -1113,9 +1097,7 @@ SharedHandle RemoveDownloadResultRpcMethod::process a2_gid_t gid = str2Gid(gidParam); if(!e->getRequestGroupMan()->removeDownloadResult(gid)) { - throw DL_ABORT_EX - (fmt("Could not remove download result of GID#%s", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("Could not remove download result of GID#%lld", gid)); } return VLB_OK; } @@ -1213,8 +1195,7 @@ SharedHandle ChangeOptionRpcMethod::process gatherChangeableOptionForReserved(&option, optsParam); changeOption(group, option, e); } else { - throw DL_ABORT_EX - (fmt("Cannot change option for GID#%s", util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("Cannot change option for GID#%lld", gid)); } } return VLB_OK; @@ -1303,9 +1284,7 @@ SharedHandle GetOptionRpcMethod::process SharedHandle group = findRequestGroup(e->getRequestGroupMan(), gid); if(!group) { - throw DL_ABORT_EX - (fmt("Cannot get option for GID#%s", - util::itos(gid).c_str())); + throw DL_ABORT_EX(fmt("Cannot get option for GID#%lld", gid)); } SharedHandle result = Dict::g(); SharedHandle