From: Dmitry Kurochkin Date: Sun, 23 Sep 2012 06:30:14 +0000 (-0600) Subject: Fix build with GCC 4.7 (and probably other C++11 compilers). X-Git-Tag: SQUID_3_1_21~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1274a9b7ba79e3112c0299b66ad9640ac454ed62;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 417e1bbd4b..34060eb262 100644 --- a/src/BodyPipe.cc +++ b/src/BodyPipe.cc @@ -423,9 +423,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/DelaySpec.cc b/src/DelaySpec.cc index 2718eb23ab..80edc2d9d9 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 d3e39ac71f..b56a5ef97c 100644 --- a/src/DiskIO/DiskDaemon/diskd.cc +++ b/src/DiskIO/DiskDaemon/diskd.cc @@ -149,11 +149,11 @@ 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"); } } @@ -161,7 +161,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); if (x < 0) { @@ -198,14 +198,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 c0af6ad673..f2531aa48a 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 975f2ca4ed..32a67a0a23 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 d0ca9b0419..8f59169073 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -213,13 +213,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/SwapDir.cc b/src/SwapDir.cc index ff090b6ff5..cc05fd7c7a 100644 --- a/src/SwapDir.cc +++ b/src/SwapDir.cc @@ -258,7 +258,7 @@ void SwapDir::optionMaxSizeDump(StoreEntry * e) const { if (max_objsize != -1) - storeAppendPrintf(e, " max-size=%"PRId64, max_objsize); + storeAppendPrintf(e, " max-size=%" PRId64, max_objsize); } /* Swapdirs do not have an index of their own - thus they ask their parent.. diff --git a/src/access_log.cc b/src/access_log.cc index cbdd2a7f74..3c0e3dbe82 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -1778,7 +1778,7 @@ accessLogSquid(AccessLogEntry * al, Logfile * logfile) safe_free(user); if (!Config.onoff.log_mime_hdrs) { - logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %"PRId64" %s %s %s %s%s/%s %s\n", + logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %" PRId64 " %s %s %s %s%s/%s %s\n", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, al->cache.msec, @@ -1796,7 +1796,7 @@ accessLogSquid(AccessLogEntry * al, Logfile * logfile) } else { char *ereq = log_quote(al->headers.request); char *erep = log_quote(al->headers.reply); - logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %"PRId64" %s %s %s %s%s/%s %s [%s] [%s]\n", + logfilePrintf(logfile, "%9ld.%03d %6d %s %s/%03d %" PRId64 " %s %s %s %s%s/%s %s [%s] [%s]\n", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, al->cache.msec, @@ -1838,7 +1838,7 @@ accessLogCommon(AccessLogEntry * al, Logfile * logfile) user2 = accessLogFormatName(al->cache.rfc931); - logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %"PRId64" %s:%s%s", + logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %" PRId64 " %s:%s%s", client, user2 ? user2 : dash_str, user1 ? user1 : dash_str, @@ -1900,7 +1900,7 @@ accessLogICAPSquid(AccessLogEntry * al, Logfile * logfile) if (user && !*user) safe_free(user); - logfilePrintf(logfile, "%9ld.%03d %6d %s -/%03d %"PRId64" %s %s %s -/%s -\n", + logfilePrintf(logfile, "%9ld.%03d %6d %s -/%03d %" PRId64 " %s %s %s -/%s -\n", (long int) current_time.tv_sec, (int) current_time.tv_usec / 1000, diff --git a/src/cache_cf.cc b/src/cache_cf.cc index d6d456468b..4e3332f35f 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -2698,13 +2698,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); } static void diff --git a/src/fde.cc b/src/fde.cc index b66542cf41..d56d5f1232 100644 --- a/src/fde.cc +++ b/src/fde.cc @@ -56,11 +56,11 @@ fde::dumpStats (StoreEntry &dumpEntry, int fdNumber) #ifdef _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 6a4641d5c5..65818c814a 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -996,8 +996,8 @@ void CossSwapDir::statfs(StoreEntry & sentry) const { storeAppendPrintf(&sentry, "\n"); - storeAppendPrintf(&sentry, "Maximum Size: %"PRIu64" KB\n", max_size); - storeAppendPrintf(&sentry, "Current Size: %"PRIu64" KB\n", cur_size); + storeAppendPrintf(&sentry, "Maximum Size: %" PRIu64 " KB\n", max_size); + storeAppendPrintf(&sentry, "Current Size: %" PRIu64 " KB\n", cur_size); storeAppendPrintf(&sentry, "Percent Used: %0.2f%%\n", (100.0 * (double)cur_size / (double)max_size) ); storeAppendPrintf(&sentry, "Number of object collisions: %d\n", (int) numcollisions); @@ -1095,7 +1095,7 @@ CossSwapDir::reconfigure(int index, char *path) void CossSwapDir::dump(StoreEntry &entry)const { - storeAppendPrintf(&entry, " %"PRIu64"", (max_size >> 10)); + storeAppendPrintf(&entry, " %" PRIu64, (max_size >> 10)); dumpOptions(&entry); } diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 0344368cad..b232261ca0 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -311,8 +311,8 @@ 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", max_size); - storeAppendPrintf(&sentry, "Current Size: %"PRIu64" KB\n", cur_size); + storeAppendPrintf(&sentry, "Maximum Size: %" PRIu64 " KB\n", max_size); + storeAppendPrintf(&sentry, "Current Size: %" PRIu64 " KB\n", cur_size); storeAppendPrintf(&sentry, "Percent Used: %0.2f%%\n", (double)(100.0 * cur_size) / (double)max_size); storeAppendPrintf(&sentry, "Filemap bits in use: %d of %d (%d%%)\n", @@ -1324,7 +1324,7 @@ UFSSwapDir::replacementRemove(StoreEntry * e) void UFSSwapDir::dump(StoreEntry & entry) const { - storeAppendPrintf(&entry, " %"PRIu64" %d %d", + storeAppendPrintf(&entry, " %" PRIu64 " %d %d", (max_size >> 10), l1, l2); diff --git a/src/ftp.cc b/src/ftp.cc index 5d4f5cd9a4..c98765ddee 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1152,7 +1152,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; } @@ -3259,7 +3259,7 @@ ftpSendRest(FtpStateData * ftpState) debugs(9, 3, HERE); - snprintf(cbuf, 1024, "REST %"PRId64"\r\n", ftpState->restart_offset); + snprintf(cbuf, 1024, "REST %" PRId64 "\r\n", ftpState->restart_offset); ftpState->writeCommand(cbuf); ftpState->state = SENT_REST; } diff --git a/src/stat.cc b/src/stat.cc index a68b883137..b6aec40b3e 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1619,7 +1619,7 @@ statClientRequests(StoreEntry * s) if (conn != NULL) { fd = conn->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 2057112620..cd036322ec 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -841,7 +841,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 170ba76f3e..925efbcf80 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -360,11 +360,11 @@ 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()); storeAppendPrintf(&output, "Current Store Swap Size: %8lu KB\n", store_swap_size); - storeAppendPrintf(&output, "Current Capacity : %"PRId64"%% used, %"PRId64"%% free\n", + storeAppendPrintf(&output, "Current Capacity : %" PRId64 "%% used, %" PRId64 "%% free\n", Math::int64Percent(store_swap_size, maxSize()), Math::int64Percent((maxSize() - store_swap_size), maxSize())); /* FIXME Here we should output memory statistics */ diff --git a/src/store_log.cc b/src/store_log.cc index 3656f539c6..3a1927b8da 100644 --- a/src/store_log.cc +++ b/src/store_log.cc @@ -83,7 +83,7 @@ storeLog(int tag, const StoreEntry * e) String ctype=(reply->content_type.size() ? reply->content_type.termedBuf() : str_unknown); - 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 6feae60403..98cb14cdb0 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -174,7 +174,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);