Bug 1060419 - make AppendPrintf and nsPrintfCString use Printf.h, r=froydnj

MozReview-Commit-ID: 2E8FoiNxU8L

--HG--
extra : rebase_source : 810ac727bef0751f24edea18c52e0ec170bf367d
This commit is contained in:
Tom Tromey 2016-12-14 09:32:21 -07:00
Родитель 38a0f29d29
Коммит d2667a2b27
55 изменённых файлов: 189 добавлений и 151 удалений

Просмотреть файл

@ -360,7 +360,7 @@ Exception::ToString(JSContext* aCx, nsACString& _retval)
static const char defaultMsg[] = "<no message>";
static const char defaultLocation[] = "<unknown>";
static const char format[] =
"[Exception... \"%s\" nsresult: \"0x%x (%s)\" location: \"%s\" data: %s]";
"[Exception... \"%s\" nsresult: \"0x%" PRIx32 " (%s)\" location: \"%s\" data: %s]";
nsCString location;
@ -388,7 +388,7 @@ Exception::ToString(JSContext* aCx, nsACString& _retval)
const char* data = mData ? "yes" : "no";
_retval.Truncate();
_retval.AppendPrintf(format, msg, mResult, resultName,
_retval.AppendPrintf(format, msg, static_cast<uint32_t>(mResult), resultName,
location.get(), data);
return NS_OK;
}
@ -552,7 +552,7 @@ DOMException::ToString(JSContext* aCx, nsACString& aReturn)
static const char defaultLocation[] = "<unknown>";
static const char defaultName[] = "<unknown>";
static const char format[] =
"[Exception... \"%s\" code: \"%d\" nsresult: \"0x%x (%s)\" location: \"%s\"]";
"[Exception... \"%s\" code: \"%d\" nsresult: \"0x%" PRIx32 " (%s)\" location: \"%s\"]";
nsAutoCString location;
@ -563,7 +563,7 @@ DOMException::ToString(JSContext* aCx, nsACString& aReturn)
const char* msg = !mMessage.IsEmpty() ? mMessage.get() : defaultMsg;
const char* resultName = !mName.IsEmpty() ? mName.get() : defaultName;
aReturn.AppendPrintf(format, msg, mCode, mResult, resultName,
aReturn.AppendPrintf(format, msg, mCode, static_cast<uint32_t>(mResult), resultName,
location.get());
return NS_OK;

Просмотреть файл

@ -168,7 +168,7 @@ AppendWindowURI(nsGlobalWindow *aWindow, nsACString& aStr, bool aAnonymize)
if (uri) {
if (aAnonymize && !aWindow->IsChromeWindow()) {
aStr.AppendPrintf("<anonymized-%llu>", aWindow->WindowID());
aStr.AppendPrintf("<anonymized-%" PRIu64 ">", aWindow->WindowID());
} else {
nsCString spec = uri->GetSpecOrDefault();
@ -276,7 +276,7 @@ CollectWindowReports(nsGlobalWindow *aWindow,
if (top) {
windowPath += NS_LITERAL_CSTRING("top(");
AppendWindowURI(top, windowPath, aAnonymize);
windowPath.AppendPrintf(", id=%llu)", top->WindowID());
windowPath.AppendPrintf(", id=%" PRIu64 ")", top->WindowID());
aTopWindowPaths->Put(aWindow->WindowID(), windowPath);

Просмотреть файл

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MemoryBlobImpl.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/SHA1.h"
#include "nsIIPCSerializableInputStream.h"
#include "nsPrintfCString.h"
@ -166,11 +167,11 @@ public:
aHandleReport->Callback(
/* process */ NS_LITERAL_CSTRING(""),
nsPrintfCString(
"explicit/dom/memory-file-data/large/file(length=%llu, sha1=%s)",
"explicit/dom/memory-file-data/large/file(length=%" PRIu64 ", sha1=%s)",
owner->mLength, aAnonymize ? "<anonymized>" : digestString.get()),
KIND_HEAP, UNITS_BYTES, size,
nsPrintfCString(
"Memory used to back a memory file of length %llu bytes. The file "
"Memory used to back a memory file of length %" PRIu64 " bytes. The file "
"has a sha1 of %s.\n\n"
"Note that the allocator may round up a memory file's length -- "
"that is, an N-byte memory file may take up more than N bytes of "

Просмотреть файл

@ -26,6 +26,7 @@
#include "mozilla/Maybe.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/SizePrintfMacros.h"
#include "mozilla/SnappyCompressOutputStream.h"
#include "mozilla/SnappyUncompressInputStream.h"
#include "mozilla/StaticPtr.h"
@ -583,9 +584,9 @@ ClampResultCode(nsresult aResultCode)
return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR;
default:
#ifdef DEBUG
nsPrintfCString message("Converting non-IndexedDB error code (0x%X) to "
nsPrintfCString message("Converting non-IndexedDB error code (0x%" PRIX32 ") to "
"NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR",
aResultCode);
static_cast<uint32_t>(aResultCode));
NS_WARNING(message.get());
#else
;
@ -4557,7 +4558,7 @@ CreateStorageConnection(nsIFile* aDBFile,
// Set the page size first.
if (kSQLitePageSizeOverride) {
rv = connection->ExecuteSimpleSQL(
nsPrintfCString("PRAGMA page_size = %lu;", kSQLitePageSizeOverride)
nsPrintfCString("PRAGMA page_size = %" PRIu32 ";", kSQLitePageSizeOverride)
);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -4793,7 +4794,7 @@ CreateStorageConnection(nsIFile* aDBFile,
// Successfully set to rollback journal mode so changing the page size
// is possible with a VACUUM.
rv = connection->ExecuteSimpleSQL(
nsPrintfCString("PRAGMA page_size = %lu;", kSQLitePageSizeOverride)
nsPrintfCString("PRAGMA page_size = %" PRIu32 ";", kSQLitePageSizeOverride)
);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -5724,7 +5725,7 @@ public:
nsCString GetThreadName() const
{
return nsPrintfCString("IndexedDB #%lu", mSerialNumber);
return nsPrintfCString("IndexedDB #%" PRIu32, mSerialNumber);
}
private:

Просмотреть файл

@ -277,7 +277,7 @@ public:
}
};
inline void
inline void MOZ_FORMAT_PRINTF(2, 3)
LoggingHelper(bool aUseProfiler, const char* aFmt, ...)
{
MOZ_ASSERT(IndexedDatabaseManager::GetLoggingMode() !=

Просмотреть файл

@ -27,7 +27,7 @@ ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr)
nsContentUtils::LogSimpleConsoleError(
NS_ConvertUTF8toUTF16(nsPrintfCString(
"IndexedDB %s: %s:%lu", aStr, aFile, aLine)),
"IndexedDB %s: %s:%" PRIu32, aStr, aFile, aLine)),
"indexedDB");
}

Просмотреть файл

@ -419,7 +419,7 @@ ContentParentsMemoryReporter::CollectReports(
}
nsPrintfCString path("queued-ipc-messages/content-parent"
"(%s, pid=%d, %s, 0x%p, refcnt=%d)",
"(%s, pid=%d, %s, 0x%p, refcnt=%" PRIuPTR ")",
NS_ConvertUTF16toUTF8(friendlyName).get(),
cp->Pid(), channelStr,
static_cast<nsIContentParent*>(cp), refcnt);

Просмотреть файл

@ -534,7 +534,7 @@ ProcessPriorityManagerImpl::GetParticularProcessPriorityManager(
mParticularManagers.Put(cpId, pppm);
FireTestOnlyObserverNotification("process-created",
nsPrintfCString("%lld", cpId));
nsPrintfCString("%" PRIu64, cpId));
}
return pppm.forget();
@ -1195,7 +1195,7 @@ ParticularProcessPriorityManager::FireTestOnlyObserverNotification(
return;
}
nsAutoCString data(nsPrintfCString("%lld", ChildID()));
nsAutoCString data(nsPrintfCString("%" PRIu64, ChildID()));
if (!aData.IsEmpty()) {
data.Append(':');
data.Append(aData);

Просмотреть файл

@ -834,8 +834,8 @@ DecoderDoctorDiagnostics::GetDescription() const
}
break;
case eEvent:
s = nsPrintfCString("event domain %s result=%u",
EventDomainString(mEvent.mDomain), mEvent.mResult);
s = nsPrintfCString("event domain %s result=%" PRIu32,
EventDomainString(mEvent.mDomain), static_cast<uint32_t>(mEvent.mResult));
break;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected DiagnosticsType");

Просмотреть файл

@ -225,7 +225,8 @@ MediaDecoderReader::AsyncReadMetadata()
// We're not waiting for anything. If we didn't get the metadata, that's an
// error.
if (NS_FAILED(rv) || !metadata->mInfo.HasValidMedia()) {
DECODER_WARN("ReadMetadata failed, rv=%x HasValidMedia=%d", rv, metadata->mInfo.HasValidMedia());
DECODER_WARN("ReadMetadata failed, rv=%" PRIx32 " HasValidMedia=%d",
static_cast<uint32_t>(rv), metadata->mInfo.HasValidMedia());
return MetadataPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
}

Просмотреть файл

@ -3756,10 +3756,10 @@ MediaDecoderStateMachine::GetDebugInfo()
{
MOZ_ASSERT(OnTaskQueue());
return nsPrintfCString(
"GetMediaTime=%lld GetClock=%lld mMediaSink=%p "
"GetMediaTime=%" PRId64 " GetClock=%" PRId64 " mMediaSink=%p "
"state=%s mPlayState=%d mSentFirstFrameLoadedEvent=%d IsPlaying=%d "
"mAudioStatus=%s mVideoStatus=%s mDecodedAudioEndTime=%lld "
"mDecodedVideoEndTime=%lld "
"mAudioStatus=%s mVideoStatus=%s mDecodedAudioEndTime=%" PRId64
" mDecodedVideoEndTime=%" PRId64
" mAudioCompleted=%d mVideoCompleted=%d ",
GetMediaTime(), mMediaSink->IsStarted() ? GetClock() : -1,
mMediaSink.get(), ToStateStr(), mPlayState.Ref(),

Просмотреть файл

@ -2786,12 +2786,12 @@ MediaFormatReader::GetMozDebugReaderData(nsACString& aString)
}
result += nsPrintfCString("audio decoder: %s\n", audioName);
result += nsPrintfCString("audio frames decoded: %lld\n",
result += nsPrintfCString("audio frames decoded: %" PRIu64 "\n",
mAudio.mNumSamplesOutputTotal);
if (HasAudio()) {
result += nsPrintfCString(
"audio state: ni=%d no=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%llu "
"out:%llu qs=%u pending:%u waiting:%d sid:%u\n",
"audio state: ni=%d no=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%" PRIu64
" out:%" PRIu64 " qs=%u pending:%u waiting:%d sid:%u\n",
NeedInput(mAudio), mAudio.HasPromise(), mAudio.mDemuxRequest.Exists(),
int(mAudio.mQueuedSamples.Length()),
mAudio.mTimeThreshold ? mAudio.mTimeThreshold.ref().Time().ToSeconds()
@ -2805,13 +2805,13 @@ MediaFormatReader::GetMozDebugReaderData(nsACString& aString)
result +=
nsPrintfCString("hardware video decoding: %s\n",
VideoIsHardwareAccelerated() ? "enabled" : "disabled");
result += nsPrintfCString("video frames decoded: %lld (skipped:%lld)\n",
result += nsPrintfCString("video frames decoded: %" PRIu64 " (skipped:%" PRIu64 ")\n",
mVideo.mNumSamplesOutputTotal,
mVideo.mNumSamplesSkippedTotal);
if (HasVideo()) {
result += nsPrintfCString(
"video state: ni=%d no=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%llu "
"out:%llu qs=%u pending:%u waiting:%d sid:%u\n",
"video state: ni=%d no=%d demuxr:%d demuxq:%d tt:%f tths:%d in:%" PRIu64
" out:%" PRIu64 " qs=%u pending:%u waiting:%d sid:%u\n",
NeedInput(mVideo), mVideo.HasPromise(), mVideo.mDemuxRequest.Exists(),
int(mVideo.mQueuedSamples.Length()),
mVideo.mTimeThreshold ? mVideo.mTimeThreshold.ref().Time().ToSeconds()

Просмотреть файл

@ -51,7 +51,7 @@ public:
if (NS_SUCCEEDED(mCode)) {
return nsCString();
}
return nsPrintfCString("0x%08x: %s", mCode, mMessage.get());
return nsPrintfCString("0x%08" PRIx32 ": %s", static_cast<uint32_t>(mCode), mMessage.get());
}
private:

Просмотреть файл

@ -42,8 +42,8 @@ DetailedPromise::~DetailedPromise()
void
DetailedPromise::MaybeReject(nsresult aArg, const nsACString& aReason)
{
nsPrintfCString msg("%s promise rejected 0x%x '%s'", mName.get(), aArg,
PromiseFlatCString(aReason).get());
nsPrintfCString msg("%s promise rejected 0x%" PRIx32 " '%s'", mName.get(),
static_cast<uint32_t>(aArg), PromiseFlatCString(aReason).get());
EME_LOG("%s", msg.get());
MaybeReportTelemetry(Failed);

Просмотреть файл

@ -341,7 +341,8 @@ MP4TrackDemuxer::GetNextSample()
bool keyframe = type == mp4_demuxer::H264::FrameType::I_FRAME;
if (sample->mKeyframe != keyframe) {
NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe "
"@ pts:%lld dur:%u dts:%lld",
"@ pts:%" PRId64 " dur:%" PRId64
" dts:%" PRId64,
keyframe ? "" : "non-", sample->mTime,
sample->mDuration, sample->mTimecode)
.get());
@ -351,7 +352,8 @@ MP4TrackDemuxer::GetNextSample()
}
case mp4_demuxer::H264::FrameType::INVALID:
NS_WARNING(
nsPrintfCString("Invalid H264 frame @ pts:%lld dur:%u dts:%lld",
nsPrintfCString("Invalid H264 frame @ pts:%" PRId64 " dur:%" PRId64
" dts:%" PRId64,
sample->mTime, sample->mDuration, sample->mTimecode)
.get());
// We could reject the sample now, however demuxer errors are fatal.

Просмотреть файл

@ -230,8 +230,8 @@ nsCString
DecodedStreamData::GetDebugInfo()
{
return nsPrintfCString(
"DecodedStreamData=%p mPlaying=%d mAudioFramesWritten=%lld "
"mNextAudioTime=%lld mNextVideoTime=%lld mHaveSentFinish=%d "
"DecodedStreamData=%p mPlaying=%d mAudioFramesWritten=%" PRId64
" mNextAudioTime=%" PRId64 " mNextVideoTime=%" PRId64 " mHaveSentFinish=%d "
"mHaveSentFinishAudio=%d mHaveSentFinishVideo=%d",
this, mPlaying, mAudioFramesWritten, mNextAudioTime, mNextVideoTime,
mHaveSentFinish, mHaveSentFinishAudio, mHaveSentFinishVideo);
@ -781,7 +781,7 @@ DecodedStream::GetDebugInfo()
{
AssertOwnerThread();
return nsPrintfCString(
"DecodedStream=%p mStartTime=%lld mLastOutputTime=%lld mPlaying=%d mData=%p",
"DecodedStream=%p mStartTime=%" PRId64 " mLastOutputTime=%" PRId64 " mPlaying=%d mData=%p",
this, mStartTime.valueOr(-1), mLastOutputTime, mPlaying, mData.get())
+ (mData ? nsCString("\n") + mData->GetDebugInfo() : nsCString());
}

Просмотреть файл

@ -479,8 +479,8 @@ VideoSink::GetDebugInfo()
{
AssertOwnerThread();
return nsPrintfCString(
"IsStarted=%d IsPlaying=%d, VideoQueue: finished=%d size=%d, "
"mVideoFrameEndTime=%lld mHasVideo=%d mVideoSinkEndRequest.Exists()=%d "
"IsStarted=%d IsPlaying=%d, VideoQueue: finished=%d size=%" PRIuSIZE ", "
"mVideoFrameEndTime=%" PRId64 " mHasVideo=%d mVideoSinkEndRequest.Exists()=%d "
"mEndPromiseHolder.IsEmpty()=%d\n",
IsStarted(), IsPlaying(), VideoQueue().IsFinished(), VideoQueue().GetSize(),
mVideoFrameEndTime, mHasVideo, mVideoSinkEndRequest.Exists(), mEndPromiseHolder.IsEmpty())

Просмотреть файл

@ -254,7 +254,7 @@ MediaSourceDemuxer::GetMozDebugReaderData(nsACString& aString)
result += nsPrintfCString("Dumping data for demuxer %p:\n", this);
if (mAudioTrack) {
result += nsPrintfCString("\tDumping Audio Track Buffer(%s): - mLastAudioTime: %f\n"
"\t\tNumSamples:%u Size:%u Evictable:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n",
"\t\tNumSamples:%" PRIuSIZE " Size:%u Evictable:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n",
mAudioTrack->mAudioTracks.mInfo->mMimeType.get(),
mAudioTrack->mAudioTracks.mNextSampleTime.ToSeconds(),
mAudioTrack->mAudioTracks.mBuffers[0].Length(),
@ -268,7 +268,7 @@ MediaSourceDemuxer::GetMozDebugReaderData(nsACString& aString)
}
if (mVideoTrack) {
result += nsPrintfCString("\tDumping Video Track Buffer(%s) - mLastVideoTime: %f\n"
"\t\tNumSamples:%u Size:%u Evictable:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n",
"\t\tNumSamples:%" PRIuSIZE " Size:%u Evictable:%u NextGetSampleIndex:%u NextInsertionIndex:%d\n",
mVideoTrack->mVideoTracks.mInfo->mMimeType.get(),
mVideoTrack->mVideoTracks.mNextSampleTime.ToSeconds(),
mVideoTrack->mVideoTracks.mBuffers[0].Length(),

Просмотреть файл

@ -269,7 +269,7 @@ AppleATDecoder::DecodeSample(MediaRawData* aSample)
LOG("Error decoding audio sample: %d\n", static_cast<int>(rv));
return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
RESULT_DETAIL("Error decoding audio sample: %d @ %lld",
rv, aSample->mTime));
static_cast<int>(rv), aSample->mTime));
}
if (numFrames) {

Просмотреть файл

@ -1157,7 +1157,7 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
uint32_t major, minor;
if (NS_SUCCEEDED(httpChannelInternal->GetResponseVersion(&major,
&minor))) {
ver = nsPrintfCString("/%lu.%lu", major, minor);
ver = nsPrintfCString("/%" PRIu32 ".%" PRIu32, major, minor);
}
}
@ -1168,7 +1168,7 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
}
// Assemble everything and pass to listener.
nsPrintfCString status("HTTP%s %lu %s", ver.get(), statusNum,
nsPrintfCString status("HTTP%s %" PRIu32 " %s", ver.get(), statusNum,
statusText.get());
static_cast<nsIHTTPHeaderListener*>(mPStreamListener)->StatusLine(status.get());
}

Просмотреть файл

@ -1285,7 +1285,7 @@ ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr)
nsContentUtils::LogSimpleConsoleError(
NS_ConvertUTF8toUTF16(nsPrintfCString(
"Quota %s: %s:%lu", aStr, aFile, aLine)),
"Quota %s: %s:%" PRIu32, aStr, aFile, aLine)),
"quota");
}
@ -4334,7 +4334,7 @@ QuotaManager::EnsureStorageIsInitialized()
// Set the page size first.
if (kSQLitePageSizeOverride) {
rv = connection->ExecuteSimpleSQL(
nsPrintfCString("PRAGMA page_size = %lu;", kSQLitePageSizeOverride)
nsPrintfCString("PRAGMA page_size = %" PRIu32 ";", kSQLitePageSizeOverride)
);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;

Просмотреть файл

@ -2182,9 +2182,9 @@ void ReportLoadError(ErrorResult& aRv, nsresult aLoadResult,
// We don't want to throw a JS exception, because for toplevel script
// loads that would get squelched.
aRv.ThrowDOMException(NS_ERROR_DOM_NETWORK_ERR,
nsPrintfCString("Failed to load worker script at %s (nsresult = 0x%x)",
nsPrintfCString("Failed to load worker script at %s (nsresult = 0x%" PRIx32 ")",
NS_ConvertUTF16toUTF8(aScriptURL).get(),
aLoadResult));
static_cast<uint32_t>(aLoadResult)));
return;
}

Просмотреть файл

@ -539,8 +539,8 @@ txXPathNodeUtils::getOwnerDocument(const txXPathNode& aNode)
return new txXPathNode(aNode.mNode->OwnerDoc());
}
const char gPrintfFmt[] = "id0x%p";
const char gPrintfFmtAttr[] = "id0x%p-%010i";
const char gPrintfFmt[] = "id0x%" PRIxPTR;
const char gPrintfFmtAttr[] = "id0x%" PRIxPTR "-%010i";
/* static */
nsresult

Просмотреть файл

@ -639,8 +639,6 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
case DATE_TIME:
{
// http://exslt.org/date/functions/date-time/
// format: YYYY-MM-DDTTHH:MM:SS.sss+00:00
char formatstr[] = "%04hd-%02ld-%02ldT%02ld:%02ld:%02ld.%03ld%c%02ld:%02ld";
PRExplodedTime prtime;
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &prtime);
@ -655,7 +653,10 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext,
rv = aContext->recycler()->getStringResult(&strRes);
NS_ENSURE_SUCCESS(rv, rv);
CopyASCIItoUTF16(nsPrintfCString(formatstr,
// format: YYYY-MM-DDTTHH:MM:SS.sss+00:00
CopyASCIItoUTF16(nsPrintfCString("%04hd-%02" PRId32 "-%02" PRId32
"T%02" PRId32 ":%02" PRId32 ":%02" PRId32
".%03" PRId32 "%c%02" PRId32 ":%02" PRId32,
prtime.tm_year, prtime.tm_month + 1, prtime.tm_mday,
prtime.tm_hour, prtime.tm_min, prtime.tm_sec,
prtime.tm_usec / 10000,

Просмотреть файл

@ -223,7 +223,7 @@ public:
tokenizer.CheckWhite() &&
tokenizer.Check(Tokenizer::TOKEN_INTEGER, intToken)) {
*mFailureId = "FAILURE_ID_ANGLE_ID_";
mFailureId->AppendPrintf("%i", intToken.AsInteger());
mFailureId->AppendPrintf("%" PRIu64, intToken.AsInteger());
} else {
*mFailureId = "FAILURE_ID_ANGLE_UNKNOWN";
}

Просмотреть файл

@ -22,6 +22,7 @@
#include "gfxUtils.h" // for gfxUtils, etc
#include "gfx2DGlue.h"
#include "mozilla/DebugOnly.h" // for DebugOnly
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Telemetry.h" // for Accumulate
#include "mozilla/ToString.h"
#include "mozilla/gfx/2D.h" // for DrawTarget
@ -1872,20 +1873,20 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
aStream << " [scrollbar]";
}
if (GetScrollbarDirection() == ScrollDirection::VERTICAL) {
aStream << nsPrintfCString(" [vscrollbar=%lld]", GetScrollbarTargetContainerId()).get();
aStream << nsPrintfCString(" [vscrollbar=%" PRIu64 "]", GetScrollbarTargetContainerId()).get();
}
if (GetScrollbarDirection() == ScrollDirection::HORIZONTAL) {
aStream << nsPrintfCString(" [hscrollbar=%lld]", GetScrollbarTargetContainerId()).get();
aStream << nsPrintfCString(" [hscrollbar=%" PRIu64 "]", GetScrollbarTargetContainerId()).get();
}
if (GetIsFixedPosition()) {
LayerPoint anchor = GetFixedPositionAnchor();
aStream << nsPrintfCString(" [isFixedPosition scrollId=%lld sides=0x%x anchor=%s]",
aStream << nsPrintfCString(" [isFixedPosition scrollId=%" PRIu64 " sides=0x%x anchor=%s]",
GetFixedPositionScrollContainerId(),
GetFixedPositionSides(),
ToString(anchor).c_str()).get();
}
if (GetIsStickyPosition()) {
aStream << nsPrintfCString(" [isStickyPosition scrollId=%d outer=(%.3f,%.3f)-(%.3f,%.3f) "
aStream << nsPrintfCString(" [isStickyPosition scrollId=%" PRIu64 " outer=(%.3f,%.3f)-(%.3f,%.3f) "
"inner=(%.3f,%.3f)-(%.3f,%.3f)]",
GetStickyScrollContainerId(),
GetStickyScrollRangeOuter().x,

Просмотреть файл

@ -190,10 +190,10 @@ AppendToString(std::stringstream& aStream, const FrameMetrics& m,
AppendToString(aStream, m.GetCumulativeResolution(), " cr=");
AppendToString(aStream, m.GetZoom(), " z=");
AppendToString(aStream, m.GetExtraResolution(), " er=");
aStream << nsPrintfCString(")] [u=(%d %d %lu)",
aStream << nsPrintfCString(")] [u=(%d %d %" PRIu32 ")",
m.GetScrollUpdateType(), m.GetDoSmoothScroll(),
m.GetScrollGeneration()).get();
aStream << nsPrintfCString("] [i=(%ld %lld %d)] }",
aStream << nsPrintfCString("] [i=(%" PRIu32 " %" PRIu64 " %d)] }",
m.GetPresShellId(), m.GetScrollId(), m.IsRootContent()).get();
}
aStream << sfx;

Просмотреть файл

@ -11,6 +11,8 @@
#include <errno.h>
#endif
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/dom/ContentParent.h"
@ -232,7 +234,7 @@ AnnotateSystemError()
if (error) {
CrashReporter::AnnotateCrashReport(
NS_LITERAL_CSTRING("IPCSystemError"),
nsPrintfCString("%lld", error));
nsPrintfCString("%" PRId64, error));
}
}
#endif

Просмотреть файл

@ -120,7 +120,7 @@ class Logging
ptr = nullptr;
}
out = nsPrintfCString("<%s %s:%d:%p>", side, objDesc, id.serialNumber(), ptr);
out = nsPrintfCString("<%s %s:%" PRIu64 ":%p>", side, objDesc, id.serialNumber(), ptr);
}
void format(const ReceiverObj& obj, nsCString& out) {

Просмотреть файл

@ -1954,7 +1954,7 @@ ReportZoneStats(const JS::ZoneStats& zStats,
bool truncated = notableString.Length() < info.length;
nsCString path = pathPrefix +
nsPrintfCString("strings/" STRING_LENGTH "%d, copies=%d, \"%s\"%s)/",
nsPrintfCString("strings/" STRING_LENGTH "%" PRIuSIZE ", copies=%d, \"%s\"%s)/",
info.length, info.numCopies, escapedString.get(),
truncated ? " (truncated)" : "");

Просмотреть файл

@ -127,17 +127,13 @@ GetPrefsFor(EventClassID aEventClassID)
nsPrintfCString repositionPref("ui.%s.radius.reposition", prefBranch);
Preferences::AddBoolVarCache(&prefs->mRepositionEventCoords, repositionPref.get(), false);
nsPrintfCString touchClusterPref("ui.zoomedview.enabled", prefBranch);
Preferences::AddBoolVarCache(&prefs->mTouchClusterDetectionEnabled, touchClusterPref.get(), false);
Preferences::AddBoolVarCache(&prefs->mTouchClusterDetectionEnabled, "ui.zoomedview.enabled", false);
nsPrintfCString simplifiedClusterDetectionPref("ui.zoomedview.simplified", prefBranch);
Preferences::AddBoolVarCache(&prefs->mSimplifiedClusterDetection, simplifiedClusterDetectionPref.get(), false);
Preferences::AddBoolVarCache(&prefs->mSimplifiedClusterDetection, "ui.zoomedview.simplified", false);
nsPrintfCString limitReadableSizePref("ui.zoomedview.limitReadableSize", prefBranch);
Preferences::AddUintVarCache(&prefs->mLimitReadableSize, limitReadableSizePref.get(), 8);
Preferences::AddUintVarCache(&prefs->mLimitReadableSize, "ui.zoomedview.limitReadableSize", 8);
nsPrintfCString keepLimitSize("ui.zoomedview.keepLimitSize", prefBranch);
Preferences::AddUintVarCache(&prefs->mKeepLimitSizeForCluster, keepLimitSize.get(), 16);
Preferences::AddUintVarCache(&prefs->mKeepLimitSizeForCluster, "ui.zoomedview.keepLimitSize", 16);
}
return prefs;

Просмотреть файл

@ -62,7 +62,7 @@ GetFrameState(nsIFrame* aFrame)
#undef FRAME_STATE_BIT
if (state) {
result.AppendPrintf(" | 0x%0llx", state);
result.AppendPrintf(" | 0x%0" PRIx64, static_cast<uint64_t>(state));
}
return result;

Просмотреть файл

@ -498,7 +498,7 @@ ListInterestingFiles(nsString& aAnnotation, nsIFile* aFile,
aAnnotation.AppendLiteral(" (");
int64_t size;
if (NS_SUCCEEDED(aFile->GetFileSize(&size))) {
aAnnotation.AppendPrintf("%ld", size);
aAnnotation.AppendPrintf("%" PRId64, size);
} else {
aAnnotation.AppendLiteral("???");
}
@ -601,7 +601,8 @@ AnnotateCrashReport(nsIURI* aURI)
nsAutoCString resolvedSpec;
nsresult rv = handler->ResolveURI(aURI, resolvedSpec);
if (NS_FAILED(rv)) {
annotation.AppendPrintf("(ResolveURI failed with 0x%08x)\n", rv);
annotation.AppendPrintf("(ResolveURI failed with 0x%08" PRIx32 ")\n",
static_cast<uint32_t>(rv));
}
annotation.Append(NS_ConvertUTF8toUTF16(resolvedSpec));
annotation.Append('\n');
@ -694,7 +695,8 @@ AnnotateCrashReport(nsIURI* aURI)
nsZipFind* find;
rv = zip->FindInit(nullptr, &find);
if (NS_FAILED(rv)) {
annotation.AppendPrintf(" (FindInit failed with 0x%08x)\n", rv);
annotation.AppendPrintf(" (FindInit failed with 0x%08" PRIx32 ")\n",
static_cast<uint32_t>(rv));
} else if (!find) {
annotation.AppendLiteral(" (FindInit returned null)\n");
} else {
@ -784,7 +786,7 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
nsresult rv = loader->LoadSheetSync(aURI, aParsingMode, true, aSheet);
if (NS_FAILED(rv)) {
ErrorLoadingSheet(aURI,
nsPrintfCString("LoadSheetSync failed with error %x", rv).get(),
nsPrintfCString("LoadSheetSync failed with error %" PRIx32, static_cast<uint32_t>(rv)).get(),
aFailureAction);
}
}

Просмотреть файл

@ -95,7 +95,7 @@ void nsStyleUtil::AppendEscapedCSSString(const nsAString& aString,
for (; in != end; in++) {
if (*in < 0x20 || (*in >= 0x7F && *in < 0xA0)) {
// Escape U+0000 through U+001F and U+007F through U+009F numerically.
aReturn.AppendPrintf("\\%hx ", *in);
aReturn.AppendPrintf("\\%x ", *in);
} else {
if (*in == '"' || *in == '\'' || *in == '\\') {
// Escape backslash and quote characters symbolically.
@ -149,7 +149,7 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
// numerically. If we didn't escape it numerically, it would get
// interpreted as a numeric escape for the wrong character.
if (in != end && ('0' <= *in && *in <= '9')) {
aReturn.AppendPrintf("\\%hx ", *in);
aReturn.AppendPrintf("\\%x ", *in);
++in;
}
@ -159,7 +159,7 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
aReturn.Append(char16_t(0xFFFD));
} else if (ch < 0x20 || (0x7F <= ch && ch < 0xA0)) {
// Escape U+0000 through U+001F and U+007F through U+009F numerically.
aReturn.AppendPrintf("\\%hx ", *in);
aReturn.AppendPrintf("\\%x ", *in);
} else {
// Escape ASCII non-identifier printables as a backslash plus
// the character.

2
netwerk/cache/nsDiskCacheDeviceSQL.cpp поставляемый
Просмотреть файл

@ -2327,7 +2327,7 @@ nsOfflineCacheDevice::CreateApplicationCache(const nsACString &group,
// Include the timestamp to guarantee uniqueness across runs, and
// the gNextTemporaryClientID for uniqueness within a second.
clientID.Append(nsPrintfCString("|%016lld|%d",
clientID.Append(nsPrintfCString("|%016" PRId64 "|%d",
now / PR_USEC_PER_SEC,
gNextTemporaryClientID++));

Просмотреть файл

@ -16,6 +16,9 @@
#include "nsServiceManagerUtils.h"
#include "nsSocketTransportService2.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/SizePrintfMacros.h"
namespace mozilla {
namespace net {
@ -50,15 +53,15 @@ nsHttpConnectionMgr::OnMsgPrintDiagnostics(int32_t, ARefBase *)
AtActiveConnectionLimit(ent, NS_HTTP_ALLOW_KEEPALIVE));
mLogData.AppendPrintf(" RestrictConnections = %d\n",
RestrictConnections(ent));
mLogData.AppendPrintf(" Pending Q Length = %u\n",
mLogData.AppendPrintf(" Pending Q Length = %" PRIuSIZE "\n",
ent->mPendingQ.Length());
mLogData.AppendPrintf(" Active Conns Length = %u\n",
mLogData.AppendPrintf(" Active Conns Length = %" PRIuSIZE "\n",
ent->mActiveConns.Length());
mLogData.AppendPrintf(" Idle Conns Length = %u\n",
mLogData.AppendPrintf(" Idle Conns Length = %" PRIuSIZE "\n",
ent->mIdleConns.Length());
mLogData.AppendPrintf(" Half Opens Length = %u\n",
mLogData.AppendPrintf(" Half Opens Length = %" PRIuSIZE "\n",
ent->mHalfOpens.Length());
mLogData.AppendPrintf(" Coalescing Keys Length = %u\n",
mLogData.AppendPrintf(" Coalescing Keys Length = %" PRIuSIZE "\n",
ent->mCoalescingKeys.Length());
mLogData.AppendPrintf(" Spdy using = %d, preferred = %d\n",
ent->mUsingSpdy, ent->mInPreferredHash);
@ -141,7 +144,7 @@ nsHttpConnection::PrintDiagnostics(nsCString &log)
log.AppendPrintf(" time since last read = %ums\n",
PR_IntervalToMilliseconds(now - mLastReadTime));
log.AppendPrintf(" max-read/read/written %lld/%lld/%lld\n",
log.AppendPrintf(" max-read/read/written %" PRId64 "/%" PRId64 "/%" PRId64 "\n",
mMaxBytesRead, mTotalBytesRead, mTotalBytesWritten);
log.AppendPrintf(" rtt = %ums\n", PR_IntervalToMilliseconds(mRtt));
@ -173,7 +176,7 @@ Http2Session::PrintDiagnostics(nsCString &log)
mStreamTransactionHash.Count(),
mStreamIDHash.Count());
log.AppendPrintf(" Queued Stream Size = %d\n", mQueuedStreams.GetSize());
log.AppendPrintf(" Queued Stream Size = %" PRIuSIZE "\n", mQueuedStreams.GetSize());
PRIntervalTime now = PR_IntervalNow();
log.AppendPrintf(" Ping Threshold = %ums\n",

Просмотреть файл

@ -3649,7 +3649,7 @@ nsHttpChannel::OpenCacheEntry(bool isHttps)
cacheEntryOpenFlags |= nsICacheStorage::OPEN_BYPASS_IF_BUSY;
if (PossiblyIntercepted()) {
extension.Append(nsPrintfCString("u%lld", mInterceptionID));
extension.Append(nsPrintfCString("u%" PRIu64, mInterceptionID));
} else if (mPostID) {
extension.Append(nsPrintfCString("%d", mPostID));
}

Просмотреть файл

@ -895,7 +895,8 @@ nsHttpHandler::InitUserAgentComponents()
#endif
SInt32 majorVersion = nsCocoaFeatures::OSXVersionMajor();
SInt32 minorVersion = nsCocoaFeatures::OSXVersionMinor();
mOscpu += nsPrintfCString(" %d.%d", majorVersion, minorVersion);
mOscpu += nsPrintfCString(" %d.%d", static_cast<int>(majorVersion),
static_cast<int>(minorVersion));
#elif defined (XP_UNIX)
struct utsname name;

Просмотреть файл

@ -229,7 +229,7 @@ nsHttpResponseHead::SetContentLength(int64_t len)
mHeaders.ClearHeader(nsHttp::Content_Length);
else
mHeaders.SetHeader(nsHttp::Content_Length,
nsPrintfCString("%lld", len),
nsPrintfCString("%" PRId64, len),
false,
nsHttpHeaderArray::eVarietyResponse);
}

Просмотреть файл

@ -735,7 +735,7 @@ nsFileView::GetCellText(int32_t aRow, nsITreeColumn* aCol,
else {
int64_t fileSize;
curFile->GetFileSize(&fileSize);
CopyUTF8toUTF16(nsPrintfCString("%lld", fileSize), aCellText);
CopyUTF8toUTF16(nsPrintfCString("%" PRId64, fileSize), aCellText);
}
}

Просмотреть файл

@ -1666,7 +1666,7 @@ nsNavBookmarks::SetItemDateAdded(int64_t aItemId, PRTime aDateAdded,
OnItemChanged(bookmark.id,
NS_LITERAL_CSTRING("dateAdded"),
false,
nsPrintfCString("%lld", bookmark.dateAdded),
nsPrintfCString("%" PRId64, bookmark.dateAdded),
bookmark.dateAdded,
bookmark.type,
bookmark.parentId,
@ -1736,7 +1736,7 @@ nsNavBookmarks::SetItemLastModified(int64_t aItemId, PRTime aLastModified,
OnItemChanged(bookmark.id,
NS_LITERAL_CSTRING("lastModified"),
false,
nsPrintfCString("%lld", bookmark.lastModified),
nsPrintfCString("%" PRId64, bookmark.lastModified),
bookmark.lastModified,
bookmark.type,
bookmark.parentId,

Просмотреть файл

@ -7,6 +7,8 @@
#include <stdio.h>
#include "mozilla/DebugOnly.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/SizePrintfMacros.h"
#include "nsNavHistory.h"
@ -210,7 +212,7 @@ void GetTagsSqlFragment(int64_t aTagsFolder,
"JOIN moz_bookmarks t_t ON t_t.id = +b_t.parent "
"WHERE b_t.fk = ") + aRelation + NS_LITERAL_CSTRING(" "
"AND t_t.parent = ") +
nsPrintfCString("%lld", aTagsFolder) + NS_LITERAL_CSTRING(" "
nsPrintfCString("%" PRId64, aTagsFolder) + NS_LITERAL_CSTRING(" "
")"));
}
@ -1553,7 +1555,7 @@ PlacesSQLQueryBuilder::SelectAsURI()
"LEFT OUTER JOIN moz_favicons f ON h.favicon_id = f.id "
"WHERE NOT EXISTS ( "
"SELECT id FROM moz_bookmarks WHERE id = b2.parent AND parent = ") +
nsPrintfCString("%lld", history->GetTagsFolder()) +
nsPrintfCString("%" PRId64, history->GetTagsFolder()) +
NS_LITERAL_CSTRING(") "
"ORDER BY b2.fk DESC, b2.lastModified DESC");
}
@ -1574,7 +1576,7 @@ PlacesSQLQueryBuilder::SelectAsURI()
"WHERE NOT EXISTS "
"(SELECT id FROM moz_bookmarks "
"WHERE id = b.parent AND parent = ") +
nsPrintfCString("%lld", history->GetTagsFolder()) +
nsPrintfCString("%" PRId64, history->GetTagsFolder()) +
NS_LITERAL_CSTRING(") "
"{ADDITIONAL_CONDITIONS}");
}
@ -1634,7 +1636,7 @@ PlacesSQLQueryBuilder::SelectAsDay()
// insert position in a result.
mQueryString = nsPrintfCString(
"SELECT null, "
"'place:type=%ld&sort=%ld&beginTime='||beginTime||'&endTime='||endTime, "
"'place:type=%d&sort=%d&beginTime='||beginTime||'&endTime='||endTime, "
"dayTitle, null, null, beginTime, null, null, null, null, null, null, "
"null, null, null "
"FROM (", // TOUTER BEGIN
@ -1838,7 +1840,7 @@ PlacesSQLQueryBuilder::SelectAsSite()
}
mQueryString = nsPrintfCString(
"SELECT null, 'place:type=%ld&sort=%ld&domain=&domainIsHost=true'%s, "
"SELECT null, 'place:type=%d&sort=%d&domain=&domainIsHost=true'%s, "
":localhost, :localhost, null, null, null, null, null, null, null, "
"null, null, null "
"WHERE EXISTS ( "
@ -1853,7 +1855,7 @@ PlacesSQLQueryBuilder::SelectAsSite()
") "
"UNION ALL "
"SELECT null, "
"'place:type=%ld&sort=%ld&domain='||host||'&domainIsHost=true'%s, "
"'place:type=%d&sort=%d&domain='||host||'&domainIsHost=true'%s, "
"host, host, null, null, null, null, null, null, null, "
"null, null, null "
"FROM ( "
@ -1893,11 +1895,11 @@ PlacesSQLQueryBuilder::SelectAsTag()
mHasDateColumns = true;
mQueryString = nsPrintfCString(
"SELECT null, 'place:folder=' || id || '&queryType=%d&type=%ld', "
"SELECT null, 'place:folder=' || id || '&queryType=%d&type=%d', "
"title, null, null, null, null, null, dateAdded, "
"lastModified, null, null, null, null, null, null "
"FROM moz_bookmarks "
"WHERE parent = %lld",
"WHERE parent = %" PRId64,
nsINavHistoryQueryOptions::QUERY_TYPE_BOOKMARKS,
nsINavHistoryQueryOptions::RESULTS_AS_TAG_CONTENTS,
history->GetTagsFolder()
@ -3356,7 +3358,7 @@ nsNavHistory::QueryToSelectClause(nsNavHistoryQuery* aQuery, // const
clause.Condition("b.parent IN(");
for (nsTArray<int64_t>::size_type i = 0; i < includeFolders.Length(); ++i) {
clause.Str(nsPrintfCString("%lld", includeFolders[i]).get());
clause.Str(nsPrintfCString("%" PRId64, includeFolders[i]).get());
if (i < includeFolders.Length() - 1) {
clause.Str(",");
}

Просмотреть файл

@ -46,7 +46,7 @@ ReflectIceEntry(const WebrtcTelemetry::WebrtcIceCandidateType *entry,
if (!statsObj)
return false;
if (!JS_DefineProperty(cx, obj,
nsPrintfCString("%lu", bitmask).BeginReading(),
nsPrintfCString("%" PRIu32, bitmask).BeginReading(),
statsObj, JSPROP_ENUMERATE)) {
return false;
}

Просмотреть файл

@ -39,7 +39,7 @@ static mozilla::LazyLogModule gUrlClassifierStreamUpdaterLog("UrlClassifierStrea
// Calls nsIURLFormatter::TrimSensitiveURLs to remove sensitive
// info from the logging message.
static void TrimAndLog(const char* aFmt, ...)
static MOZ_FORMAT_PRINTF(1, 2) void TrimAndLog(const char* aFmt, ...)
{
nsString raw;
@ -404,7 +404,8 @@ nsUrlClassifierStreamUpdater::StreamFinished(nsresult status,
// We are a service and may not be reset with Init between calls, so reset
// mBeganStream manually.
mBeganStream = false;
LOG(("nsUrlClassifierStreamUpdater::StreamFinished [%x, %d]", status, requestedDelay));
LOG(("nsUrlClassifierStreamUpdater::StreamFinished [%" PRIx32 ", %d]",
static_cast<uint32_t>(status), requestedDelay));
if (NS_FAILED(status) || mPendingUpdates.Length() == 0) {
// We're done.
LOG(("nsUrlClassifierStreamUpdater::Done [this=%p]", this));
@ -710,7 +711,7 @@ nsUrlClassifierStreamUpdater::OnDataAvailable(nsIRequest *request,
LOG(("OnDataAvailable (%d bytes)", aLength));
if (aSourceOffset > MAX_FILE_SIZE) {
LOG(("OnDataAvailable::Abort because exceeded the maximum file size(%lld)", aSourceOffset));
LOG(("OnDataAvailable::Abort because exceeded the maximum file size(%" PRIu64 ")", aSourceOffset));
return NS_ERROR_FILE_TOO_BIG;
}
@ -735,8 +736,8 @@ nsUrlClassifierStreamUpdater::OnStopRequest(nsIRequest *request, nsISupports* co
if (!mDBService)
return NS_ERROR_NOT_INITIALIZED;
LOG(("OnStopRequest (status %x, beganStream %s, this=%p)", aStatus,
mBeganStream ? "true" : "false", this));
LOG(("OnStopRequest (status %" PRIx32 ", beganStream %s, this=%p)",
static_cast<uint32_t>(aStatus), mBeganStream ? "true" : "false", this));
nsresult rv;

Просмотреть файл

@ -47,7 +47,7 @@ CreateResetProfile(nsIToolkitProfileService* aProfileSvc, const nsACString& aOld
} else {
newProfileName.Assign("default-");
}
newProfileName.Append(nsPrintfCString("%lld", PR_Now() / 1000));
newProfileName.Append(nsPrintfCString("%" PRId64, PR_Now() / 1000));
nsresult rv = aProfileSvc->CreateProfile(nullptr, // choose a default dir for us
newProfileName,
getter_AddRefs(newProfile));

Просмотреть файл

@ -4175,9 +4175,9 @@ XREMain::XRE_mainRun()
}
// Needs to be set after xpcom initialization.
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("FramePoisonBase"),
nsPrintfCString("%.16llx", uint64_t(gMozillaPoisonBase)));
nsPrintfCString("%.16" PRIu64, uint64_t(gMozillaPoisonBase)));
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("FramePoisonSize"),
nsPrintfCString("%lu", uint32_t(gMozillaPoisonSize)));
nsPrintfCString("%" PRIu32, uint32_t(gMozillaPoisonSize)));
#ifdef XP_WIN
PR_CreateThread(PR_USER_THREAD, AnnotateSystemManufacturer_ThreadStart, 0,

Просмотреть файл

@ -67,7 +67,7 @@ void ShutdownTaskTracer();
// Add a label to the currently running task, aFormat is the message to log,
// followed by corresponding parameters.
void AddLabel(const char* aFormat, ...);
void AddLabel(const char* aFormat, ...) MOZ_FORMAT_PRINTF(1, 2);
void StartLogging();
void StopLogging();

Просмотреть файл

@ -461,7 +461,7 @@ private:
aDesc.AppendPrintf("The stack size of a non-main thread named '%s' with "
"thread ID %d. This corresponds to '[stack:%d]' "
"in /proc/%d/smaps.", threadName.get(), tid, tid);
"in /proc/%d/smaps.", threadName.get(), tid, tid, tid);
} else if (absPath.EqualsLiteral("[vdso]")) {
aName.AppendLiteral("vdso");
aDesc.AppendLiteral(

Просмотреть файл

@ -50,7 +50,7 @@ public:
MozillaRegisterDebugFILE(mFile);
}
void Printf(const char* aFormat, ...)
void Printf(const char* aFormat, ...) MOZ_FORMAT_PRINTF(2, 3)
{
MOZ_ASSERT(mFile);
va_list list;

Просмотреть файл

@ -25,7 +25,7 @@ class nsPrintfCString : public nsFixedCString
typedef nsCString string_type;
public:
explicit nsPrintfCString(const char_type* aFormat, ...)
explicit nsPrintfCString(const char_type* aFormat, ...) MOZ_FORMAT_PRINTF(2, 3)
: nsFixedCString(mLocalBuffer, kLocalBufferSize, 0)
{
va_list ap;

Просмотреть файл

@ -7,6 +7,7 @@
#include "mozilla/CheckedInt.h"
#include "mozilla/double-conversion.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Printf.h"
using double_conversion::DoubleToStringConverter;
@ -904,29 +905,41 @@ nsTSubstring_CharT::StripChars(const char_type* aChars, uint32_t aOffset)
mLength = to - mData;
}
int
nsTSubstring_CharT::AppendFunc(void* aArg, const char* aStr, uint32_t aLen)
struct MOZ_STACK_CLASS PrintfAppend_CharT : public mozilla::PrintfTarget
{
self_type* self = static_cast<self_type*>(aArg);
explicit PrintfAppend_CharT(nsTSubstring_CharT* aString)
: mString(aString)
{
}
// NSPR sends us the final null terminator even though we don't want it
if (aLen && aStr[aLen - 1] == '\0') {
bool append(const char* aStr, size_t aLen) override {
if (aLen == 0) {
return true;
}
// Printf sends us the final null terminator even though we don't want it
if (aStr[aLen - 1] == '\0') {
--aLen;
}
self->AppendASCII(aStr, aLen);
return aLen;
mString->AppendASCII(aStr, aLen);
return true;
}
private:
nsTSubstring_CharT* mString;
};
void
nsTSubstring_CharT::AppendPrintf(const char* aFormat, ...)
{
PrintfAppend_CharT appender(this);
va_list ap;
va_start(ap, aFormat);
uint32_t r = PR_vsxprintf(AppendFunc, this, aFormat, ap);
if (r == (uint32_t)-1) {
MOZ_CRASH("Allocation or other failure in PR_vsxprintf");
bool r = appender.vprint(aFormat, ap);
if (!r) {
MOZ_CRASH("Allocation or other failure in PrintfTarget::print");
}
va_end(ap);
}
@ -934,9 +947,10 @@ nsTSubstring_CharT::AppendPrintf(const char* aFormat, ...)
void
nsTSubstring_CharT::AppendPrintf(const char* aFormat, va_list aAp)
{
uint32_t r = PR_vsxprintf(AppendFunc, this, aFormat, aAp);
if (r == (uint32_t)-1) {
MOZ_CRASH("Allocation or other failure in PR_vsxprintf");
PrintfAppend_CharT appender(this);
bool r = appender.vprint(aFormat, aAp);
if (!r) {
MOZ_CRASH("Allocation or other failure in PrintfTarget::print");
}
}

Просмотреть файл

@ -6,6 +6,7 @@
// IWYU pragma: private, include "nsString.h"
#include "mozilla/Casting.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/MemoryReporting.h"
@ -574,46 +575,54 @@ public:
}
/**
* Append a formatted string to the current string. Uses the format
* codes documented in prprf.h
* Append a formatted string to the current string. Uses the
* standard printf format codes.
*/
void AppendPrintf(const char* aFormat, ...);
void AppendPrintf(const char* aFormat, ...) MOZ_FORMAT_PRINTF(2, 3);
void AppendPrintf(const char* aFormat, va_list aAp);
void AppendInt(int32_t aInteger)
{
AppendPrintf("%d", aInteger);
AppendPrintf("%" PRId32, aInteger);
}
void AppendInt(int32_t aInteger, int aRadix)
{
const char* fmt = aRadix == 10 ? "%d" : aRadix == 8 ? "%o" : "%x";
AppendPrintf(fmt, aInteger);
if (aRadix == 10) {
AppendPrintf("%" PRId32, aInteger);
} else {
AppendPrintf(aRadix == 8 ? "%" PRIo32 : "%" PRIx32,
static_cast<uint32_t>(aInteger));
}
}
void AppendInt(uint32_t aInteger)
{
AppendPrintf("%u", aInteger);
AppendPrintf("%" PRIu32, aInteger);
}
void AppendInt(uint32_t aInteger, int aRadix)
{
const char* fmt = aRadix == 10 ? "%u" : aRadix == 8 ? "%o" : "%x";
AppendPrintf(fmt, aInteger);
AppendPrintf(aRadix == 10 ? "%" PRIu32 : aRadix == 8 ? "%" PRIo32 : "%" PRIx32,
aInteger);
}
void AppendInt(int64_t aInteger)
{
AppendPrintf("%lld", aInteger);
AppendPrintf("%" PRId64, aInteger);
}
void AppendInt(int64_t aInteger, int aRadix)
{
const char* fmt = aRadix == 10 ? "%lld" : aRadix == 8 ? "%llo" : "%llx";
AppendPrintf(fmt, aInteger);
if (aRadix == 10) {
AppendPrintf("%" PRId64, aInteger);
} else {
AppendPrintf(aRadix == 8 ? "%" PRIo64 : "%" PRIx64,
static_cast<uint64_t>(aInteger));
}
}
void AppendInt(uint64_t aInteger)
{
AppendPrintf("%llu", aInteger);
AppendPrintf("%" PRIu64, aInteger);
}
void AppendInt(uint64_t aInteger, int aRadix)
{
const char* fmt = aRadix == 10 ? "%llu" : aRadix == 8 ? "%llo" : "%llx";
AppendPrintf(fmt, aInteger);
AppendPrintf(aRadix == 10 ? "%" PRIu64 : aRadix == 8 ? "%" PRIo64 : "%" PRIx64,
aInteger);
}
/**
@ -1044,8 +1053,6 @@ protected:
void NS_FASTCALL ReplaceLiteral(index_type aCutStart, size_type aCutLength,
const char_type* aData, size_type aLength);
static int AppendFunc(void* aArg, const char* aStr, uint32_t aLen);
public:
// NOTE: this method is declared public _only_ for convenience for

Просмотреть файл

@ -12,6 +12,7 @@
#define nsTFixedString_CharT nsFixedCString
#define nsTAutoString_CharT nsAutoCString
#define nsTSubstring_CharT nsACString
#define PrintfAppend_CharT PrintfAppend_nsACString
#define nsTSubstringTuple_CharT nsCSubstringTuple
#define nsTStringComparator_CharT nsCStringComparator
#define nsTDefaultStringComparator_CharT nsDefaultCStringComparator

Просмотреть файл

@ -12,6 +12,7 @@
#define nsTFixedString_CharT nsFixedString
#define nsTAutoString_CharT nsAutoString
#define nsTSubstring_CharT nsAString
#define PrintfAppend_CharT PrintfAppend_nsAString
#define nsTSubstringTuple_CharT nsSubstringTuple
#define nsTStringComparator_CharT nsStringComparator
#define nsTDefaultStringComparator_CharT nsDefaultStringComparator

Просмотреть файл

@ -13,6 +13,7 @@
#undef nsTFixedString_CharT
#undef nsTAutoString_CharT
#undef nsTSubstring_CharT
#undef PrintfAppend_CharT
#undef nsTSubstringTuple_CharT
#undef nsTStringComparator_CharT
#undef nsTDefaultStringComparator_CharT