diff --git a/hphp/compiler/statement/break_statement.cpp b/hphp/compiler/statement/break_statement.cpp index 0c0fc9204..b46ad86a5 100644 --- a/hphp/compiler/statement/break_statement.cpp +++ b/hphp/compiler/statement/break_statement.cpp @@ -80,7 +80,7 @@ void BreakStatement::inferTypes(AnalysisResultPtr ar) { void BreakStatement::outputPHP(CodeGenerator &cg, AnalysisResultPtr ar) { if (m_depth != 1) { - cg_printf("%s %lu;\n", m_name, m_depth); + cg_printf("%s %" PRIu64 ";\n", m_name, m_depth); } else { cg_printf("%s;\n", m_name); } diff --git a/hphp/runtime/base/server/admin_request_handler.cpp b/hphp/runtime/base/server/admin_request_handler.cpp index 9bb07fcc8..5d5078cc2 100644 --- a/hphp/runtime/base/server/admin_request_handler.cpp +++ b/hphp/runtime/base/server/admin_request_handler.cpp @@ -980,7 +980,7 @@ bool AdminRequestHandler::handleVMRequest(const std::string &cmd, int64_t start = Timer::GetCurrentTimeMicros(); if (Transl::Translator::Get()->replace()) { string msg; - Util::string_printf(msg, "Done %ld ms", + Util::string_printf(msg, "Done %" PRId64 " ms", (Timer::GetCurrentTimeMicros() - start) / 1000); transport->sendString(msg); } else { diff --git a/hphp/runtime/base/stats.cpp b/hphp/runtime/base/stats.cpp index b6c9a64a0..7e721d8f5 100644 --- a/hphp/runtime/base/stats.cpp +++ b/hphp/runtime/base/stats.cpp @@ -86,7 +86,7 @@ static __thread int64_t epoch; void dump() { if (!enabledAny()) return; auto url = g_context->getRequestUrl(50); - TRACE(0, "STATS %ld %s\n", epoch, url.c_str()); + TRACE(0, "STATS %" PRId64 " %s\n", epoch, url.c_str()); #include "hphp/runtime/vm/stats-opcodeDef.h" #define STAT(s) \ if (!tl_counters[s]) {} else \ @@ -96,7 +96,7 @@ void dump() { #undef O for (int i=0; helperNames[i]; i++) { if (tl_helper_counters[i]) { - TRACE(0, "STAT %-50s %15ld\n", + TRACE(0, "STAT %-50s %15" PRIu64 "\n", helperNames[i], tl_helper_counters[i]); } diff --git a/hphp/runtime/ext/ext_hotprofiler.cpp b/hphp/runtime/ext/ext_hotprofiler.cpp index 691dd3ccf..85a477d6b 100644 --- a/hphp/runtime/ext/ext_hotprofiler.cpp +++ b/hphp/runtime/ext/ext_hotprofiler.cpp @@ -1450,8 +1450,9 @@ private: */ void sample_stack() { char key[512]; - snprintf(key, sizeof(key), "%ld.%06ld", - m_last_sample_time.tv_sec, m_last_sample_time.tv_usec); + snprintf(key, sizeof(key), "%" PRId64 ".%06" PRId64, + (int64_t)m_last_sample_time.tv_sec, + (int64_t)m_last_sample_time.tv_usec); char symbol[5120]; m_stack->getStack(INT_MAX, symbol, sizeof(symbol)); diff --git a/hphp/runtime/ext/ext_simplexml.cpp b/hphp/runtime/ext/ext_simplexml.cpp index 303648589..f3353bc19 100644 --- a/hphp/runtime/ext/ext_simplexml.cpp +++ b/hphp/runtime/ext/ext_simplexml.cpp @@ -846,7 +846,7 @@ Variant c_SimpleXMLElement::t___set(Variant name, Variant value) { } else if (m_is_attribute) { if (name.isInteger()) { raise_warning("Cannot change attribute number %" PRId64 - " when only %" PRId64 " attributes exist", name.toInt64(), + " when only %zd attributes exist", name.toInt64(), m_attributes.toArray().size()); } else { newnode = (xmlNodePtr)xmlNewProp(m_node, (xmlChar *)sname.data(), sv); diff --git a/hphp/runtime/vm/bytecode.cpp b/hphp/runtime/vm/bytecode.cpp index c4eb56784..bf5a58315 100644 --- a/hphp/runtime/vm/bytecode.cpp +++ b/hphp/runtime/vm/bytecode.cpp @@ -2739,7 +2739,7 @@ void VMExecutionContext::preventReturnsToTC() { while (ar) { if (!isReturnHelper(ar->m_savedRip) && (tx()->isValidCodeAddress((Transl::TCA)ar->m_savedRip))) { - TRACE_RB(2, "Replace RIP in fp %p, savedRip 0x%lx, " + TRACE_RB(2, "Replace RIP in fp %p, savedRip 0x%" PRIx64 ", " "func %s\n", ar, ar->m_savedRip, ar->m_func->fullName()->data()); if (ar->m_func->isGenerator()) { diff --git a/hphp/runtime/vm/class.cpp b/hphp/runtime/vm/class.cpp index 1b9bd3ca4..5e54e6bcf 100644 --- a/hphp/runtime/vm/class.cpp +++ b/hphp/runtime/vm/class.cpp @@ -644,19 +644,21 @@ void Class::initInstanceBits() { // Print out stats about what we ended up using if (Trace::moduleEnabledRelease(Trace::instancebits, 1)) { - Trace::traceRelease("%s: %u classes, %u (%.2f%%) of warmup checks\n", + Trace::traceRelease("%s: %u classes, %" PRIu64 " (%.2f%%) of warmup" + " checks\n", __FUNCTION__, i-1, accum, 100.0 * accum / total); if (Trace::moduleEnabledRelease(Trace::instancebits, 2)) { accum = 0; i = 1; for (auto& pair : counts) { if (i >= 256) { - Trace::traceRelease("skipping the remainder of the %llu classes\n", + Trace::traceRelease("skipping the remainder of the %" PRIu64 + " classes\n", counts.size()); break; } accum += pair.second; - Trace::traceRelease("%3u %5.2f%% %7u -- %6.2f%% %7u %s\n", + Trace::traceRelease("%3u %5.2f%% %7u -- %6.2f%% %7" PRIu64 " %s\n", i++, 100.0 * pair.second / total, pair.second, 100.0 * accum / total, accum, pair.first->data()); diff --git a/hphp/runtime/vm/jit/translator-x64.cpp b/hphp/runtime/vm/jit/translator-x64.cpp index 0f69f698a..66af81e9e 100644 --- a/hphp/runtime/vm/jit/translator-x64.cpp +++ b/hphp/runtime/vm/jit/translator-x64.cpp @@ -2896,8 +2896,8 @@ newInstanceHelper(Class* cls, int numArgs, ActRec* ar, ActRec* prevAr) { ar->setThis(ret); ar->setVarEnv(nullptr); arSetSfp(ar, prevAr); - TRACE(2, "newInstanceHelper: AR %p: f %p, savedRbp %#lx, savedRip %#lx" - " this %p\n", + TRACE(2, "newInstanceHelper: AR %p: f %p, savedRbp %#" PRIx64 + ", savedRip %#" PRIx64 ", this %p\n", ar, ar->m_func, ar->m_savedRbp, ar->m_savedRip, ar->m_this); return ret; } @@ -3287,7 +3287,7 @@ TranslatorX64::translateWork(const TranslArgs& args) { srcRec.newTranslation(start); TRACE(1, "tx64: %zd-byte tracelet\n", a.code.frontier - start); if (Trace::moduleEnabledRelease(Trace::tcspace, 1)) { - Trace::traceRelease(getUsage().c_str()); + Trace::traceRelease("%s", getUsage().c_str()); } } @@ -3698,7 +3698,7 @@ TranslatorX64::requestExit() { Trace::traceRelease("TranslatorX64 perf counters for %s:\n", g_context->getRequestUrl(50).c_str()); for (int i = 0; i < tpc_num_counters; i++) { - Trace::traceRelease("%-20s %10lld\n", + Trace::traceRelease("%-20s %10" PRId64 "\n", kPerfCounterNames[i], s_perfCounters[i]); } Trace::traceRelease("\n"); diff --git a/hphp/runtime/vm/jit/translator-x64.h b/hphp/runtime/vm/jit/translator-x64.h index e3f486c55..2688d1504 100644 --- a/hphp/runtime/vm/jit/translator-x64.h +++ b/hphp/runtime/vm/jit/translator-x64.h @@ -635,7 +635,9 @@ struct SpaceRecorder { ~SpaceRecorder() { if (Trace::moduleEnabledRelease(Trace::tcspace, 1)) { ptrdiff_t diff = m_a.code.frontier - m_start; - if (diff) Trace::traceRelease("TCSpace %10s %3d\n", m_name, diff); + if (diff) { + Trace::traceRelease("TCSpace %10s %3" PRId64 "\n", m_name, diff); + } } } }; diff --git a/hphp/runtime/vm/jit/translator.cpp b/hphp/runtime/vm/jit/translator.cpp index 856f17305..4263d3d0e 100644 --- a/hphp/runtime/vm/jit/translator.cpp +++ b/hphp/runtime/vm/jit/translator.cpp @@ -3958,7 +3958,7 @@ uint64_t* Translator::getTransCounterAddr() { uint32_t Translator::addTranslation(const TransRec& transRec) { if (Trace::moduleEnabledRelease(Trace::trans, 1)) { // Log the translation's size, creation time, SrcKey, and size - Trace::traceRelease("New translation: %lld %s %u %u %d\n", + Trace::traceRelease("New translation: %" PRId64 " %s %u %u %d\n", Timer::GetCurrentTimeMicros() - m_createdTime, folly::format("{}:{}:{}", curUnit()->filepath()->data(), diff --git a/hphp/runtime/vm/jit/writelease.cpp b/hphp/runtime/vm/jit/writelease.cpp index 7888718fe..d0dbd3c07 100644 --- a/hphp/runtime/vm/jit/writelease.cpp +++ b/hphp/runtime/vm/jit/writelease.cpp @@ -76,14 +76,16 @@ bool Lease::acquire(bool blocking /* = false */ ) { if (0 == (blocking ? pthread_mutex_lock(&m_lock) : pthread_mutex_trylock(&m_lock))) { - TRACE(4, "thr%lx: acquired lease, called by %p,%p\n", + TRACE(4, "thr%" PRIx64 ": acquired lease, called by %p,%p\n", pthread_self(), __builtin_return_address(0), __builtin_return_address(1)); if (debug) { pushRank(RankWriteLease); if (expire != 0 && m_owner != pthread_self()) { m_hintGrabbed++; - TRACE(3, "thr%lx acquired hinted lease: expired %" PRId64 "us ago\n", + TRACE(3, + "thr%" PRIx64 ": acquired hinted lease" + ", expired %" PRId64 "us ago\n", pthread_self(), -expireDiff); } else if (expire != 0 && m_owner == pthread_self()) { m_hintKept++; @@ -97,7 +99,7 @@ bool Lease::acquire(bool blocking /* = false */ ) { return true; } if (blocking) { - TRACE(3, "thr%lx: failed to acquired lease in blocking mode\n", + TRACE(3, "thr%" PRIx64 ": failed to acquired lease in blocking mode\n", pthread_self()); } return false; @@ -105,7 +107,7 @@ bool Lease::acquire(bool blocking /* = false */ ) { void Lease::drop(int64_t hintExpireDelay) { assert(amOwner()); - TRACE(4, "thr%lx: dropping lease, called by %p,%p\n", + TRACE(4, "thr%" PRIx64 ": dropping lease, called by %p,%p\n", pthread_self(), __builtin_return_address(0), __builtin_return_address(1)); if (debug) { diff --git a/hphp/runtime/vm/unit.cpp b/hphp/runtime/vm/unit.cpp index 88bece7eb..654538af3 100644 --- a/hphp/runtime/vm/unit.cpp +++ b/hphp/runtime/vm/unit.cpp @@ -2680,7 +2680,7 @@ Unit* UnitEmitter::create() { if (RuntimeOption::EvalDumpBytecode) { // Dump human-readable bytecode. - Trace::traceRelease(u->toString()); + Trace::traceRelease("%s", u->toString().c_str()); } static const bool kVerify = getenv("HHVM_VERIFY"); diff --git a/hphp/util/asm-x64.h b/hphp/util/asm-x64.h index e2c083d70..90a39c148 100644 --- a/hphp/util/asm-x64.h +++ b/hphp/util/asm-x64.h @@ -578,7 +578,7 @@ struct DataBlock { } void qword(const uint64_t qword) { assert(canEmit(sz::qword)); - TRACE(10, "%p q : %016lx\n", frontier, qword); + TRACE(10, "%p q : %016" PRIx64 "\n", frontier, qword); *(uint64_t*)frontier = qword; frontier += sz::qword; } diff --git a/hphp/util/rank.cpp b/hphp/util/rank.cpp index e3f478a7f..7bc370841 100644 --- a/hphp/util/rank.cpp +++ b/hphp/util/rank.cpp @@ -42,10 +42,11 @@ void checkRank(Rank r) { */ if (prev >= r && r != RankUnranked) { if (r == RankLeaf) { - fprintf(stderr, "Rank violation in thr%lx! leaf lock from leaf rank; ", + fprintf(stderr, + "Rank violation in thr%" PRIx64 "! leaf lock from leaf rank; ", pthread_self()); } else { - fprintf(stderr, "Rank violation in thr%lx! lock of rank %d; ", + fprintf(stderr, "Rank violation in thr%" PRIx64 "! lock of rank %d; ", pthread_self(), r); } fprintf(stderr, "held locks:\n"); diff --git a/hphp/util/ringbuffer.cpp b/hphp/util/ringbuffer.cpp index fe5e035c5..5dc2cfa12 100644 --- a/hphp/util/ringbuffer.cpp +++ b/hphp/util/ringbuffer.cpp @@ -175,7 +175,7 @@ void dumpEntry(const RingBufferEntry* e) { break; } default: { - printf("%#x %10u %#lx %d %20s\n", + printf("%#x %10u %#" PRIx64 " %d %20s\n", e->m_threadId, e->m_seq, e->m_funcId, e->m_offset, names[e->m_type]); break; diff --git a/hphp/util/trace.h b/hphp/util/trace.h index 3b4a3da5e..3b806b99a 100644 --- a/hphp/util/trace.h +++ b/hphp/util/trace.h @@ -165,7 +165,8 @@ std::string prettyNode(const char* name, const P1& p1, const P2& p2) { string(")"); } -void traceRelease(const char*, ...); +void traceRelease(const char*, ...) + __attribute__((format(printf,1,2))); void traceRelease(const std::string& s); // Trace to the global ring buffer in all builds, and also trace normally @@ -173,7 +174,8 @@ void traceRelease(const std::string& s); #define TRACE_RB(n, ...) \ HPHP::Trace::traceRingBufferRelease(__VA_ARGS__); \ TRACE(n, __VA_ARGS__); -void traceRingBufferRelease(const char* fmt, ...); +void traceRingBufferRelease(const char* fmt, ...) + __attribute__((format(printf,1,2))); extern int levels[NumModules]; const char* moduleName(Module mod);