From: Jordan Lee Date: Sun, 8 Sep 2013 17:32:09 +0000 (+0000) Subject: introduce TR_PRIuSIZE macro for portable printf()ing of size_t. mikedld X-Git-Tag: 2.83~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea7d2482dd73009adf37af335fc051f46e19051d;p=transmission introduce TR_PRIuSIZE macro for portable printf()ing of size_t. mikedld --- diff --git a/libtransmission/announcer-http.c b/libtransmission/announcer-http.c index 556f3b29a..dc3623fb9 100644 --- a/libtransmission/announcer-http.c +++ b/libtransmission/announcer-http.c @@ -262,18 +262,18 @@ on_announce_done (tr_session * session, response->downloads = i; if (tr_variantDictFindRaw (&benc, TR_KEY_peers6, &raw, &len)) { - dbgmsg (data->log_name, "got a peers6 length of %zu", len); + dbgmsg (data->log_name, "got a peers6 length of %"TR_PRIuSIZE, len); response->pex6 = tr_peerMgrCompact6ToPex (raw, len, NULL, 0, &response->pex6_count); } if (tr_variantDictFindRaw (&benc, TR_KEY_peers, &raw, &len)) { - dbgmsg (data->log_name, "got a compact peers length of %zu", len); + dbgmsg (data->log_name, "got a compact peers length of %"TR_PRIuSIZE, len); response->pex = tr_peerMgrCompactToPex (raw, len, NULL, 0, &response->pex_count); } else if (tr_variantDictFindList (&benc, TR_KEY_peers, &tmp)) { response->pex = listToPex (tmp, &response->pex_count); - dbgmsg (data->log_name, "got a peers list with %zu entries", + dbgmsg (data->log_name, "got a peers list with %"TR_PRIuSIZE" entries", response->pex_count); } } diff --git a/libtransmission/announcer-udp.c b/libtransmission/announcer-udp.c index b5bfea66a..2b16b3bcb 100644 --- a/libtransmission/announcer-udp.c +++ b/libtransmission/announcer-udp.c @@ -690,7 +690,7 @@ tau_tracker_upkeep (struct tau_tracker * tracker) return; } - dbgmsg (tracker->key, "addr %p -- connected %d (%zu %zu) -- connecting_at %zu", + dbgmsg (tracker->key, "addr %p -- connected %d (%"TR_PRIuSIZE" %"TR_PRIuSIZE") -- connecting_at %"TR_PRIuSIZE, tracker->addr, (int)(tracker->connection_expiration_time > now), (size_t)tracker->connection_expiration_time, (size_t)now, (size_t)tracker->connecting_at); @@ -871,7 +871,7 @@ tau_handle_message (tr_session * session, const uint8_t * msg, size_t msglen) tau_transaction_t transaction_id; struct evbuffer * buf; - /*fprintf (stderr, "got an incoming udp message w/len %zu\n", msglen);*/ + /*fprintf (stderr, "got an incoming udp message w/len %"TR_PRIuSIZE"\n", msglen);*/ if (!session || !session->announcer_udp) return false; diff --git a/libtransmission/announcer.c b/libtransmission/announcer.c index af04d3565..4d4bbb3ab 100644 --- a/libtransmission/announcer.c +++ b/libtransmission/announcer.c @@ -1035,8 +1035,8 @@ on_announce_done (const tr_announce_response * response, "interval:%d " "min_interval:%d " "tracker_id_str:%s " - "pex:%zu " - "pex6:%zu " + "pex:%"TR_PRIuSIZE" " + "pex6:%"TR_PRIuSIZE" " "err:%s " "warn:%s", (int)response->did_connect, @@ -1287,8 +1287,8 @@ on_scrape_error (tr_session * session, tr_tier * tier, const char * errmsg) /* schedule a rescrape */ interval = getRetryInterval (tier->currentTracker); - dbgmsg (tier, "Retrying scrape in %zu seconds.", (size_t)interval); - tr_logAddTorInfo (tier->tor, "Retrying scrape in %zu seconds.", (size_t)interval); + dbgmsg (tier, "Retrying scrape in %"TR_PRIuSIZE" seconds.", (size_t)interval); + tr_logAddTorInfo (tier->tor, "Retrying scrape in %"TR_PRIuSIZE" seconds.", (size_t)interval); tier->lastScrapeSucceeded = false; tier->scrapeAt = get_next_scrape_time (session, tier, interval); } diff --git a/libtransmission/bandwidth.c b/libtransmission/bandwidth.c index 42a238273..8939916b0 100644 --- a/libtransmission/bandwidth.c +++ b/libtransmission/bandwidth.c @@ -395,7 +395,7 @@ tr_bandwidthUsed (tr_bandwidth * b, #ifdef DEBUG_DIRECTION if ((dir == DEBUG_DIRECTION) && (band->isLimited)) -fprintf (stderr, "%p consumed %5zu bytes of %5s data... was %6zu, now %6zu left\n", +fprintf (stderr, "%p consumed %5"TR_PRIuSIZE" bytes of %5s data... was %6"TR_PRIuSIZE", now %6"TR_PRIuSIZE" left\n", b, byteCount, (isPieceData?"piece":"raw"), oldBytesLeft, band->bytesLeft); #endif diff --git a/libtransmission/cache.c b/libtransmission/cache.c index e80ca5dab..ceaee7c2d 100644 --- a/libtransmission/cache.c +++ b/libtransmission/cache.c @@ -96,7 +96,7 @@ getBlockRun (const tr_cache * cache, int pos, struct run_info * info) break; if (b->tor != ref->tor) break; - //fprintf (stderr, "pos %d tor %d block %zu time %zu\n", i, b->tor->uniqueId, (size_t)b->block, (size_t)b->time); + //fprintf (stderr, "pos %d tor %d block %"TR_PRIuSIZE" time %"TR_PRIuSIZE"\n", i, b->tor->uniqueId, (size_t)b->block, (size_t)b->time); } //fprintf (stderr, "run is %d long from [%d to %d)\n", (int)(i-pos), i, (int)pos); @@ -441,7 +441,7 @@ tr_cacheFlushFile (tr_cache * cache, tr_torrent * torrent, tr_file_index_t i) tr_torGetFileBlockRange (torrent, i, &first, &last); pos = findBlockPos (cache, torrent, first); - dbgmsg ("flushing file %d from cache to disk: blocks [%zu...%zu]", (int)i, (size_t)first, (size_t)last); + dbgmsg ("flushing file %d from cache to disk: blocks [%"TR_PRIuSIZE"...%"TR_PRIuSIZE"]", (int)i, (size_t)first, (size_t)last); /* flush out all the blocks in that file */ while (!err && (pos < tr_ptrArraySize (&cache->blocks))) diff --git a/libtransmission/handshake.c b/libtransmission/handshake.c index 24f7f02fd..e919c0e33 100644 --- a/libtransmission/handshake.c +++ b/libtransmission/handshake.c @@ -254,7 +254,7 @@ parseHandshake (tr_handshake * handshake, tr_torrent * tor; uint8_t peer_id[PEER_ID_LEN]; - dbgmsg (handshake, "payload: need %d, got %zu", + dbgmsg (handshake, "payload: need %d, got %"TR_PRIuSIZE, HANDSHAKE_SIZE, evbuffer_get_length (inbuf)); if (evbuffer_get_length (inbuf) < HANDSHAKE_SIZE) @@ -565,7 +565,7 @@ readPadD (tr_handshake * handshake, { const size_t needlen = handshake->pad_d_len; - dbgmsg (handshake, "pad d: need %zu, got %zu", + dbgmsg (handshake, "pad d: need %"TR_PRIuSIZE", got %"TR_PRIuSIZE, needlen, evbuffer_get_length (inbuf)); if (evbuffer_get_length (inbuf) < needlen) return READ_LATER; @@ -593,7 +593,7 @@ readHandshake (tr_handshake * handshake, uint8_t reserved[HANDSHAKE_FLAGS_LEN]; uint8_t hash[SHA_DIGEST_LENGTH]; - dbgmsg (handshake, "payload: need %d, got %zu", + dbgmsg (handshake, "payload: need %d, got %"TR_PRIuSIZE, INCOMING_HANDSHAKE_LEN, evbuffer_get_length (inbuf)); if (evbuffer_get_length (inbuf) < INCOMING_HANDSHAKE_LEN) @@ -734,7 +734,7 @@ readYa (tr_handshake * handshake, const uint8_t * secret; int len; - dbgmsg (handshake, "in readYa... need %d, have %zu", + dbgmsg (handshake, "in readYa... need %d, have %"TR_PRIuSIZE, KEY_LEN, evbuffer_get_length (inbuf)); if (evbuffer_get_length (inbuf) < KEY_LEN) return READ_LATER; @@ -884,7 +884,7 @@ readIA (tr_handshake * handshake, struct evbuffer * outbuf; uint32_t crypto_select; - dbgmsg (handshake, "reading IA... have %zu, need %zu", + dbgmsg (handshake, "reading IA... have %"TR_PRIuSIZE", need %"TR_PRIuSIZE, evbuffer_get_length (inbuf), needlen); if (evbuffer_get_length (inbuf) < needlen) return READ_LATER; @@ -961,7 +961,7 @@ readPayloadStream (tr_handshake * handshake, int i; const size_t needlen = HANDSHAKE_SIZE; - dbgmsg (handshake, "reading payload stream... have %zu, need %zu", + dbgmsg (handshake, "reading payload stream... have %"TR_PRIuSIZE", need %"TR_PRIuSIZE, evbuffer_get_length (inbuf), needlen); if (evbuffer_get_length (inbuf) < needlen) return READ_LATER; diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index 06d9bad05..2cb7ca803 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -416,7 +416,7 @@ utp_on_read (void *closure, const unsigned char *buf, size_t buflen) assert (tr_isPeerIo (io)); rc = evbuffer_add (io->inbuf, buf, buflen); - dbgmsg (io, "utp_on_read got %zu bytes", buflen); + dbgmsg (io, "utp_on_read got %"TR_PRIuSIZE" bytes", buflen); if (rc < 0) { tr_logAddNamedError ("UTP", "On read evbuffer_add"); @@ -435,7 +435,7 @@ utp_on_write (void *closure, unsigned char *buf, size_t buflen) assert (tr_isPeerIo (io)); rc = evbuffer_remove (io->outbuf, buf, buflen); - dbgmsg (io, "utp_on_write sending %zu bytes... evbuffer_remove returned %d", buflen, rc); + dbgmsg (io, "utp_on_write sending %"TR_PRIuSIZE" bytes... evbuffer_remove returned %d", buflen, rc); assert (rc == (int)buflen); /* if this fails, we've corrupted our bookkeeping somewhere */ if (rc < (long)buflen) { tr_logAddNamedError ("UTP", "Short write: %d < %ld", rc, (long)buflen); @@ -453,7 +453,7 @@ utp_get_rb_size (void *closure) bytes = tr_bandwidthClamp (&io->bandwidth, TR_DOWN, UTP_READ_BUFFER_SIZE); - dbgmsg (io, "utp_get_rb_size is saying it's ready to read %zu bytes", bytes); + dbgmsg (io, "utp_get_rb_size is saying it's ready to read %"TR_PRIuSIZE" bytes", bytes); return UTP_READ_BUFFER_SIZE - bytes; } @@ -514,7 +514,7 @@ utp_on_overhead (void *closure, uint8_t send, size_t count, int type UNUSED) tr_peerIo *io = closure; assert (tr_isPeerIo (io)); - dbgmsg (io, "utp_on_overhead -- count is %zu", count); + dbgmsg (io, "utp_on_overhead -- count is %"TR_PRIuSIZE, count); tr_bandwidthUsed (&io->bandwidth, send ? TR_UP : TR_DOWN, count, false, tr_time_msec ()); @@ -1269,7 +1269,7 @@ tr_peerIoTryWrite (tr_peerIo * io, size_t howmuch) { int n = 0; const size_t old_len = evbuffer_get_length (io->outbuf); - dbgmsg (io, "in tr_peerIoTryWrite %zu", howmuch); + dbgmsg (io, "in tr_peerIoTryWrite %"TR_PRIuSIZE, howmuch); if (howmuch > old_len) howmuch = old_len; @@ -1322,7 +1322,7 @@ tr_peerIoFlush (tr_peerIo * io, tr_direction dir, size_t limit) else bytesUsed = tr_peerIoTryWrite (io, limit); - dbgmsg (io, "flushing peer-io, direction %d, limit %zu, bytesUsed %d", (int)dir, limit, bytesUsed); + dbgmsg (io, "flushing peer-io, direction %d, limit %"TR_PRIuSIZE", bytesUsed %d", (int)dir, limit, bytesUsed); return bytesUsed; } diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index a774d01b2..998965d46 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -333,7 +333,7 @@ pokeBatchPeriod (tr_peerMsgs * msgs, int interval) static void dbgOutMessageLen (tr_peerMsgs * msgs) { - dbgmsg (msgs, "outMessage size is now %zu", evbuffer_get_length (msgs->outMessages)); + dbgmsg (msgs, "outMessage size is now %"TR_PRIuSIZE, evbuffer_get_length (msgs->outMessages)); } static void @@ -903,7 +903,7 @@ void tr_peerMsgsCancel (tr_peerMsgs * msgs, tr_block_index_t block) { struct peer_request req; -/*fprintf (stderr, "SENDING CANCEL MESSAGE FOR BLOCK %zu\n\t\tFROM PEER %p ------------------------------------\n", (size_t)block, msgs->peer);*/ +/*fprintf (stderr, "SENDING CANCEL MESSAGE FOR BLOCK %"TR_PRIuSIZE"\n\t\tFROM PEER %p ------------------------------------\n", (size_t)block, msgs->peer);*/ blockToReq (msgs->torrent, block, &req); protocolSendCancel (msgs, &req); } @@ -1291,7 +1291,7 @@ readBtId (tr_peerMsgs * msgs, struct evbuffer * inbuf, size_t inlen) tr_peerIoReadUint8 (msgs->io, inbuf, &id); msgs->incoming.id = id; - dbgmsg (msgs, "msgs->incoming.id is now %d; msgs->incoming.length is %zu", id, (size_t)msgs->incoming.length); + dbgmsg (msgs, "msgs->incoming.id is now %d; msgs->incoming.length is %"TR_PRIuSIZE, id, (size_t)msgs->incoming.length); if (id == BT_PIECE) { @@ -1454,7 +1454,7 @@ readBtPiece (tr_peerMsgs * msgs, fireClientGotPieceData (msgs, n); *setme_piece_bytes_read += n; - dbgmsg (msgs, "got %zu bytes for block %u:%u->%u ... %d remain", + dbgmsg (msgs, "got %"TR_PRIuSIZE" bytes for block %u:%u->%u ... %d remain", n, req->index, req->offset, req->length, (int)(req->length - evbuffer_get_length (block_buffer))); if (evbuffer_get_length (block_buffer) < req->length) @@ -1486,7 +1486,7 @@ readBtMessage (tr_peerMsgs * msgs, struct evbuffer * inbuf, size_t inlen) --msglen; /* id length */ - dbgmsg (msgs, "got BT id %d, len %d, buffer size is %zu", (int)id, (int)msglen, inlen); + dbgmsg (msgs, "got BT id %d, len %d, buffer size is %"TR_PRIuSIZE, (int)id, (int)msglen, inlen); if (inlen < msglen) return READ_LATER; @@ -1747,7 +1747,7 @@ canRead (tr_peerIo * io, void * vmsgs, size_t * piece) struct evbuffer * in = tr_peerIoGetReadBuffer (io); const size_t inlen = evbuffer_get_length (in); - dbgmsg (msgs, "canRead: inlen is %zu, msgs->state is %d", inlen, msgs->state); + dbgmsg (msgs, "canRead: inlen is %"TR_PRIuSIZE", msgs->state is %d", inlen, msgs->state); if (!inlen) { @@ -1915,14 +1915,14 @@ fillOutputBuffer (tr_peerMsgs * msgs, time_t now) if (haveMessages && !msgs->outMessagesBatchedAt) /* fresh batch */ { - dbgmsg (msgs, "started an outMessages batch (length is %zu)", evbuffer_get_length (msgs->outMessages)); + dbgmsg (msgs, "started an outMessages batch (length is %"TR_PRIuSIZE")", evbuffer_get_length (msgs->outMessages)); msgs->outMessagesBatchedAt = now; } else if (haveMessages && ((now - msgs->outMessagesBatchedAt) >= msgs->outMessagesBatchPeriod)) { const size_t len = evbuffer_get_length (msgs->outMessages); /* flush the protocol messages */ - dbgmsg (msgs, "flushing outMessages... to %p (length is %zu)", msgs->io, len); + dbgmsg (msgs, "flushing outMessages... to %p (length is %"TR_PRIuSIZE")", msgs->io, len); tr_peerIoWriteBuf (msgs->io, msgs->outMessages, false); msgs->clientSentAnythingAt = now; msgs->outMessagesBatchedAt = 0; @@ -2029,7 +2029,7 @@ fillOutputBuffer (tr_peerMsgs * msgs, time_t now) /* check the piece if it needs checking... */ if (!err && tr_torrentPieceNeedsCheck (msgs->torrent, req.index)) if ((err = !tr_torrentCheckPiece (msgs->torrent, req.index))) - tr_torrentSetLocalError (msgs->torrent, _("Please Verify Local Data! Piece #%zu is corrupt."), (size_t)req.index); + tr_torrentSetLocalError (msgs->torrent, _("Please Verify Local Data! Piece #%"TR_PRIuSIZE" is corrupt."), (size_t)req.index); if (err) { @@ -2130,7 +2130,7 @@ sendBitfield (tr_peerMsgs * msgs) evbuffer_add_uint32 (out, sizeof (uint8_t) + byte_count); evbuffer_add_uint8 (out, BT_BITFIELD); evbuffer_add (out, bytes, byte_count); - dbgmsg (msgs, "sending bitfield... outMessage size is now %zu", evbuffer_get_length (out)); + dbgmsg (msgs, "sending bitfield... outMessage size is now %"TR_PRIuSIZE, evbuffer_get_length (out)); pokeBatchPeriod (msgs, IMMEDIATE_PRIORITY_INTERVAL_SECS); tr_free (bytes); @@ -2425,7 +2425,7 @@ sendPex (tr_peerMsgs * msgs) evbuffer_add_uint8 (out, msgs->ut_pex_id); evbuffer_add_buffer (out, payload); pokeBatchPeriod (msgs, HIGH_PRIORITY_INTERVAL_SECS); - dbgmsg (msgs, "sending a pex message; outMessage size is now %zu", evbuffer_get_length (out)); + dbgmsg (msgs, "sending a pex message; outMessage size is now %"TR_PRIuSIZE, evbuffer_get_length (out)); dbgOutMessageLen (msgs); evbuffer_free (payload); diff --git a/libtransmission/resume.c b/libtransmission/resume.c index de3aef22d..473a9ee93 100644 --- a/libtransmission/resume.c +++ b/libtransmission/resume.c @@ -164,7 +164,7 @@ loadDND (tr_variant * dict, tr_torrent * tor) } else { - tr_logAddTorDbg (tor, "Couldn't load DND flags. DND list (%p) has %zu children; torrent has %d files", + tr_logAddTorDbg (tor, "Couldn't load DND flags. DND list (%p) has %"TR_PRIuSIZE" children; torrent has %d files", list, tr_variantListSize (list), (int)n); } diff --git a/libtransmission/rpc-server.c b/libtransmission/rpc-server.c index 9df5ddd1e..57c6ed976 100644 --- a/libtransmission/rpc-server.c +++ b/libtransmission/rpc-server.c @@ -387,7 +387,7 @@ add_response (struct evhttp_request * req, iovec[0].iov_len -= server->stream.avail_out; #if 0 - fprintf (stderr, "compressed response is %.2f of original (raw==%zu bytes; compressed==%zu)\n", + fprintf (stderr, "compressed response is %.2f of original (raw==%"TR_PRIuSIZE" bytes; compressed==%"TR_PRIuSIZE")\n", (double)evbuffer_get_length (out)/content_len, content_len, evbuffer_get_length (out)); #endif diff --git a/libtransmission/rpcimpl.c b/libtransmission/rpcimpl.c index 61824089e..10d3c78fe 100644 --- a/libtransmission/rpcimpl.c +++ b/libtransmission/rpcimpl.c @@ -1633,7 +1633,7 @@ gotMetadataFromURL (tr_session * session UNUSED, { struct add_torrent_idle_data * data = user_data; - dbgmsg ("torrentAdd: HTTP response code was %ld (%s); response length was %zu bytes", + dbgmsg ("torrentAdd: HTTP response code was %ld (%s); response length was %"TR_PRIuSIZE" bytes", response_code, tr_webGetResponseStr (response_code), response_byte_count); if (response_code==200 || response_code==221) /* http or ftp success.. */ diff --git a/libtransmission/session.c b/libtransmission/session.c index 0e47097ba..d079d12cd 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -676,7 +676,7 @@ onNowTimer (evutil_socket_t foo UNUSED, short bar UNUSED, void * vsession) if (usec < min) usec = min; tr_timerAdd (session->nowTimer, 0, usec); - /* fprintf (stderr, "time %zu sec, %zu microsec\n", (size_t)tr_time (), (size_t)tv.tv_usec); */ + /* fprintf (stderr, "time %"TR_PRIuSIZE" sec, %"TR_PRIuSIZE" microsec\n", (size_t)tr_time (), (size_t)tv.tv_usec); */ } static void loadBlocklists (tr_session * session); @@ -1868,7 +1868,7 @@ tr_sessionClose (tr_session * session) assert (tr_isSession (session)); - dbgmsg ("shutting down transmission session %p... now is %zu, deadline is %zu", session, (size_t)time (NULL), (size_t)deadline); + dbgmsg ("shutting down transmission session %p... now is %"TR_PRIuSIZE", deadline is %"TR_PRIuSIZE, session, (size_t)time (NULL), (size_t)deadline); /* close the session */ tr_runInEventThread (session, sessionCloseImpl, session); @@ -1885,7 +1885,7 @@ tr_sessionClose (tr_session * session) while ((session->shared || session->web || session->announcer || session->announcer_udp) && !deadlineReached (deadline)) { - dbgmsg ("waiting on port unmap (%p) or announcer (%p)... now %zu deadline %zu", + dbgmsg ("waiting on port unmap (%p) or announcer (%p)... now %"TR_PRIuSIZE" deadline %"TR_PRIuSIZE, session->shared, session->announcer, (size_t)time (NULL), (size_t)deadline); tr_wait_msec (50); } @@ -1897,7 +1897,7 @@ tr_sessionClose (tr_session * session) while (session->events != NULL) { static bool forced = false; - dbgmsg ("waiting for libtransmission thread to finish... now %zu deadline %zu", (size_t)time (NULL), (size_t)deadline); + dbgmsg ("waiting for libtransmission thread to finish... now %"TR_PRIuSIZE" deadline %"TR_PRIuSIZE, (size_t)time (NULL), (size_t)deadline); tr_wait_msec (100); if (deadlineReached (deadline) && !forced) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index ab92da161..3abf6a926 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -562,9 +562,9 @@ onTrackerResponse (tr_torrent * tor, const tr_tracker_event * event, void * unus const bool allAreSeeds = seedProbability == 100; if (allAreSeeds) - tr_logAddTorDbg (tor, "Got %zu seeds from tracker", event->pexCount); + tr_logAddTorDbg (tor, "Got %"TR_PRIuSIZE" seeds from tracker", event->pexCount); else - tr_logAddTorDbg (tor, "Got %zu peers from tracker", event->pexCount); + tr_logAddTorDbg (tor, "Got %"TR_PRIuSIZE" peers from tracker", event->pexCount); for (i = 0; i < event->pexCount; ++i) tr_peerMgrAddPex (tor, TR_PEER_FROM_TRACKER, &event->pex[i], seedProbability); @@ -2572,7 +2572,7 @@ tr_torrentCheckPiece (tr_torrent * tor, tr_piece_index_t pieceIndex) { const bool pass = tr_ioTestPiece (tor, pieceIndex); - tr_deeplog_tor (tor, "[LAZY] tr_torrentCheckPiece tested piece %zu, pass==%d", (size_t)pieceIndex, (int)pass); + tr_deeplog_tor (tor, "[LAZY] tr_torrentCheckPiece tested piece %"TR_PRIuSIZE", pass==%d", (size_t)pieceIndex, (int)pass); tr_torrentSetHasPiece (tor, pieceIndex, pass); tr_torrentSetPieceChecked (tor, pieceIndex); tor->anyDate = tr_time (); @@ -3240,7 +3240,7 @@ tr_torrentGotBlock (tr_torrent * tor, tr_block_index_t block) p = tr_torBlockPiece (tor, block); if (tr_torrentPieceIsComplete (tor, p)) { - tr_logAddTorDbg (tor, "[LAZY] checking just-completed piece %zu", (size_t)p); + tr_logAddTorDbg (tor, "[LAZY] checking just-completed piece %"TR_PRIuSIZE, (size_t)p); if (tr_torrentCheckPiece (tor, p)) { diff --git a/libtransmission/tr-utp.c b/libtransmission/tr-utp.c index c03ce74bf..1c0727350 100644 --- a/libtransmission/tr-utp.c +++ b/libtransmission/tr-utp.c @@ -65,8 +65,8 @@ UTP_RBDrained (struct UTPSocket *socket) bool UTP_Write (struct UTPSocket *socket, size_t count) { - tr_logAddNamedError (MY_NAME, "UTP_RBDrained (%p, %zu) was called.", socket, count); - dbgmsg ("UTP_RBDrained (%p, %zu) was called.", socket, count); + tr_logAddNamedError (MY_NAME, "UTP_RBDrained (%p, %"TR_PRIuSIZE") was called.", socket, count); + dbgmsg ("UTP_RBDrained (%p, %"TR_PRIuSIZE") was called.", socket, count); assert (0); /* FIXME: this is too much for the long term, but probably needed in the short term */ return false; } diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 1e805d172..76dabdd2b 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -83,6 +83,14 @@ extern "C" { #endif #endif +#ifndef TR_PRIuSIZE + #ifdef _MSC_VER + #define TR_PRIuSIZE "Iu" + #else + #define TR_PRIuSIZE "zu" + #endif +#endif + #if defined (WIN32) && defined (_MSC_VER) #define inline __inline #endif diff --git a/libtransmission/variant-benc.c b/libtransmission/variant-benc.c index 45d039e17..5048c5af0 100644 --- a/libtransmission/variant-benc.c +++ b/libtransmission/variant-benc.c @@ -297,7 +297,7 @@ saveStringFunc (const tr_variant * v, void * evbuf) size_t len; const char * str; tr_variantGetStr (v, &str, &len); - evbuffer_add_printf (evbuf, "%zu:", len); + evbuffer_add_printf (evbuf, "%"TR_PRIuSIZE":", len); evbuffer_add (evbuf, str, len); } diff --git a/libtransmission/variant-json.c b/libtransmission/variant-json.c index 66a5d3629..a4810ed44 100644 --- a/libtransmission/variant-json.c +++ b/libtransmission/variant-json.c @@ -91,7 +91,7 @@ error_handler (jsonsl_t jsn, if (data->source) { - tr_logAddError ("JSON parse failed in %s at pos %zu: %s -- remaining text \"%.16s\"", + tr_logAddError ("JSON parse failed in %s at pos %"TR_PRIuSIZE": %s -- remaining text \"%.16s\"", data->source, jsn->pos, jsonsl_strerror (error), @@ -99,7 +99,7 @@ error_handler (jsonsl_t jsn, } else { - tr_logAddError ("JSON parse failed at pos %zu: %s -- remaining text \"%.16s\"", + tr_logAddError ("JSON parse failed at pos %"TR_PRIuSIZE": %s -- remaining text \"%.16s\"", jsn->pos, jsonsl_strerror (error), buf); diff --git a/libtransmission/web.c b/libtransmission/web.c index 5d8ecab8a..a51bbd899 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -133,7 +133,7 @@ writeFunc (void * ptr, size_t size, size_t nmemb, void * vtask) } evbuffer_add (task->response, ptr, byteCount); - dbgmsg ("wrote %zu bytes to task %p's buffer", byteCount, task); + dbgmsg ("wrote %"TR_PRIuSIZE" bytes to task %p's buffer", byteCount, task); return byteCount; } diff --git a/utils/edit.c b/utils/edit.c index ce29ae584..5bbda0723 100644 --- a/utils/edit.c +++ b/utils/edit.c @@ -279,7 +279,7 @@ addURL (tr_variant * metainfo, const char * url) { tr_variant * tier = tr_variantListAddList (announce_list, 1); tr_variantListAddStr (tier, url); - printf ("\tAdded \"%s\" to \"announce-list\" tier %zu\n", url, tr_variantListSize (announce_list)); + printf ("\tAdded \"%s\" to \"announce-list\" tier %"TR_PRIuSIZE"\n", url, tr_variantListSize (announce_list)); changed = true; } }