From: Francesco Chemolli Date: Sat, 28 Mar 2020 14:09:19 +0000 (+0000) Subject: Fix clang-6.0 build on FreeBSD 12 [-Wformat] (#577) X-Git-Tag: SQUID_5_0_2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcfd5a732c468da12498c2a229feba6bef0c3ea7;p=thirdparty%2Fsquid.git Fix clang-6.0 build on FreeBSD 12 [-Wformat] (#577) Cast and print std::chrono:nanoseconds::count() as intmax_t because its actual type might be larger than the 64 bytes expected by %PRId64. The problem was not, technically, specific to clang or FreeBSD. The error message says "long" because %PRId64 is %ld on platforms where "long" is 64 bits: format specifies type 'long' but the argument has type [...] 'long long' [-Wformat] --- diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 7a410f9648..f694fe3d47 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -3074,7 +3074,8 @@ free_time_msec(time_msec_t * var) static void dump_time_nanoseconds(StoreEntry *entry, const char *name, const std::chrono::nanoseconds &var) { - storeAppendPrintf(entry, "%s %" PRId64 " nanoseconds\n", name, var.count()); + // std::chrono::nanoseconds::rep is unknown a priori so we cast to (and print) the largest supported integer + storeAppendPrintf(entry, "%s %jd nanoseconds\n", name, static_cast(var.count())); } static void