From 4b03634f36b05c32737aeea8ca178f53f68052e8 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 25 Jun 2012 22:43:33 +0900 Subject: [PATCH] Use PRId64 for int64_t format specifier --- src/AbstractCommand.cc | 30 +++---- src/AbstractDiskWriter.cc | 4 +- src/AbstractHttpServerResponseCommand.cc | 6 +- src/BtDependency.cc | 6 +- src/BtPieceMessage.cc | 4 +- src/BtStopDownloadCommand.cc | 2 +- src/CheckIntegrityDispatcherCommand.cc | 2 +- src/Command.h | 2 +- src/DHTMessageFactoryImpl.cc | 7 +- src/DHTMessageTracker.cc | 2 +- src/DefaultBtAnnounce.cc | 14 +-- src/DefaultBtInteractive.cc | 4 +- src/DefaultBtProgressInfoFile.cc | 6 +- src/DownloadCommand.cc | 2 +- src/FileAllocationCommand.cc | 2 +- src/FtpConnection.cc | 7 +- src/FtpFinishDownloadCommand.cc | 6 +- src/FtpNegotiationCommand.cc | 11 ++- src/HttpHeader.cc | 11 +-- src/HttpRequest.cc | 4 +- src/HttpResponse.cc | 14 +-- src/HttpServerBodyCommand.cc | 6 +- src/HttpServerCommand.cc | 6 +- src/HttpServerResponseCommand.cc | 2 +- src/InitiatorMSEHandshakeCommand.cc | 4 +- src/IteratableChunkChecksumValidator.cc | 2 +- src/MSEHandshake.cc | 42 ++++----- src/MultiDiskAdaptor.cc | 14 +-- src/OptionHandlerImpl.cc | 11 +-- src/PeerAbstractCommand.cc | 2 +- src/PeerConnection.cc | 2 +- src/PeerListenCommand.cc | 2 +- src/RequestGroup.cc | 14 +-- src/RequestGroup.h | 3 +- src/RequestGroupMan.cc | 4 +- src/RpcMethodImpl.cc | 26 +++--- src/SegmentMan.cc | 8 +- src/TrackerWatcherCommand.cc | 4 +- src/WatchProcessCommand.cc | 2 +- src/WebSocketInteractionCommand.cc | 4 +- src/bittorrent_helper.cc | 6 +- src/common.h | 3 + src/message.h | 104 +++++++++++------------ src/util.cc | 2 +- 44 files changed, 206 insertions(+), 213 deletions(-) diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index b4777013..7276a755 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -121,7 +121,7 @@ AbstractCommand::~AbstractCommand() { void AbstractCommand::useFasterRequest (const SharedHandle& fasterRequest) { - A2_LOG_INFO(fmt("CUID#%lld - Use faster Request hostname=%s, port=%u", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - Use faster Request hostname=%s, port=%u", getCuid(), fasterRequest->getHost().c_str(), fasterRequest->getPort())); @@ -135,7 +135,7 @@ void AbstractCommand::useFasterRequest } bool AbstractCommand::execute() { - A2_LOG_DEBUG(fmt("CUID#%lld - socket: read:%d, write:%d, hup:%d, err:%d", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - socket: read:%d, write:%d, hup:%d, err:%d", getCuid(), readEventEnabled(), writeEventEnabled(), @@ -146,7 +146,7 @@ bool AbstractCommand::execute() { return true; } if(req_ && req_->removalRequested()) { - A2_LOG_DEBUG(fmt("CUID#%lld - Discard original URI=%s because it is" + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Discard original URI=%s because it is" " requested.", getCuid(), req_->getUri().c_str())); return prepareForRetry(0); @@ -158,7 +158,7 @@ bool AbstractCommand::execute() { // This command previously has assigned segments, but it is // canceled. So discard current request chain. Plus, if no // segment is available when http pipelining is used. - A2_LOG_DEBUG(fmt("CUID#%lld - It seems previously assigned segments" + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - It seems previously assigned segments" " are canceled. Restart.", getCuid())); // Request::isPipeliningEnabled() == true means aria2 @@ -273,7 +273,7 @@ bool AbstractCommand::execute() { // empty. if(!req_->getConnectedAddr().empty()) { // Purging IP address cache to renew IP address. - A2_LOG_DEBUG(fmt("CUID#%lld - Marking IP address %s as bad", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Marking IP address %s as bad", getCuid(), req_->getConnectedAddr().c_str())); e_->markBadIPAddress(req_->getConnectedHostname(), @@ -282,7 +282,7 @@ bool AbstractCommand::execute() { } if(e_->findCachedIPAddress (req_->getConnectedHostname(), req_->getConnectedPort()).empty()) { - A2_LOG_DEBUG(fmt("CUID#%lld - All IP addresses were marked bad." + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - All IP addresses were marked bad." " Removing Entry.", getCuid())); e_->removeCachedIPAddress @@ -370,14 +370,14 @@ void AbstractCommand::tryReserved() { // and there are no URI left. Because file length is unknown, we // can assume that there are no in-flight request object. if(entry->getLength() == 0 && entry->getRemainingUris().empty()) { - A2_LOG_DEBUG(fmt("CUID#%lld - Not trying next request." + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Not trying next request." " No reserved/pooled request is remaining and" " total length is still unknown.", getCuid())); return; } } - A2_LOG_DEBUG(fmt("CUID#%lld - Trying reserved/pooled request.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Trying reserved/pooled request.", getCuid())); std::vector commands; requestGroup_->createNextCommand(commands, e_, 1); @@ -397,7 +397,7 @@ bool AbstractCommand::prepareForRetry(time_t wait) { req_->setMaxPipelinedRequest(1); fileEntry_->poolRequest(req_); - A2_LOG_DEBUG(fmt("CUID#%lld - Pooling request URI=%s", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Pooling request URI=%s", getCuid(), req_->getUri().c_str())); if(getSegmentMan()) { getSegmentMan()->recognizeSegmentFor(fileEntry_); @@ -422,7 +422,7 @@ void AbstractCommand::onAbort() { fileEntry_->removeIdenticalURI(req_->getUri()); fileEntry_->removeRequest(req_); } - A2_LOG_DEBUG(fmt("CUID#%lld - Aborting download", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Aborting download", getCuid())); if(getPieceStorage()) { getSegmentMan()->cancelSegment(getCuid()); @@ -440,10 +440,10 @@ void AbstractCommand::onAbort() { // Local file exists, but given servers(or at least contacted // ones) doesn't support resume. Let's restart download from // scratch. - A2_LOG_NOTICE(fmt(_("CUID#%lld - Failed to resume download." + A2_LOG_NOTICE(fmt(_("CUID#%" PRId64 " - Failed to resume download." " Download from scratch."), getCuid())); - A2_LOG_DEBUG(fmt("CUID#%lld - Gathering URIs that has CANNOT_RESUME" + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Gathering URIs that has CANNOT_RESUME" " error", getCuid())); // Set PREF_ALWAYS_RESUME to A2_V_TRUE to avoid repeating this @@ -459,7 +459,7 @@ void AbstractCommand::onAbort() { uris.reserve(res.size()); std::transform(res.begin(), res.end(), std::back_inserter(uris), std::mem_fun_ref(&URIResult::getURI)); - A2_LOG_DEBUG(fmt("CUID#%lld - %lu URIs found.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - %lu URIs found.", getCuid(), static_cast(uris.size()))); fileEntry_->addUris(uris.begin(), uris.end()); @@ -675,9 +675,9 @@ SharedHandle AbstractCommand::createProxyRequest() const if(!proxy.empty()) { proxyRequest.reset(new Request()); if(proxyRequest->setUri(proxy)) { - A2_LOG_DEBUG(fmt("CUID#%lld - Using proxy", getCuid())); + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Using proxy", getCuid())); } else { - A2_LOG_DEBUG(fmt("CUID#%lld - Failed to parse proxy string", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Failed to parse proxy string", getCuid())); proxyRequest.reset(); } diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index 4e8d6c76..1e4a66e4 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -215,9 +215,9 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, off_t offset) mapaddr_ = reinterpret_cast (mmap(0, size(), PROT_READ | PROT_WRITE, MAP_SHARED, fd_, 0)); if(mapaddr_) { - A2_LOG_DEBUG(fmt("mmap for file %s succeeded, length=%lld", + A2_LOG_DEBUG(fmt("mmap for file %s succeeded, length=%" PRId64 "", filename_.c_str(), - static_cast(filesize))); + static_cast(filesize))); maplen_ = filesize; } else { int errNum = errno; diff --git a/src/AbstractHttpServerResponseCommand.cc b/src/AbstractHttpServerResponseCommand.cc index d60e81c4..7b89a254 100644 --- a/src/AbstractHttpServerResponseCommand.cc +++ b/src/AbstractHttpServerResponseCommand.cc @@ -75,19 +75,19 @@ bool AbstractHttpServerResponseCommand::execute() httpServer_->sendResponse(); } catch(RecoverableException& e) { A2_LOG_INFO_EX - (fmt("CUID#%lld - Error occurred while transmitting response body.", + (fmt("CUID#%" PRId64 " - Error occurred while transmitting response body.", getCuid()), e); return true; } if(httpServer_->sendBufferIsEmpty()) { - A2_LOG_INFO(fmt("CUID#%lld - HttpServer: all response transmitted.", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - HttpServer: all response transmitted.", getCuid())); afterSend(httpServer_, e_); return true; } else { if(timeoutTimer_.difference(global::wallclock()) >= 10) { - A2_LOG_INFO(fmt("CUID#%lld - HttpServer: Timeout while trasmitting" + A2_LOG_INFO(fmt("CUID#%" PRId64 " - HttpServer: Timeout while trasmitting" " response.", getCuid())); return true; diff --git a/src/BtDependency.cc b/src/BtDependency.cc index 35f99116..967fa845 100644 --- a/src/BtDependency.cc +++ b/src/BtDependency.cc @@ -155,11 +155,11 @@ bool BtDependency::resolve() } } catch(RecoverableException& e) { A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e); - A2_LOG_INFO(fmt("BtDependency for GID#%lld failed. Go without Bt.", + A2_LOG_INFO(fmt("BtDependency for GID#%" PRId64 " failed. Go without Bt.", dependant_->getGID())); return true; } - A2_LOG_INFO(fmt("Dependency resolved for GID#%lld", + A2_LOG_INFO(fmt("Dependency resolved for GID#%" PRId64 "", dependant_->getGID())); dependant_->setDownloadContext(context); return true; @@ -167,7 +167,7 @@ bool BtDependency::resolve() // dependee_'s download failed. // cut reference here dependee_.reset(); - A2_LOG_INFO(fmt("BtDependency for GID#%lld failed. Go without Bt.", + A2_LOG_INFO(fmt("BtDependency for GID#%" PRId64 " failed. Go without Bt.", dependant_->getGID())); return true; } else { diff --git a/src/BtPieceMessage.cc b/src/BtPieceMessage.cc index 338bebe3..80a67541 100644 --- a/src/BtPieceMessage.cc +++ b/src/BtPieceMessage.cc @@ -109,7 +109,7 @@ void BtPieceMessage::doReceivedAction() static_cast(index_), begin_, blockLength_, - static_cast(offset), + static_cast(offset), static_cast(slot.getBlockIndex()))); if(piece->hasBlock(slot.getBlockIndex())) { A2_LOG_DEBUG("Already have this block."); @@ -133,7 +133,7 @@ void BtPieceMessage::doReceivedAction() } } } else { - A2_LOG_DEBUG(fmt("CUID#%lld - RequestSlot not found, index=%lu, begin=%d", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - RequestSlot not found, index=%lu, begin=%d", getCuid(), static_cast(index_), begin_)); diff --git a/src/BtStopDownloadCommand.cc b/src/BtStopDownloadCommand.cc index 15e9fa21..15eeea53 100644 --- a/src/BtStopDownloadCommand.cc +++ b/src/BtStopDownloadCommand.cc @@ -61,7 +61,7 @@ void BtStopDownloadCommand::preProcess() enableExit(); } if(checkPoint_.difference(global::wallclock()) >= timeout_) { - A2_LOG_NOTICE(fmt(_("GID#%lld Stop downloading torrent due to" + A2_LOG_NOTICE(fmt(_("GID#%" PRId64 " Stop downloading torrent due to" " --bt-stop-timeout option."), requestGroup_->getGID())); requestGroup_->setForceHaltRequested(true); diff --git a/src/CheckIntegrityDispatcherCommand.cc b/src/CheckIntegrityDispatcherCommand.cc index ca72316c..49fa965e 100644 --- a/src/CheckIntegrityDispatcherCommand.cc +++ b/src/CheckIntegrityDispatcherCommand.cc @@ -56,7 +56,7 @@ Command* CheckIntegrityDispatcherCommand::createCommand (const SharedHandle& entry) { cuid_t newCUID = getDownloadEngine()->newCUID(); - A2_LOG_INFO(fmt("CUID#%lld - Dispatching CheckIntegrityCommand CUID#%lld.", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - Dispatching CheckIntegrityCommand CUID#%" PRId64 ".", getCuid(), newCUID)); return new CheckIntegrityCommand (newCUID, entry->getRequestGroup(), getDownloadEngine(), entry); diff --git a/src/Command.h b/src/Command.h index 33d59ad8..a164661d 100644 --- a/src/Command.h +++ b/src/Command.h @@ -39,7 +39,7 @@ namespace aria2 { -typedef long long int cuid_t; +typedef int64_t cuid_t; class Command { public: diff --git a/src/DHTMessageFactoryImpl.cc b/src/DHTMessageFactoryImpl.cc index a804d983..dc4d69cf 100644 --- a/src/DHTMessageFactoryImpl.cc +++ b/src/DHTMessageFactoryImpl.cc @@ -183,8 +183,7 @@ void DHTMessageFactoryImpl::validatePort(const Integer* port) const { if(!(0 < port->i() && port->i() < UINT16_MAX)) { throw DL_ABORT_EX - (fmt("Malformed DHT message. Invalid port=%lld", - static_cast(port->i()))); + (fmt("Malformed DHT message. Invalid port=%" PRId64 "", port->i())); } } @@ -256,8 +255,8 @@ DHTMessageFactoryImpl::createResponseMessage // for now, just report error message arrived and throw exception. const List* e = getList(dict, DHTUnknownMessage::E); if(e->size() == 2) { - A2_LOG_INFO(fmt("Received Error DHT message. code=%lld, msg=%s", - static_cast(getInteger(e, 0)->i()), + A2_LOG_INFO(fmt("Received Error DHT message. code=%" PRId64 ", msg=%s", + getInteger(e, 0)->i(), util::percentEncode(getString(e, 1)->s()).c_str())); } else { A2_LOG_DEBUG("e doesn't have 2 elements."); diff --git a/src/DHTMessageTracker.cc b/src/DHTMessageTracker.cc index 11b1ffbb..ec728a77 100644 --- a/src/DHTMessageTracker.cc +++ b/src/DHTMessageTracker.cc @@ -87,7 +87,7 @@ DHTMessageTracker::messageArrived targetNode->getPort()); int64_t rtt = entry->getElapsedMillis(); - A2_LOG_DEBUG(fmt("RTT is %lld", static_cast(rtt))); + A2_LOG_DEBUG(fmt("RTT is %" PRId64 "", rtt)); message->getRemoteNode()->updateRTT(rtt); SharedHandle callback = entry->getCallback(); if(!(*targetNode == *message->getRemoteNode())) { diff --git a/src/DefaultBtAnnounce.cc b/src/DefaultBtAnnounce.cc index 705ddeef..8f60285c 100644 --- a/src/DefaultBtAnnounce.cc +++ b/src/DefaultBtAnnounce.cc @@ -142,7 +142,7 @@ std::string DefaultBtAnnounce::getAnnounceUrl() { numWant = 0; } TransferStat stat = peerStorage_->calculateStat(); - off_t left = + int64_t left = pieceStorage_->getTotalLength()-pieceStorage_->getCompletedLength(); // Use last 8 bytes of peer ID as a key const size_t keyLen = 8; @@ -150,9 +150,9 @@ std::string DefaultBtAnnounce::getAnnounceUrl() { uri += uriHasQuery(uri) ? "&" : "?"; uri += fmt("info_hash=%s&" "peer_id=%s&" - "uploaded=%lld&" - "downloaded=%lld&" - "left=%lld&" + "uploaded=%" PRId64 "&" + "downloaded=%" PRId64 "&" + "left=%" PRId64 "&" "compact=1&" "key=%s&" "numwant=%d&" @@ -162,9 +162,9 @@ std::string DefaultBtAnnounce::getAnnounceUrl() { INFO_HASH_LENGTH).c_str(), util::torrentPercentEncode (bittorrent::getStaticPeerId(), PEER_ID_LENGTH).c_str(), - static_cast(stat.getSessionUploadLength()), - static_cast(stat.getSessionDownloadLength()), - static_cast(left), + stat.getSessionUploadLength(), + stat.getSessionDownloadLength(), + left, util::torrentPercentEncode (bittorrent::getStaticPeerId()+PEER_ID_LENGTH-keyLen, keyLen).c_str(), diff --git a/src/DefaultBtInteractive.cc b/src/DefaultBtInteractive.cc index cb2530e8..af3df1b5 100644 --- a/src/DefaultBtInteractive.cc +++ b/src/DefaultBtInteractive.cc @@ -117,7 +117,7 @@ BtMessageHandle DefaultBtInteractive::receiveHandshake(bool quickReply) { if(memcmp(message->getPeerId(), bittorrent::getStaticPeerId(), PEER_ID_LENGTH) == 0) { throw DL_ABORT_EX - (fmt("CUID#%lld - Drop connection from the same Peer ID", + (fmt("CUID#%" PRId64 " - Drop connection from the same Peer ID", cuid_)); } std::vector > activePeers; @@ -126,7 +126,7 @@ BtMessageHandle DefaultBtInteractive::receiveHandshake(bool quickReply) { eoi = activePeers.end(); i != eoi; ++i) { if(memcmp((*i)->getPeerId(), message->getPeerId(), PEER_ID_LENGTH) == 0) { throw DL_ABORT_EX - (fmt("CUID#%lld - Same Peer ID has been already seen.", + (fmt("CUID#%" PRId64 " - Same Peer ID has been already seen.", cuid_)); } } diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index a3efb72e..9a82dfc7 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -276,9 +276,9 @@ void DefaultBtProgressInfoFile::load() } if(totalLength != static_cast(dctx_->getTotalLength())) { throw DL_ABORT_EX - (fmt("total length mismatch. expected: %lld, actual: %lld", - static_cast(dctx_->getTotalLength()), - static_cast(totalLength))); + (fmt("total length mismatch. expected: %" PRId64 ", actual: %" PRId64 "", + static_cast(dctx_->getTotalLength()), + static_cast(totalLength))); } uint64_t uploadLength; READ_CHECK(fp, &uploadLength, sizeof(uploadLength)); diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index e405236f..8f3c8289 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -361,7 +361,7 @@ void DownloadCommand::validatePieceHash(const SharedHandle& segment, } else { A2_LOG_INFO(fmt(EX_INVALID_CHUNK_CHECKSUM, static_cast(segment->getIndex()), - static_cast(segment->getPosition()), + static_cast(segment->getPosition()), util::toHex(expectedHash).c_str(), util::toHex(actualHash).c_str())); segment->clear(); diff --git a/src/FileAllocationCommand.cc b/src/FileAllocationCommand.cc index 450fa2b7..04d35172 100644 --- a/src/FileAllocationCommand.cc +++ b/src/FileAllocationCommand.cc @@ -71,7 +71,7 @@ bool FileAllocationCommand::executeInternal() A2_LOG_DEBUG (fmt(MSG_ALLOCATION_COMPLETED, static_cast(timer_.difference(global::wallclock())), - static_cast(getRequestGroup()->getTotalLength()))); + static_cast(getRequestGroup()->getTotalLength()))); getDownloadEngine()->getFileAllocationMan()->dropPickedEntry(); std::vector* commands = new std::vector(); diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 728295ee..667fa286 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -254,9 +254,10 @@ bool FtpConnection::sendRest(const SharedHandle& segment) { if(socketBuffer_.sendBufferIsEmpty()) { std::string request = - fmt("REST %lld\r\n", + fmt("REST %" PRId64 "\r\n", segment ? - static_cast(segment->getPositionToWrite()) : 0LL); + static_cast(segment->getPositionToWrite()) : + static_cast(0LL)); A2_LOG_INFO(fmt(MSG_SENDING_REQUEST, cuid_, request.c_str())); socketBuffer_.pushStr(request); @@ -392,7 +393,7 @@ int FtpConnection::receiveResponse() # define LONGLONG_SCANF "%I64d" # define ULONGLONG_SCANF "%I64u" #else -# define LONGLONG_PRINTF "%lld" +# define LONGLONG_PRINTF "%" PRId64 "" # define ULONGLONG_PRINTF "%llu" # define LONGLONG_SCANF "%Ld" // Mac OSX uses "%llu" for 64bits integer. diff --git a/src/FtpFinishDownloadCommand.cc b/src/FtpFinishDownloadCommand.cc index 75d5ad49..ecfdd838 100644 --- a/src/FtpFinishDownloadCommand.cc +++ b/src/FtpFinishDownloadCommand.cc @@ -92,18 +92,18 @@ bool FtpFinishDownloadCommand::execute() getSocket(), options); } } else { - A2_LOG_INFO(fmt("CUID#%lld - Bad status for transfer complete.", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - Bad status for transfer complete.", getCuid())); } } else if(getCheckPoint().difference(global::wallclock()) >= getTimeout()) { - A2_LOG_INFO(fmt("CUID#%lld - Timeout before receiving transfer complete.", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - Timeout before receiving transfer complete.", getCuid())); } else { getDownloadEngine()->addCommand(this); return false; } } catch(RecoverableException& e) { - A2_LOG_INFO_EX(fmt("CUID#%lld - Exception was thrown, but download was" + A2_LOG_INFO_EX(fmt("CUID#%" PRId64 " - Exception was thrown, but download was" " finished, so we can ignore the exception.", getCuid()), e); diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index 0f39db13..49907e9a 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -265,7 +265,7 @@ bool FtpNegotiationCommand::recvPwd() error_code::FTP_PROTOCOL_ERROR); } ftp_->setBaseWorkingDir(pwd); - A2_LOG_INFO(fmt("CUID#%lld - base working directory is '%s'", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - base working directory is '%s'", getCuid(), pwd.c_str())); sequence_ = SEQ_SEND_CWD_PREP; return true; @@ -350,7 +350,7 @@ bool FtpNegotiationCommand::recvMdtm() " a time value as in specified in RFC3659."); } } else { - A2_LOG_INFO(fmt("CUID#%lld - MDTM command failed.", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - MDTM command failed.", getCuid())); } sequence_ = SEQ_SEND_SIZE; @@ -502,9 +502,8 @@ bool FtpNegotiationCommand::recvSize() { } if(status == 213) { if(size > std::numeric_limits::max()) { - throw DL_ABORT_EX2 - (fmt(EX_TOO_LARGE_FILE, static_cast(size)), - error_code::FTP_PROTOCOL_ERROR); + throw DL_ABORT_EX2(fmt(EX_TOO_LARGE_FILE, size), + error_code::FTP_PROTOCOL_ERROR); } if(!getPieceStorage()) { @@ -516,7 +515,7 @@ bool FtpNegotiationCommand::recvSize() { } } else { - A2_LOG_INFO(fmt("CUID#%lld - The remote FTP Server doesn't recognize SIZE" + A2_LOG_INFO(fmt("CUID#%" PRId64 " - The remote FTP Server doesn't recognize SIZE" " command. Continue.", getCuid())); // Even if one of the other servers waiting in the queue supports SIZE // command, resuming and segmented downloading are disabled when the first diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 6f86d934..6197fd12 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -142,7 +142,7 @@ RangeHandle HttpHeader::getRange() const throw DL_ABORT_EX("Content-Length must be positive"); } else if(contentLength > std::numeric_limits::max()) { throw DOWNLOAD_FAILURE_EXCEPTION - (fmt(EX_TOO_LARGE_FILE, static_cast(contentLength))); + (fmt(EX_TOO_LARGE_FILE, contentLength)); } else if(contentLength == 0) { return SharedHandle(new Range()); } else { @@ -187,16 +187,13 @@ RangeHandle HttpHeader::getRange() const throw DL_ABORT_EX("byte-range-spec must be positive"); } if(startByte > std::numeric_limits::max()) { - throw DOWNLOAD_FAILURE_EXCEPTION - (fmt(EX_TOO_LARGE_FILE, static_cast(startByte))); + throw DOWNLOAD_FAILURE_EXCEPTION(fmt(EX_TOO_LARGE_FILE, startByte)); } if(endByte > std::numeric_limits::max()) { - throw DOWNLOAD_FAILURE_EXCEPTION - (fmt(EX_TOO_LARGE_FILE, static_cast(endByte))); + throw DOWNLOAD_FAILURE_EXCEPTION(fmt(EX_TOO_LARGE_FILE, endByte)); } if(entityLength > std::numeric_limits::max()) { - throw DOWNLOAD_FAILURE_EXCEPTION - (fmt(EX_TOO_LARGE_FILE, static_cast(entityLength))); + throw DOWNLOAD_FAILURE_EXCEPTION(fmt(EX_TOO_LARGE_FILE, entityLength)); } return SharedHandle(new Range(startByte, endByte, entityLength)); } diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 3ebf7f24..beba1b67 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -193,8 +193,8 @@ std::string HttpRequest::createRequest() } if(segment_ && segment_->getLength() > 0 && (request_->isPipeliningEnabled() || getStartByte() > 0)) { - std::string rangeHeader(fmt("bytes=%lld-", - static_cast(getStartByte()))); + std::string rangeHeader(fmt("bytes=%" PRId64 "-", + static_cast(getStartByte()))); if(request_->isPipeliningEnabled()) { rangeHeader += util::itos(getEndByte()); } else if(getProtocol() != Request::PROTO_FTP && endOffsetOverride_ > 0) { diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index b07d873a..fb726c4d 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -100,12 +100,12 @@ void HttpResponse::validateResponse() const if(!httpRequest_->isRangeSatisfied(responseRange)) { throw DL_ABORT_EX2 (fmt(EX_INVALID_RANGE_HEADER, - static_cast(httpRequest_->getStartByte()), - static_cast(httpRequest_->getEndByte()), - static_cast(httpRequest_->getEntityLength()), - static_cast(responseRange->getStartByte()), - static_cast(responseRange->getEndByte()), - static_cast(responseRange->getEntityLength())), + static_cast(httpRequest_->getStartByte()), + static_cast(httpRequest_->getEndByte()), + static_cast(httpRequest_->getEntityLength()), + static_cast(responseRange->getStartByte()), + static_cast(responseRange->getEndByte()), + static_cast(responseRange->getEntityLength())), error_code::CANNOT_RESUME); } } @@ -170,7 +170,7 @@ void HttpResponse::processRedirect() httpRequest_->getRequest()->getCurrentUri().c_str())); } else { throw DL_RETRY_EX - (fmt("CUID#%lld - Redirect to %s failed. It may not be a valid URI.", + (fmt("CUID#%" PRId64 " - Redirect to %s failed. It may not be a valid URI.", cuid_, httpRequest_->getRequest()->getCurrentUri().c_str())); } diff --git a/src/HttpServerBodyCommand.cc b/src/HttpServerBodyCommand.cc index bd2e3a70..44cd6b95 100644 --- a/src/HttpServerBodyCommand.cc +++ b/src/HttpServerBodyCommand.cc @@ -195,7 +195,7 @@ bool HttpServerBodyCommand::execute() req = rpc::xmlParseMemory(body.c_str(), body.size()); } catch(RecoverableException& e) { A2_LOG_INFO_EX - (fmt("CUID#%lld - Failed to parse XML-RPC request", + (fmt("CUID#%" PRId64 " - Failed to parse XML-RPC request", getCuid()), e); httpServer_->feedResponse(400); @@ -228,7 +228,7 @@ bool HttpServerBodyCommand::execute() } } catch(RecoverableException& e) { A2_LOG_INFO_EX - (fmt("CUID#%lld - Failed to parse JSON-RPC request", + (fmt("CUID#%" PRId64 " - Failed to parse JSON-RPC request", getCuid()), e); rpc::RpcResponse res @@ -283,7 +283,7 @@ bool HttpServerBodyCommand::execute() } } catch(RecoverableException& e) { A2_LOG_INFO_EX - (fmt("CUID#%lld - Error occurred while reading HTTP request body", + (fmt("CUID#%" PRId64 " - Error occurred while reading HTTP request body", getCuid()), e); return true; diff --git a/src/HttpServerCommand.cc b/src/HttpServerCommand.cc index 5c79112f..2851b90e 100644 --- a/src/HttpServerCommand.cc +++ b/src/HttpServerCommand.cc @@ -216,10 +216,10 @@ bool HttpServerCommand::execute() if(e_->getOption()->getAsInt(PREF_RPC_MAX_REQUEST_SIZE) < httpServer_->getContentLength()) { A2_LOG_INFO - (fmt("Request too long. ContentLength=%lld." + (fmt("Request too long. ContentLength=%" PRId64 "." " See --rpc-max-request-size option to loose" " this limitation.", - static_cast(httpServer_->getContentLength()))); + static_cast(httpServer_->getContentLength()))); return true; } Command* command = new HttpServerBodyCommand(getCuid(), httpServer_, e_, @@ -238,7 +238,7 @@ bool HttpServerCommand::execute() } } } catch(RecoverableException& e) { - A2_LOG_INFO_EX(fmt("CUID#%lld - Error occurred while reading HTTP request", + A2_LOG_INFO_EX(fmt("CUID#%" PRId64 " - Error occurred while reading HTTP request", getCuid()), e); return true; diff --git a/src/HttpServerResponseCommand.cc b/src/HttpServerResponseCommand.cc index eabcf22b..473afd84 100644 --- a/src/HttpServerResponseCommand.cc +++ b/src/HttpServerResponseCommand.cc @@ -60,7 +60,7 @@ void HttpServerResponseCommand::afterSend DownloadEngine* e) { if(httpServer->supportsPersistentConnection()) { - A2_LOG_INFO(fmt("CUID#%lld - Persist connection.", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - Persist connection.", getCuid())); e->addCommand (new HttpServerCommand(getCuid(), httpServer, e, diff --git a/src/InitiatorMSEHandshakeCommand.cc b/src/InitiatorMSEHandshakeCommand.cc index bbeb38dc..52066c02 100644 --- a/src/InitiatorMSEHandshakeCommand.cc +++ b/src/InitiatorMSEHandshakeCommand.cc @@ -217,14 +217,14 @@ bool InitiatorMSEHandshakeCommand::prepareForNextPeer(time_t wait) tryNewPeer(); return true; } else if(getOption()->getAsBool(PREF_BT_REQUIRE_CRYPTO)) { - A2_LOG_INFO(fmt("CUID#%lld - Establishing connection using legacy" + A2_LOG_INFO(fmt("CUID#%" PRId64 " - Establishing connection using legacy" " BitTorrent handshake is disabled by preference.", getCuid())); tryNewPeer(); return true; } else { // try legacy BitTorrent handshake - A2_LOG_INFO(fmt("CUID#%lld - Retry using legacy BitTorrent handshake.", + A2_LOG_INFO(fmt("CUID#%" PRId64 " - Retry using legacy BitTorrent handshake.", getCuid())); PeerInitiateConnectionCommand* command = new PeerInitiateConnectionCommand(getCuid(), requestGroup_, getPeer(), diff --git a/src/IteratableChunkChecksumValidator.cc b/src/IteratableChunkChecksumValidator.cc index f3f7f2b2..f9f03ce7 100644 --- a/src/IteratableChunkChecksumValidator.cc +++ b/src/IteratableChunkChecksumValidator.cc @@ -78,7 +78,7 @@ void IteratableChunkChecksumValidator::validateChunk() A2_LOG_INFO (fmt(EX_INVALID_CHUNK_CHECKSUM, static_cast(currentIndex_), - static_cast(getCurrentOffset()), + static_cast(getCurrentOffset()), util::toHex(dctx_->getPieceHashes()[currentIndex_]).c_str(), util::toHex(actualChecksum).c_str())); bitfield_->unsetBit(currentIndex_); diff --git a/src/MSEHandshake.cc b/src/MSEHandshake.cc index 0dab5140..26c3c816 100644 --- a/src/MSEHandshake.cc +++ b/src/MSEHandshake.cc @@ -104,11 +104,11 @@ MSEHandshake::HANDSHAKE_TYPE MSEHandshake::identifyHandshakeType() } if(rbuf_[0] == BtHandshakeMessage::PSTR_LENGTH && memcmp(BtHandshakeMessage::BT_PSTR, rbuf_+1, 19) == 0) { - A2_LOG_DEBUG(fmt("CUID#%lld - This is legacy BitTorrent handshake.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - This is legacy BitTorrent handshake.", cuid_)); return HANDSHAKE_LEGACY; } else { - A2_LOG_DEBUG(fmt("CUID#%lld - This may be encrypted BitTorrent handshake.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - This may be encrypted BitTorrent handshake.", cuid_)); return HANDSHAKE_ENCRYPTED; } @@ -120,13 +120,13 @@ void MSEHandshake::initEncryptionFacility(bool initiator) dh_ = new DHKeyExchange(); dh_->init(PRIME, PRIME_BITS, GENERATOR, 160); dh_->generatePublicKey(); - A2_LOG_DEBUG(fmt("CUID#%lld - DH initialized.", cuid_)); + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - DH initialized.", cuid_)); initiator_ = initiator; } void MSEHandshake::sendPublicKey() { - A2_LOG_DEBUG(fmt("CUID#%lld - Sending public key.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Sending public key.", cuid_)); unsigned char* buf = new unsigned char[KEY_LENGTH+MAX_PAD_LENGTH]; array_ptr bufp(buf); @@ -174,7 +174,7 @@ bool MSEHandshake::receivePublicKey() wantRead_ = true; return false; } - A2_LOG_DEBUG(fmt("CUID#%lld - public key received.", cuid_)); + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - public key received.", cuid_)); // TODO handle exception. in catch, resbufLength = 0; dh_->computeSecret(secret_, sizeof(secret_), rbuf_, KEY_LENGTH); // shift buffer @@ -269,7 +269,7 @@ uint16_t MSEHandshake::decodeLength16(const unsigned char* buffer) void MSEHandshake::sendInitiatorStep2() { - A2_LOG_DEBUG(fmt("CUID#%lld - Sending negotiation step2.", cuid_)); + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Sending negotiation step2.", cuid_)); // Assuming no exception unsigned char* md = new unsigned char[20]; createReq1Hash(md); @@ -338,7 +338,7 @@ bool MSEHandshake::findInitiatorVCMarker() } } markerIndex_ = ptr-rbuf_; - A2_LOG_DEBUG(fmt("CUID#%lld - VC marker found at %lu", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - VC marker found at %lu", cuid_, static_cast(markerIndex_))); verifyVC(rbuf_+markerIndex_); @@ -358,18 +358,18 @@ bool MSEHandshake::receiveInitiatorCryptoSelectAndPadDLength() decryptor_->encrypt(CRYPTO_BITFIELD_LENGTH, rbufptr, rbufptr); if(rbufptr[3]&CRYPTO_PLAIN_TEXT && option_->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) { - A2_LOG_DEBUG(fmt("CUID#%lld - peer prefers plaintext.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - peer prefers plaintext.", cuid_)); negotiatedCryptoType_ = CRYPTO_PLAIN_TEXT; } if(rbufptr[3]&CRYPTO_ARC4) { - A2_LOG_DEBUG(fmt("CUID#%lld - peer prefers ARC4", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - peer prefers ARC4", cuid_)); negotiatedCryptoType_ = CRYPTO_ARC4; } if(negotiatedCryptoType_ == CRYPTO_NONE) { throw DL_ABORT_EX - (fmt("CUID#%lld - No supported crypto type selected.", + (fmt("CUID#%" PRId64 " - No supported crypto type selected.", cuid_)); } // padD length @@ -412,7 +412,7 @@ bool MSEHandshake::findReceiverHashMarker() } } markerIndex_ = ptr-rbuf_; - A2_LOG_DEBUG(fmt("CUID#%lld - Hash marker found at %lu.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Hash marker found at %lu.", cuid_, static_cast(markerIndex_))); verifyReq1Hash(rbuf_+markerIndex_); @@ -439,7 +439,7 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength const unsigned char* infohash = bittorrent::getInfoHash(*i); createReq23Hash(md, infohash); if(memcmp(md, rbufptr, sizeof(md)) == 0) { - A2_LOG_DEBUG(fmt("CUID#%lld - info hash found: %s", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - info hash found: %s", cuid_, util::toHex(infohash, INFO_HASH_LENGTH).c_str())); downloadContext = *i; @@ -460,17 +460,17 @@ bool MSEHandshake::receiveReceiverHashAndPadCLength // For now, choose ARC4. if(rbufptr[3]&CRYPTO_PLAIN_TEXT && option_->get(PREF_BT_MIN_CRYPTO_LEVEL) == V_PLAIN) { - A2_LOG_DEBUG(fmt("CUID#%lld - peer provides plaintext.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - peer provides plaintext.", cuid_)); negotiatedCryptoType_ = CRYPTO_PLAIN_TEXT; } else if(rbufptr[3]&CRYPTO_ARC4) { - A2_LOG_DEBUG(fmt("CUID#%lld - peer provides ARC4.", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - peer provides ARC4.", cuid_)); negotiatedCryptoType_ = CRYPTO_ARC4; } if(negotiatedCryptoType_ == CRYPTO_NONE) { throw DL_ABORT_EX - (fmt("CUID#%lld - No supported crypto type provided.", + (fmt("CUID#%" PRId64 " - No supported crypto type provided.", cuid_)); } // decrypt PadC length @@ -491,7 +491,7 @@ bool MSEHandshake::receiveReceiverIALength() if(iaLength_ > BtHandshakeMessage::MESSAGE_LENGTH) { throw DL_ABORT_EX(fmt("Too large IA length length: %u", iaLength_)); } - A2_LOG_DEBUG(fmt("CUID#%lld - len(IA)=%u.", cuid_, iaLength_)); + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - len(IA)=%u.", cuid_, iaLength_)); // shift rbuf_ shiftBuffer(2); return true; @@ -509,7 +509,7 @@ bool MSEHandshake::receiveReceiverIA() delete [] ia_; ia_ = new unsigned char[iaLength_]; decryptor_->encrypt(iaLength_, ia_, rbuf_); - A2_LOG_DEBUG(fmt("CUID#%lld - IA received.", cuid_)); + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - IA received.", cuid_)); // shift rbuf_ shiftBuffer(iaLength_); return true; @@ -548,10 +548,10 @@ void MSEHandshake::sendReceiverStep2() uint16_t MSEHandshake::verifyPadLength(const unsigned char* padlenbuf, const char* padName) { - A2_LOG_DEBUG(fmt("CUID#%lld - Verifying Pad length for %s", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Verifying Pad length for %s", cuid_, padName)); uint16_t padLength = decodeLength16(padlenbuf); - A2_LOG_DEBUG(fmt("CUID#%lld - len(%s)=%u", + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - len(%s)=%u", cuid_, padName, padLength)); if(padLength > 512) { throw DL_ABORT_EX @@ -562,7 +562,7 @@ uint16_t MSEHandshake::verifyPadLength(const unsigned char* padlenbuf, const cha void MSEHandshake::verifyVC(unsigned char* vcbuf) { - A2_LOG_DEBUG(fmt("CUID#%lld - Verifying VC.", cuid_)); + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Verifying VC.", cuid_)); decryptor_->encrypt(VC_LENGTH, vcbuf, vcbuf); if(memcmp(VC, vcbuf, VC_LENGTH) != 0) { throw DL_ABORT_EX @@ -572,7 +572,7 @@ void MSEHandshake::verifyVC(unsigned char* vcbuf) void MSEHandshake::verifyReq1Hash(const unsigned char* req1buf) { - A2_LOG_DEBUG(fmt("CUID#%lld - Verifying req hash.", cuid_)); + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Verifying req hash.", cuid_)); unsigned char md[20]; createReq1Hash(md); if(memcmp(md, req1buf, sizeof(md)) != 0) { diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index 43bd3a82..02b1e14c 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -186,9 +186,9 @@ void MultiDiskAdaptor::resetDiskWriterEntries() (fileEntry->getOffset()+fileEntry->getLength()-1)/ pieceLength_*pieceLength_; A2_LOG_DEBUG(fmt("Checking adjacent backward file to %s" - " whose lastPieceStartOffset+pieceLength_=%lld", + " whose lastPieceStartOffset+pieceLength_=%" PRId64 "", fileEntry->getPath().c_str(), - static_cast + static_cast (lastPieceStartOffset+pieceLength_))); ++itr; // adjacent backward files are not needed to be allocated. They @@ -197,9 +197,9 @@ void MultiDiskAdaptor::resetDiskWriterEntries() (!(*itr)->getFileEntry()->isRequested() || (*itr)->getFileEntry()->getLength() == 0); ++itr) { A2_LOG_DEBUG - (fmt("file=%s, offset=%lld", + (fmt("file=%s, offset=%" PRId64 "", (*itr)->getFileEntry()->getPath().c_str(), - static_cast + static_cast ((*itr)->getFileEntry()->getOffset()))); if((*itr)->getFileEntry()->getOffset() < static_cast(lastPieceStartOffset+pieceLength_)) { @@ -348,7 +348,7 @@ DiskWriterEntries::const_iterator findFirstDiskWriterEntry // In case when offset is out-of-range if(!isInRange(*first, offset)) { throw DL_ABORT_EX - (fmt(EX_FILE_OFFSET_OUT_OF_RANGE, static_cast(offset))); + (fmt(EX_FILE_OFFSET_OUT_OF_RANGE, static_cast(offset))); } return first; } @@ -359,8 +359,8 @@ void throwOnDiskWriterNotOpened(const SharedHandle& e, off_t offset) { throw DL_ABORT_EX - (fmt("DiskWriter for offset=%lld, filename=%s is not opened.", - static_cast(offset), + (fmt("DiskWriter for offset=%" PRId64 ", filename=%s is not opened.", + static_cast(offset), e->getFilePath().c_str())); } } // namespace diff --git a/src/OptionHandlerImpl.cc b/src/OptionHandlerImpl.cc index 8241e736..89c39298 100644 --- a/src/OptionHandlerImpl.cc +++ b/src/OptionHandlerImpl.cc @@ -165,15 +165,12 @@ void NumberOptionHandler::parseArg(Option& option, int64_t number) std::string msg = pref_->k; msg += " "; if(min_ == -1 && max_ != -1) { - msg += fmt(_("must be smaller than or equal to %lld."), - static_cast(max_)); + msg += fmt(_("must be smaller than or equal to %" PRId64 "."), max_); } else if(min_ != -1 && max_ != -1) { - msg += fmt(_("must be between %lld and %lld."), - static_cast(min_), - static_cast(max_)); + msg += fmt(_("must be between %" PRId64 " and %" PRId64 "."), + min_, max_); } else if(min_ != -1 && max_ == -1) { - msg += fmt(_("must be greater than or equal to %lld."), - static_cast(min_)); + msg += fmt(_("must be greater than or equal to %" PRId64 "."), min_); } else { msg += _("must be a number."); } diff --git a/src/PeerAbstractCommand.cc b/src/PeerAbstractCommand.cc index e1541d68..63420d61 100644 --- a/src/PeerAbstractCommand.cc +++ b/src/PeerAbstractCommand.cc @@ -78,7 +78,7 @@ PeerAbstractCommand::~PeerAbstractCommand() bool PeerAbstractCommand::execute() { - A2_LOG_DEBUG(fmt("CUID#%lld -" + A2_LOG_DEBUG(fmt("CUID#%" PRId64 " -" " socket: read:%d, write:%d, hup:%d, err:%d, noCheck:%d", getCuid(), readEventEnabled(), writeEventEnabled(), diff --git a/src/PeerConnection.cc b/src/PeerConnection.cc index 4dd9a3fc..48a78d93 100644 --- a/src/PeerConnection.cc +++ b/src/PeerConnection.cc @@ -201,7 +201,7 @@ bool PeerConnection::receiveHandshake(unsigned char* data, size_t& dataLength, if(remaining == 0 && !socket_->wantRead() && !socket_->wantWrite()) { // we got EOF A2_LOG_DEBUG - (fmt("CUID#%lld - In PeerConnection::receiveHandshake(), remain=%lu", + (fmt("CUID#%" PRId64 " - In PeerConnection::receiveHandshake(), remain=%lu", cuid_, static_cast(temp))); peer_->setDisconnectedGracefully(true); diff --git a/src/PeerListenCommand.cc b/src/PeerListenCommand.cc index 8051029a..401e1634 100644 --- a/src/PeerListenCommand.cc +++ b/src/PeerListenCommand.cc @@ -124,7 +124,7 @@ bool PeerListenCommand::execute() { A2_LOG_DEBUG(fmt("Accepted the connection from %s:%u.", peer->getIPAddress().c_str(), peer->getPort())); - A2_LOG_DEBUG(fmt("Added CUID#%lld to receive BitTorrent/MSE handshake.", + A2_LOG_DEBUG(fmt("Added CUID#%" PRId64 " to receive BitTorrent/MSE handshake.", cuid)); } catch(RecoverableException& ex) { A2_LOG_DEBUG_EX(fmt(MSG_ACCEPT_FAILURE, diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index 96cdf090..b0717759 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -396,9 +396,9 @@ void RequestGroup::createInitialCommand // truncate the file to downloadContext_->getTotalLength() A2_LOG_DEBUG (fmt("File size not match. File is opened in writable" - " mode. Expected:%lld Actual:%lld", - static_cast(downloadContext_->getTotalLength()), - static_cast(actualFileSize))); + " mode. Expected:%" PRId64 " Actual:%" PRId64 "", + static_cast(downloadContext_->getTotalLength()), + static_cast(actualFileSize))); } } // Call Load, Save and file allocation command here @@ -906,8 +906,8 @@ void RequestGroup::validateTotalLength(off_t expectedTotalLength, if(expectedTotalLength != actualTotalLength) { throw DL_ABORT_EX (fmt(EX_SIZE_MISMATCH, - static_cast(expectedTotalLength), - static_cast(actualTotalLength))); + static_cast(expectedTotalLength), + static_cast(actualTotalLength))); } } @@ -961,7 +961,7 @@ void RequestGroup::decreaseNumCommand() { --numCommand_; if(!numCommand_ && requestGroupMan_) { - A2_LOG_DEBUG(fmt("GID#%lld - Request queue check", gid_)); + A2_LOG_DEBUG(fmt("GID#%" PRId64 " - Request queue check", gid_)); requestGroupMan_->requestQueueCheck(); } } @@ -1156,7 +1156,7 @@ bool RequestGroup::needsFileAllocation() const DownloadResultHandle RequestGroup::createDownloadResult() const { - A2_LOG_DEBUG(fmt("GID#%lld - Creating DownloadResult.", gid_)); + A2_LOG_DEBUG(fmt("GID#%" PRId64 " - Creating DownloadResult.", gid_)); TransferStat st = calculateStat(); SharedHandle res(new DownloadResult()); res->gid = gid_; diff --git a/src/RequestGroup.h b/src/RequestGroup.h index 01c5b7cd..0c3e0485 100644 --- a/src/RequestGroup.h +++ b/src/RequestGroup.h @@ -73,8 +73,7 @@ class BtRuntime; class PeerStorage; #endif // ENABLE_BITTORRENT -// To make %lld happy, we use long long int instead of int64_t. -typedef long long int a2_gid_t; +typedef int64_t a2_gid_t; class RequestGroup { public: diff --git a/src/RequestGroupMan.cc b/src/RequestGroupMan.cc index 7a084cb1..27cdf962 100644 --- a/src/RequestGroupMan.cc +++ b/src/RequestGroupMan.cc @@ -207,7 +207,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#%lld not found in the waiting queue.", gid)); + throw DL_ABORT_EX(fmt("GID#%" PRId64 " not found in the waiting queue.", gid)); } SharedHandle rg = *i; const size_t maxPos = reservedGroups_.size()-1; @@ -387,7 +387,7 @@ public: #endif // ENABLE_BITTORRENT } else { A2_LOG_NOTICE - (fmt(_("Download GID#%lld not complete: %s"), + (fmt(_("Download GID#%" PRId64 " not complete: %s"), group->getGID(), group->getDownloadContext()->getBasePath().c_str())); group->saveControlFile(); diff --git a/src/RpcMethodImpl.cc b/src/RpcMethodImpl.cc index 1cebfdbd..aeeb7932 100644 --- a/src/RpcMethodImpl.cc +++ b/src/RpcMethodImpl.cc @@ -381,12 +381,12 @@ SharedHandle removeDownload if(!group) { group = e->getRequestGroupMan()->findReservedGroup(gid); if(!group) { - throw DL_ABORT_EX(fmt("Active Download not found for GID#%lld", gid)); + throw DL_ABORT_EX(fmt("Active Download not found for GID#%" PRId64 "", gid)); } if(group->isDependencyResolved()) { e->getRequestGroupMan()->removeReservedGroup(gid); } else { - throw DL_ABORT_EX(fmt("GID#%lld cannot be removed now", gid)); + throw DL_ABORT_EX(fmt("GID#%" PRId64 " cannot be removed now", gid)); } } else { if(forceRemove) { @@ -456,7 +456,7 @@ SharedHandle pauseDownload e->setRefreshInterval(0); return createGIDResponse(gid); } else { - throw DL_ABORT_EX(fmt("GID#%lld cannot be paused now", gid)); + throw DL_ABORT_EX(fmt("GID#%" PRId64 " cannot be paused now", gid)); } } } // namespace @@ -520,7 +520,7 @@ SharedHandle UnpauseRpcMethod::process SharedHandle group = e->getRequestGroupMan()->findReservedGroup(gid); if(!group || !group->isPauseRequested()) { - throw DL_ABORT_EX(fmt("GID#%lld cannot be unpaused now", gid)); + throw DL_ABORT_EX(fmt("GID#%" PRId64 " cannot be unpaused now", gid)); } else { group->setPauseRequested(false); e->getRequestGroupMan()->requestQueueCheck(); @@ -923,7 +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#%lld", gid)); + throw DL_ABORT_EX(fmt("No file data is available for GID#%" PRId64 "", gid)); } else { createFileEntry(files, dr->fileEntries.begin(), dr->fileEntries.end(), dr->totalLength, dr->pieceLength, dr->bitfield); @@ -950,7 +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#%lld", gid)); + throw DL_ABORT_EX(fmt("No URI data is available for GID#%" PRId64 "", gid)); } SharedHandle uriList = List::g(); // TODO Current implementation just returns first FileEntry's URIs. @@ -970,7 +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#%lld", gid)); + throw DL_ABORT_EX(fmt("No peer data is available for GID#%" PRId64 "", gid)); } SharedHandle peers = List::g(); const SharedHandle& btObject = @@ -1003,7 +1003,7 @@ SharedHandle TellStatusRpcMethod::process SharedHandle ds = e->getRequestGroupMan()->findDownloadResult(gid); if(!ds) { - throw DL_ABORT_EX(fmt("No such download for GID#%lld", gid)); + throw DL_ABORT_EX(fmt("No such download for GID#%" PRId64 "", gid)); } gatherStoppedDownload(entryDict, ds, keys); } else { @@ -1097,7 +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#%lld", gid)); + throw DL_ABORT_EX(fmt("Could not remove download result of GID#%" PRId64 "", gid)); } return VLB_OK; } @@ -1200,7 +1200,7 @@ SharedHandle ChangeOptionRpcMethod::process gatherChangeableOptionForReserved(&option, optsParam); changeOption(group, option, e); } else { - throw DL_ABORT_EX(fmt("Cannot change option for GID#%lld", gid)); + throw DL_ABORT_EX(fmt("Cannot change option for GID#%" PRId64 "", gid)); } } return VLB_OK; @@ -1289,7 +1289,7 @@ SharedHandle GetOptionRpcMethod::process SharedHandle group = findRequestGroup(e->getRequestGroupMan(), gid); if(!group) { - throw DL_ABORT_EX(fmt("Cannot get option for GID#%lld", gid)); + throw DL_ABORT_EX(fmt("Cannot get option for GID#%" PRId64 "", gid)); } SharedHandle result = Dict::g(); SharedHandle