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: 4.15-20210522-snapshot~148 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eba422fc4bac2ca3a4232d78ca039cbf680aec4b;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 7a02b8cb83..6d168721c0 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -3072,7 +3072,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