From: Dmitry Kurochkin Date: Thu, 28 Jun 2012 05:14:18 +0000 (-0600) Subject: Fix build with GCC 4.7 (and probably other C++11 compilers). X-Git-Tag: SQUID_3_2_0_18~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41985789d72177dfdce1e076df9f0d18786d2266;p=thirdparty%2Fsquid.git Fix build with GCC 4.7 (and probably other C++11 compilers). User-defined literals introduced by C++11 break some previously valid code, resulting in errors when building with GCC v4.7. For example: error: unable to find string literal operator 'operator"" PRIu64' In particular, whitespace is now needed after a string literal and before something that could be a valid user-defined literal. See "User-defined literals and whitespace" section at [1] for more details. The patch adds spaces between string literals and macros. [1] http://gcc.gnu.org/gcc-4.7/porting_to.html --- diff --git a/src/BodyPipe.cc b/src/BodyPipe.cc index 600317b4ef..b792623e41 100644 --- a/src/BodyPipe.cc +++ b/src/BodyPipe.cc @@ -447,9 +447,9 @@ const char *BodyPipe::status() const outputBuffer.append(" [", 2); - outputBuffer.Printf("%"PRIu64"<=%"PRIu64, theGetSize, thePutSize); + outputBuffer.Printf("%" PRIu64 "<=%" PRIu64, theGetSize, thePutSize); if (theBodySize >= 0) - outputBuffer.Printf("<=%"PRId64, theBodySize); + outputBuffer.Printf("<=%" PRId64, theBodySize); else outputBuffer.append("<=?", 3); diff --git a/src/ClientDelayConfig.cc b/src/ClientDelayConfig.cc index 88db3b6d77..387ea8449f 100644 --- a/src/ClientDelayConfig.cc +++ b/src/ClientDelayConfig.cc @@ -12,7 +12,7 @@ void ClientDelayPool::dump(StoreEntry * entry, unsigned int poolNumberMinusOne) LOCAL_ARRAY(char, nom, 32); snprintf(nom, 32, "client_delay_access %d", poolNumberMinusOne + 1); dump_acl_access(entry, nom, access); - storeAppendPrintf(entry, "client_delay_parameters %d %d %"PRId64"\n", poolNumberMinusOne + 1, rate,highwatermark); + storeAppendPrintf(entry, "client_delay_parameters %d %d %" PRId64 "\n", poolNumberMinusOne + 1, rate,highwatermark); storeAppendPrintf(entry, "\n"); } diff --git a/src/DelaySpec.cc b/src/DelaySpec.cc index 5481a4c24c..7beed06239 100644 --- a/src/DelaySpec.cc +++ b/src/DelaySpec.cc @@ -57,14 +57,14 @@ DelaySpec::stats (StoreEntry * sentry, char const *label) const } storeAppendPrintf(sentry, "\t%s:\n", label); - storeAppendPrintf(sentry, "\t\tMax: %"PRId64"\n", max_bytes); + storeAppendPrintf(sentry, "\t\tMax: %" PRId64 "\n", max_bytes); storeAppendPrintf(sentry, "\t\tRestore: %d\n", restore_bps); } void DelaySpec::dump (StoreEntry *entry) const { - storeAppendPrintf(entry, " %d/%"PRId64"", restore_bps, max_bytes); + storeAppendPrintf(entry, " %d/%" PRId64 "", restore_bps, max_bytes); } void diff --git a/src/DiskIO/DiskDaemon/diskd.cc b/src/DiskIO/DiskDaemon/diskd.cc index 4f225531c1..e38bcbfc82 100644 --- a/src/DiskIO/DiskDaemon/diskd.cc +++ b/src/DiskIO/DiskDaemon/diskd.cc @@ -156,12 +156,12 @@ do_read(diomsg * r, int len, char *buf) if (r->offset > -1 && r->offset != fs->offset) { DEBUG(2) { - fprintf(stderr, "seeking to %"PRId64"\n", (int64_t)r->offset); + fprintf(stderr, "seeking to %" PRId64 "\n", (int64_t)r->offset); } if (lseek(fs->fd, r->offset, SEEK_SET) < 0) { DEBUG(1) { - fprintf(stderr, "%d FD %d, offset %"PRId64": ", (int) mypid, fs->fd, (int64_t)r->offset); + fprintf(stderr, "%d FD %d, offset %" PRId64 ": ", (int) mypid, fs->fd, (int64_t)r->offset); perror("lseek"); } } @@ -169,7 +169,7 @@ do_read(diomsg * r, int len, char *buf) x = read(fs->fd, buf, readlen); DEBUG(2) { - fprintf(stderr, "%d READ %d,%d,%"PRId64" ret %d\n", (int) mypid, + fprintf(stderr, "%d READ %d,%d,%" PRId64 " ret %d\n", (int) mypid, fs->fd, readlen, (int64_t)r->offset, x); } @@ -207,14 +207,14 @@ do_write(diomsg * r, int len, const char *buf) if (r->offset > -1 && r->offset != fs->offset) { if (lseek(fs->fd, r->offset, SEEK_SET) < 0) { DEBUG(1) { - fprintf(stderr, "%d FD %d, offset %"PRId64": ", (int) mypid, fs->fd, (int64_t)r->offset); + fprintf(stderr, "%d FD %d, offset %" PRId64 ": ", (int) mypid, fs->fd, (int64_t)r->offset); perror("lseek"); } } } DEBUG(2) { - fprintf(stderr, "%d WRITE %d,%d,%"PRId64"\n", (int) mypid, + fprintf(stderr, "%d WRITE %d,%d,%" PRId64 "\n", (int) mypid, fs->fd, wrtlen, (int64_t)r->offset); } x = write(fs->fd, buf, wrtlen); diff --git a/src/HttpHdrContRange.cc b/src/HttpHdrContRange.cc index 85fdb4fe8f..88e334c334 100644 --- a/src/HttpHdrContRange.cc +++ b/src/HttpHdrContRange.cc @@ -129,7 +129,7 @@ httpHdrRangeRespSpecPackInto(const HttpHdrRangeSpec * spec, Packer * p) if (!known_spec(spec->offset) || !known_spec(spec->length)) packerPrintf(p, "*"); else - packerPrintf(p, "bytes %"PRId64"-%"PRId64, + packerPrintf(p, "bytes %" PRId64 "-%" PRId64, spec->offset, spec->offset + spec->length - 1); } @@ -233,7 +233,7 @@ httpHdrContRangePackInto(const HttpHdrContRange * range, Packer * p) if (!known_spec(range->elength)) packerPrintf(p, "/*"); else - packerPrintf(p, "/%"PRId64, range->elength); + packerPrintf(p, "/%" PRId64, range->elength); } void diff --git a/src/HttpHdrRange.cc b/src/HttpHdrRange.cc index f43b7f62f0..7acfa8205a 100644 --- a/src/HttpHdrRange.cc +++ b/src/HttpHdrRange.cc @@ -132,11 +132,11 @@ void HttpHdrRangeSpec::packInto(Packer * packer) const { if (!known_spec(offset)) /* suffix */ - packerPrintf(packer, "-%"PRId64, length); + packerPrintf(packer, "-%" PRId64, length); else if (!known_spec(length)) /* trailer */ - packerPrintf(packer, "%"PRId64"-", offset); + packerPrintf(packer, "%" PRId64 "-", offset); else /* range */ - packerPrintf(packer, "%"PRId64"-%"PRId64, + packerPrintf(packer, "%" PRId64 "-%" PRId64, offset, offset + length - 1); } diff --git a/src/MemObject.cc b/src/MemObject.cc index 5e677ccbd1..a544e976a3 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -225,13 +225,13 @@ MemObject::stat(MemBuf * mb) const RequestMethodStr(method), log_url); if (vary_headers) mb->Printf("\tvary_headers: %s\n", vary_headers); - mb->Printf("\tinmem_lo: %"PRId64"\n", inmem_lo); - mb->Printf("\tinmem_hi: %"PRId64"\n", data_hdr.endOffset()); - mb->Printf("\tswapout: %"PRId64" bytes queued\n", + mb->Printf("\tinmem_lo: %" PRId64 "\n", inmem_lo); + mb->Printf("\tinmem_hi: %" PRId64 "\n", data_hdr.endOffset()); + mb->Printf("\tswapout: %" PRId64 " bytes queued\n", swapout.queue_offset); if (swapout.sio.getRaw()) - mb->Printf("\tswapout: %"PRId64" bytes written\n", + mb->Printf("\tswapout: %" PRId64 " bytes written\n", (int64_t) swapout.sio->offset()); StoreClientStats statsVisitor(mb); diff --git a/src/MemStore.cc b/src/MemStore.cc index c66560165b..1e055f3c53 100644 --- a/src/MemStore.cc +++ b/src/MemStore.cc @@ -76,7 +76,7 @@ MemStore::stat(StoreEntry &e) const const int limit = map->entryLimit(); storeAppendPrintf(&e, "Maximum entries: %9d\n", limit); if (limit > 0) { - storeAppendPrintf(&e, "Current entries: %"PRId64" %.2f%%\n", + storeAppendPrintf(&e, "Current entries: %" PRId64 " %.2f%%\n", currentCount(), (100.0 * currentCount() / limit)); if (limit < 100) { // XXX: otherwise too expensive to count diff --git a/src/SwapDir.cc b/src/SwapDir.cc index 43af800a0c..867fd7f5f2 100644 --- a/src/SwapDir.cc +++ b/src/SwapDir.cc @@ -342,10 +342,10 @@ void SwapDir::optionObjectSizeDump(StoreEntry * e) const { if (min_objsize != 0) - storeAppendPrintf(e, " min-size=%"PRId64, min_objsize); + storeAppendPrintf(e, " min-size=%" PRId64, min_objsize); if (max_objsize != -1) - storeAppendPrintf(e, " max-size=%"PRId64, max_objsize); + storeAppendPrintf(e, " max-size=%" PRId64, max_objsize); } // some SwapDirs may maintain their indexes and be able to lookup an entry key diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 6a65f60ebd..4636870408 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -3035,7 +3035,7 @@ static void dump_time_msec(StoreEntry * entry, const char *name, time_msec_t var) { if (var % 1000) - storeAppendPrintf(entry, "%s %"PRId64" milliseconds\n", name, var); + storeAppendPrintf(entry, "%s %" PRId64 " milliseconds\n", name, var); else storeAppendPrintf(entry, "%s %d seconds\n", name, (int)(var/1000) ); } @@ -3086,13 +3086,13 @@ dump_kb_size_t(StoreEntry * entry, const char *name, size_t var) static void dump_b_int64_t(StoreEntry * entry, const char *name, int64_t var) { - storeAppendPrintf(entry, "%s %"PRId64" %s\n", name, var, B_BYTES_STR); + storeAppendPrintf(entry, "%s %" PRId64 " %s\n", name, var, B_BYTES_STR); } static void dump_kb_int64_t(StoreEntry * entry, const char *name, int64_t var) { - storeAppendPrintf(entry, "%s %"PRId64" %s\n", name, var, B_KBYTES_STR); + storeAppendPrintf(entry, "%s %" PRId64 " %s\n", name, var, B_KBYTES_STR); } #if UNUSED_CODE diff --git a/src/client_side.cc b/src/client_side.cc index d779977a8b..76c3014a2c 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1001,7 +1001,7 @@ ClientSocketContext::packChunk(const StoreIOBuffer &bodyData, MemBuf &mb) static_cast(lengthToSend(bodyData.range())); noteSentBodyBytes(length); - mb.Printf("%"PRIX64"\r\n", length); + mb.Printf("%" PRIX64 "\r\n", length); mb.append(bodyData.data, length); mb.Printf("\r\n"); } diff --git a/src/fde.cc b/src/fde.cc index 61854c6658..910d0d496d 100644 --- a/src/fde.cc +++ b/src/fde.cc @@ -56,11 +56,11 @@ fde::dumpStats (StoreEntry &dumpEntry, int fdNumber) #if _SQUID_MSWIN_ - storeAppendPrintf(&dumpEntry, "%4d 0x%-8lX %-6.6s %4d %7"PRId64"%c %7"PRId64"%c %-21s %s\n", + storeAppendPrintf(&dumpEntry, "%4d 0x%-8lX %-6.6s %4d %7" PRId64 "%c %7" PRId64 "%c %-21s %s\n", fdNumber, win32.handle, #else - storeAppendPrintf(&dumpEntry, "%4d %-6.6s %4d %7"PRId64"%c %7"PRId64"%c %-21s %s\n", + storeAppendPrintf(&dumpEntry, "%4d %-6.6s %4d %7" PRId64 "%c %7" PRId64 "%c %-21s %s\n", fdNumber, #endif fdTypeStr[type], diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index 2d6b97f8e2..e0a02f8b66 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -973,7 +973,7 @@ void CossSwapDir::statfs(StoreEntry & sentry) const { storeAppendPrintf(&sentry, "\n"); - storeAppendPrintf(&sentry, "Maximum Size: %"PRIu64" KB\n", maxSize() >> 10); + storeAppendPrintf(&sentry, "Maximum Size: %" PRIu64 " KB\n", maxSize() >> 10); storeAppendPrintf(&sentry, "Current Size: %.2f KB\n", currentSize() / 1024.0); storeAppendPrintf(&sentry, "Percent Used: %0.2f%%\n", Math::doublePercent(currentSize(), maxSize()) ); @@ -1066,7 +1066,7 @@ CossSwapDir::swappedOut(const StoreEntry &e) void CossSwapDir::dump(StoreEntry &entry)const { - storeAppendPrintf(&entry, " %"PRIu64, maxSize() >> 20); + storeAppendPrintf(&entry, " %" PRIu64, maxSize() >> 20); dumpOptions(&entry); } diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index 4d8e7b60e0..d624ec7b01 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -351,7 +351,7 @@ void Rock::SwapDir::dumpTimeOption(StoreEntry * e) const { if (fileConfig.ioTimeout) - storeAppendPrintf(e, " swap-timeout=%"PRId64, + storeAppendPrintf(e, " swap-timeout=%" PRId64, static_cast(fileConfig.ioTimeout)); } @@ -786,7 +786,7 @@ void Rock::SwapDir::statfs(StoreEntry &e) const { storeAppendPrintf(&e, "\n"); - storeAppendPrintf(&e, "Maximum Size: %"PRIu64" KB\n", maxSize() >> 10); + storeAppendPrintf(&e, "Maximum Size: %" PRIu64 " KB\n", maxSize() >> 10); storeAppendPrintf(&e, "Current Size: %.2f KB %.2f%%\n", currentSize() / 1024.0, Math::doublePercent(currentSize(), maxSize())); diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 228ebcd034..96a0cfa2c2 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -318,7 +318,7 @@ UFSSwapDir::statfs(StoreEntry & sentry) const int x; storeAppendPrintf(&sentry, "First level subdirectories: %d\n", l1); storeAppendPrintf(&sentry, "Second level subdirectories: %d\n", l2); - storeAppendPrintf(&sentry, "Maximum Size: %"PRIu64" KB\n", maxSize() >> 10); + storeAppendPrintf(&sentry, "Maximum Size: %" PRIu64 " KB\n", maxSize() >> 10); storeAppendPrintf(&sentry, "Current Size: %.2f KB\n", currentSize() / 1024.0); storeAppendPrintf(&sentry, "Percent Used: %0.2f%%\n", Math::doublePercent(currentSize(), maxSize())); @@ -1347,7 +1347,7 @@ UFSSwapDir::replacementRemove(StoreEntry * e) void UFSSwapDir::dump(StoreEntry & entry) const { - storeAppendPrintf(&entry, " %"PRIu64" %d %d", maxSize() >> 20, l1, l2); + storeAppendPrintf(&entry, " %" PRIu64 " %d %d", maxSize() >> 20, l1, l2); dumpOptions(&entry); } diff --git a/src/ftp.cc b/src/ftp.cc index 8dd4d6c114..3499570dc2 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1060,7 +1060,7 @@ FtpStateData::htmlifyListEntry(const char *line) snprintf(icon, 2048, "\"%-6s\"", mimeGetIconURL(parts->name), "[FILE]"); - snprintf(size, 2048, " %6"PRId64"k", parts->size); + snprintf(size, 2048, " %6" PRId64 "k", parts->size); break; } @@ -3096,7 +3096,7 @@ ftpSendRest(FtpStateData * ftpState) debugs(9, 3, HERE); - snprintf(cbuf, CTRL_BUFLEN, "REST %"PRId64"\r\n", ftpState->restart_offset); + snprintf(cbuf, CTRL_BUFLEN, "REST %" PRId64 "\r\n", ftpState->restart_offset); ftpState->writeCommand(cbuf); ftpState->state = SENT_REST; } diff --git a/src/log/FormatHttpdCombined.cc b/src/log/FormatHttpdCombined.cc index 67374ae212..4980462d9d 100644 --- a/src/log/FormatHttpdCombined.cc +++ b/src/log/FormatHttpdCombined.cc @@ -65,7 +65,7 @@ Log::Format::HttpdCombined(AccessLogEntry * al, Logfile * logfile) char clientip[MAX_IPSTRLEN]; al->getLogClientIp(clientip, MAX_IPSTRLEN); - logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %"PRId64" \"%s\" \"%s\" %s%s:%s%s", + logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %" PRId64 " \"%s\" \"%s\" %s%s:%s%s", clientip, user_ident ? user_ident : dash_str, user_auth ? user_auth : dash_str, diff --git a/src/log/FormatHttpdCommon.cc b/src/log/FormatHttpdCommon.cc index 82a0a03015..bcb5d74d39 100644 --- a/src/log/FormatHttpdCommon.cc +++ b/src/log/FormatHttpdCommon.cc @@ -49,7 +49,7 @@ Log::Format::HttpdCommon(AccessLogEntry * al, Logfile * logfile) char clientip[MAX_IPSTRLEN]; al->getLogClientIp(clientip, MAX_IPSTRLEN); - logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %"PRId64" %s%s:%s%s", + logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %" PRId64 " %s%s:%s%s", clientip, user_ident ? user_ident : dash_str, user_auth ? user_auth : dash_str, diff --git a/src/log/FormatSquidIcap.cc b/src/log/FormatSquidIcap.cc index 72a98c7b51..ffa9223c0f 100644 --- a/src/log/FormatSquidIcap.cc +++ b/src/log/FormatSquidIcap.cc @@ -75,7 +75,7 @@ Log::Format::SquidIcap(AccessLogEntry * al, Logfile * logfile) if (user && !*user) safe_free(user); - logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %"PRId64" %s %s %s -/%s -\n", + logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %" PRId64 " %s %s %s -/%s -\n", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, al->icap.trTime, diff --git a/src/log/FormatSquidNative.cc b/src/log/FormatSquidNative.cc index b3eb1c1af3..c5b059da0d 100644 --- a/src/log/FormatSquidNative.cc +++ b/src/log/FormatSquidNative.cc @@ -64,7 +64,7 @@ Log::Format::SquidNative(AccessLogEntry * al, Logfile * logfile) char clientip[MAX_IPSTRLEN]; al->getLogClientIp(clientip, MAX_IPSTRLEN); - logfilePrintf(logfile, "%9ld.%03d %6d %s %s%s/%03d %"PRId64" %s %s %s %s%s/%s %s%s", + logfilePrintf(logfile, "%9ld.%03d %6d %s %s%s/%03d %" PRId64 " %s %s %s %s%s/%s %s%s", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, al->cache.msec, diff --git a/src/stat.cc b/src/stat.cc index be671b357a..d3fe2e542e 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -2013,7 +2013,7 @@ statClientRequests(StoreEntry * s) if (conn != NULL) { const int fd = conn->clientConnection->fd; - storeAppendPrintf(s, "\tFD %d, read %"PRId64", wrote %"PRId64"\n", fd, + storeAppendPrintf(s, "\tFD %d, read %" PRId64 ", wrote %" PRId64 "\n", fd, fd_table[fd].bytes_read, fd_table[fd].bytes_written); storeAppendPrintf(s, "\tFD desc: %s\n", fd_table[fd].desc); storeAppendPrintf(s, "\tin: buf %p, offset %ld, size %ld\n", diff --git a/src/store_client.cc b/src/store_client.cc index 8e022d8093..cca9766c58 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -876,7 +876,7 @@ store_client::dumpStats(MemBuf * output, int clientNumber) const output->Printf("\tClient #%d, %p\n", clientNumber, _callback.callback_data); - output->Printf("\t\tcopy_offset: %"PRId64"\n", + output->Printf("\t\tcopy_offset: %" PRId64 "\n", copyInto.offset); output->Printf("\t\tcopy_size: %d\n", diff --git a/src/store_dir.cc b/src/store_dir.cc index 93f3f94380..0b27b76ea8 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -352,7 +352,7 @@ StoreController::stat(StoreEntry &output) const storeAppendPrintf(&output, "Store Directory Statistics:\n"); storeAppendPrintf(&output, "Store Entries : %lu\n", (unsigned long int)StoreEntry::inUseCount()); - storeAppendPrintf(&output, "Maximum Swap Size : %"PRIu64" KB\n", + storeAppendPrintf(&output, "Maximum Swap Size : %" PRIu64 " KB\n", maxSize() >> 10); storeAppendPrintf(&output, "Current Store Swap Size: %.2f KB\n", currentSize() / 1024.0); diff --git a/src/store_log.cc b/src/store_log.cc index 928512f9b4..d415de5383 100644 --- a/src/store_log.cc +++ b/src/store_log.cc @@ -86,7 +86,7 @@ storeLog(int tag, const StoreEntry * e) String ctype=(reply->content_type.size() ? reply->content_type.termedBuf() : str_unknown); logfileLineStart(storelog); - logfilePrintf(storelog, "%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d " SQUIDSTRINGPH " %"PRId64"/%"PRId64" %s %s\n", + logfilePrintf(storelog, "%9d.%03d %-7s %02d %08X %s %4d %9d %9d %9d " SQUIDSTRINGPH " %" PRId64 "/%" PRId64 " %s %s\n", (int) current_time.tv_sec, (int) current_time.tv_usec / 1000, storeLogTags[tag], diff --git a/src/tools.cc b/src/tools.cc index 931917f769..8267f16822 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -176,7 +176,7 @@ dumpMallocStats(void) mp = mallinfo(); - fprintf(debug_log, "Memory usage for "APP_SHORTNAME" via mallinfo():\n"); + fprintf(debug_log, "Memory usage for " APP_SHORTNAME " via mallinfo():\n"); fprintf(debug_log, "\ttotal space in arena: %6ld KB\n", (long)mp.arena >> 10);