Bug 1046841 - Fix more style violations in previously touched .cpp files in xpcom/. r=froydnj

This commit is contained in:
Birunthan Mohanathas 2014-08-25 12:17:15 -07:00
parent 6bf06cece4
commit 6ea79dfc7c
48 changed files with 396 additions and 306 deletions

View File

@ -149,18 +149,16 @@ volatile PRIntervalTime sLastLowMemoryNotificationTime;
// These are function pointers to the functions we wrap in Init().
void* (WINAPI* sVirtualAllocOrig)
(LPVOID aAddress, SIZE_T aSize, DWORD aAllocationType, DWORD aProtect);
void* (WINAPI* sVirtualAllocOrig)(LPVOID aAddress, SIZE_T aSize,
DWORD aAllocationType, DWORD aProtect);
void* (WINAPI* sMapViewOfFileOrig)
(HANDLE aFileMappingObject, DWORD aDesiredAccess,
DWORD aFileOffsetHigh, DWORD aFileOffsetLow,
SIZE_T aNumBytesToMap);
void* (WINAPI* sMapViewOfFileOrig)(HANDLE aFileMappingObject,
DWORD aDesiredAccess, DWORD aFileOffsetHigh,
DWORD aFileOffsetLow, SIZE_T aNumBytesToMap);
HBITMAP (WINAPI* sCreateDIBSectionOrig)
(HDC aDC, const BITMAPINFO* aBitmapInfo,
UINT aUsage, VOID** aBits,
HANDLE aSection, DWORD aOffset);
HBITMAP(WINAPI* sCreateDIBSectionOrig)(HDC aDC, const BITMAPINFO* aBitmapInfo,
UINT aUsage, VOID** aBits,
HANDLE aSection, DWORD aOffset);
/**
* Fire a memory pressure event if it's been long enough since the last one we

View File

@ -157,7 +157,8 @@ TraceWeakMappingChild(JSTracer* aTrc, void** aThingp, JSGCTraceKind aKind)
}
if (AddToCCKind(aKind)) {
tracer->mCb.NoteWeakMapping(tracer->mMap, tracer->mKey, tracer->mKeyDelegate, thing);
tracer->mCb.NoteWeakMapping(tracer->mMap, tracer->mKey,
tracer->mKeyDelegate, thing);
tracer->mTracedAny = true;
} else {
JS_TraceChildren(aTrc, thing, aKind);
@ -305,7 +306,8 @@ struct Closure
};
static void
CheckParticipatesInCycleCollection(void* aThing, const char* aName, void* aClosure)
CheckParticipatesInCycleCollection(void* aThing, const char* aName,
void* aClosure)
{
Closure* closure = static_cast<Closure*>(aClosure);
@ -346,9 +348,9 @@ NS_IMETHODIMP
JSGCThingParticipant::Traverse(void* aPtr,
nsCycleCollectionTraversalCallback& aCb)
{
CycleCollectedJSRuntime* runtime = reinterpret_cast<CycleCollectedJSRuntime*>
(reinterpret_cast<char*>(this) -
offsetof(CycleCollectedJSRuntime, mGCThingCycleCollectorGlobal));
auto runtime = reinterpret_cast<CycleCollectedJSRuntime*>(
reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSRuntime,
mGCThingCycleCollectorGlobal));
runtime->TraverseGCThing(CycleCollectedJSRuntime::TRAVERSE_FULL,
aPtr, js::GCThingTraceKind(aPtr), aCb);
@ -362,9 +364,9 @@ static JSGCThingParticipant sGCThingCycleCollectorGlobal;
NS_IMETHODIMP
JSZoneParticipant::Traverse(void* aPtr, nsCycleCollectionTraversalCallback& aCb)
{
CycleCollectedJSRuntime* runtime = reinterpret_cast<CycleCollectedJSRuntime*>
(reinterpret_cast<char*>(this) -
offsetof(CycleCollectedJSRuntime, mJSZoneCycleCollectorGlobal));
auto runtime = reinterpret_cast<CycleCollectedJSRuntime*>(
reinterpret_cast<char*>(this) - offsetof(CycleCollectedJSRuntime,
mJSZoneCycleCollectorGlobal));
MOZ_ASSERT(!aCb.WantAllTraces());
JS::Zone* zone = static_cast<JS::Zone*>(aPtr);
@ -489,7 +491,8 @@ CycleCollectedJSRuntime::CycleCollectedJSRuntime(JSRuntime* aParentRuntime,
JS_SetGrayGCRootsTracer(mJSRuntime, TraceGrayJS, this);
JS_SetGCCallback(mJSRuntime, GCCallback, this);
JS::SetOutOfMemoryCallback(mJSRuntime, OutOfMemoryCallback, this);
JS::SetLargeAllocationFailureCallback(mJSRuntime, LargeAllocationFailureCallback, this);
JS::SetLargeAllocationFailureCallback(mJSRuntime,
LargeAllocationFailureCallback, this);
JS_SetContextCallback(mJSRuntime, ContextCallback, this);
JS_SetDestroyZoneCallback(mJSRuntime, XPCStringConvert::FreeZoneCache);
JS_SetSweepZoneCallback(mJSRuntime, XPCStringConvert::ClearZoneCache);
@ -612,7 +615,8 @@ CycleCollectedJSRuntime::NoteGCThingJSChildren(void* aThing,
}
void
CycleCollectedJSRuntime::NoteGCThingXPCOMChildren(const js::Class* aClasp, JSObject* aObj,
CycleCollectedJSRuntime::NoteGCThingXPCOMChildren(const js::Class* aClasp,
JSObject* aObj,
nsCycleCollectionTraversalCallback& aCb) const
{
MOZ_ASSERT(aClasp);
@ -765,7 +769,7 @@ CycleCollectedJSRuntime::GCCallback(JSRuntime* aRuntime,
}
/* static */ void
CycleCollectedJSRuntime::OutOfMemoryCallback(JSContext *aContext,
CycleCollectedJSRuntime::OutOfMemoryCallback(JSContext* aContext,
void* aData)
{
CycleCollectedJSRuntime* self = static_cast<CycleCollectedJSRuntime*>(aData);
@ -1101,7 +1105,8 @@ IncrementalFinalizeRunnable::IncrementalFinalizeRunnable(CycleCollectedJSRuntime
, mFinalizeFunctionToRun(0)
{
this->mSupports.SwapElements(aSupports);
DeferredFinalizeFunctionHolder* function = mDeferredFinalizeFunctions.AppendElement();
DeferredFinalizeFunctionHolder* function =
mDeferredFinalizeFunctions.AppendElement();
function->run = ReleaseSliceNow;
function->data = &this->mSupports;
@ -1201,8 +1206,9 @@ CycleCollectedJSRuntime::FinalizeDeferredThings(DeferredFinalizeType aType)
}
}
void
CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState *aStatePtr, OOMState aNewState)
void
CycleCollectedJSRuntime::AnnotateAndSetOutOfMemory(OOMState* aStatePtr,
OOMState aNewState)
{
*aStatePtr = aNewState;
#ifdef MOZ_CRASHREPORTER

View File

@ -163,8 +163,9 @@ public:
{
// There is lots of privacy-sensitive data in /proc. Just skip this
// reporter entirely when anonymization is required.
if (aAnonymize)
if (aAnonymize) {
return NS_OK;
}
if (!Preferences::GetBool("memory.system_memory_reporter")) {
return NS_OK;
@ -213,12 +214,12 @@ private:
class ProcessSizes
{
public:
void Add(const nsACString &aKey, size_t aSize)
void Add(const nsACString& aKey, size_t aSize)
{
mTagged.Put(aKey, mTagged.Get(aKey) + aSize);
}
void Report(nsIHandleReportCallback *aHandleReport, nsISupports *aData)
void Report(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
{
EnumArgs env = { aHandleReport, aData };
mTagged.EnumerateRead(ReportSizes, &env);
@ -227,16 +228,17 @@ private:
private:
nsDataHashtable<nsCStringHashKey, size_t> mTagged;
struct EnumArgs {
struct EnumArgs
{
nsIHandleReportCallback* mHandleReport;
nsISupports* mData;
};
static PLDHashOperator ReportSizes(nsCStringHashKey::KeyType aKey,
size_t aAmount,
void *aUserArg)
void* aUserArg)
{
const EnumArgs *envp = reinterpret_cast<const EnumArgs*>(aUserArg);
const EnumArgs* envp = reinterpret_cast<const EnumArgs*>(aUserArg);
nsAutoCString path("processes/");
path.Append(aKey);
@ -335,8 +337,8 @@ private:
// Report the open file descriptors for this process.
nsPrintfCString procFdPath("/proc/%s/fd", pidStr);
rv = CollectOpenFileReports(
aHandleReport, aData, procFdPath, processName);
rv = CollectOpenFileReports(aHandleReport, aData, procFdPath,
processName);
if (NS_FAILED(rv)) {
break;
}
@ -947,12 +949,12 @@ private:
#undef CHECK_PREFIX
const nsCString processName(aProcessName);
nsPrintfCString entryPath(
"open-fds/%s/%s%s/%s", processName.get(), category, linkPath, fd);
nsPrintfCString entryDescription(
"%s file descriptor opened by the process", descriptionPrefix);
REPORT_WITH_CLEANUP(
entryPath, UNITS_COUNT, 1, entryDescription, closedir(d));
nsPrintfCString entryPath("open-fds/%s/%s%s/%s",
processName.get(), category, linkPath, fd);
nsPrintfCString entryDescription("%s file descriptor opened by the process",
descriptionPrefix);
REPORT_WITH_CLEANUP(entryPath, UNITS_COUNT, 1, entryDescription,
closedir(d));
}
}
@ -973,8 +975,8 @@ private:
// For simplicity numbers will be uint64_t, strings 63 chars max.
const char* const kScanFormat =
"%" SCNx64 " %" SCNx64 " %" SCNu64 " %" SCNu64
" %63s %63s %63s %" SCNu64;
"%" SCNx64 " %" SCNx64 " %" SCNu64 " %" SCNu64
" %63s %63s %63s %" SCNu64;
const int kNumFields = 8;
const size_t kStringSize = 64;

View File

@ -439,7 +439,8 @@ Init()
gEventFilter = EventFilter::Build(logEvents);
}
PRStatus status = PR_NewThreadPrivateIndex(&gThreadPrivateIndex, &RecordBatch::Close);
PRStatus status = PR_NewThreadPrivateIndex(&gThreadPrivateIndex,
&RecordBatch::Close);
if (status != PR_SUCCESS) {
return;
}
@ -497,8 +498,8 @@ Mark(uint32_t aType, void* aItem, const char* aText, const char* aText2)
return;
}
RecordBatch* threadLogPrivate = static_cast<RecordBatch*>(
PR_GetThreadPrivate(gThreadPrivateIndex));
RecordBatch* threadLogPrivate =
static_cast<RecordBatch*>(PR_GetThreadPrivate(gThreadPrivateIndex));
if (!threadLogPrivate) {
threadLogPrivate = RecordBatch::Register();
if (!threadLogPrivate) {

View File

@ -34,7 +34,9 @@ using namespace mozilla;
NS_IMPL_ADDREF(nsConsoleService)
NS_IMPL_RELEASE(nsConsoleService)
NS_IMPL_CLASSINFO(nsConsoleService, nullptr, nsIClassInfo::THREADSAFE | nsIClassInfo::SINGLETON, NS_CONSOLESERVICE_CID)
NS_IMPL_CLASSINFO(nsConsoleService, nullptr,
nsIClassInfo::THREADSAFE | nsIClassInfo::SINGLETON,
NS_CONSOLESERVICE_CID)
NS_IMPL_QUERY_INTERFACE_CI(nsConsoleService, nsIConsoleService)
NS_IMPL_CI_INTERFACE_GETTER(nsConsoleService, nsIConsoleService)
@ -57,7 +59,7 @@ nsConsoleService::nsConsoleService()
nsConsoleService::~nsConsoleService()
{
uint32_t i = 0;
while (i < mBufferSize && mMessages[i] != nullptr) {
while (i < mBufferSize && mMessages[i]) {
NS_RELEASE(mMessages[i]);
i++;
}
@ -266,7 +268,8 @@ nsConsoleService::LogStringMessage(const char16_t* aMessage)
}
NS_IMETHODIMP
nsConsoleService::GetMessageArray(uint32_t* aCount, nsIConsoleMessage*** aMessages)
nsConsoleService::GetMessageArray(uint32_t* aCount,
nsIConsoleMessage*** aMessages)
{
nsIConsoleMessage** messageArray;

View File

@ -383,7 +383,8 @@ public:
private:
struct Block;
union PtrInfoOrBlock {
union PtrInfoOrBlock
{
// Use a union to avoid reinterpret_cast and the ensuing
// potential aliasing bugs.
PtrInfo* ptrInfo;
@ -430,15 +431,9 @@ public:
class Iterator
{
public:
Iterator() : mPointer(nullptr)
{
}
explicit Iterator(PtrInfoOrBlock* aPointer) : mPointer(aPointer)
{
}
Iterator(const Iterator& aOther) : mPointer(aOther.mPointer)
{
}
Iterator() : mPointer(nullptr) {}
explicit Iterator(PtrInfoOrBlock* aPointer) : mPointer(aPointer) {}
Iterator(const Iterator& aOther) : mPointer(aOther.mPointer) {}
Iterator& operator++()
{
@ -963,7 +958,8 @@ CanonicalizeParticipant(void** aParti, nsCycleCollectionParticipant** aCp)
struct nsPurpleBufferEntry
{
union {
union
{
void* mObject; // when low bit unset
nsPurpleBufferEntry* mNextInFreeList; // when low bit set
};
@ -998,7 +994,7 @@ private:
);
}
template <class PurpleVisitor>
template<class PurpleVisitor>
void VisitEntries(nsPurpleBuffer& aBuffer, PurpleVisitor& aVisitor)
{
nsPurpleBufferEntry* eEnd = ArrayEnd(mEntries);
@ -1027,7 +1023,7 @@ public:
FreeBlocks();
}
template <class PurpleVisitor>
template<class PurpleVisitor>
void VisitEntries(PurpleVisitor& aVisitor)
{
for (Block* b = &mFirstBlock; b; b = b->mNext) {
@ -1218,14 +1214,16 @@ nsPurpleBuffer::SelectPointers(CCGraphBuilder& aBuilder)
}
}
enum ccPhase {
enum ccPhase
{
IdlePhase,
GraphBuildingPhase,
ScanAndCollectWhitePhase,
CleanupPhase
};
enum ccType {
enum ccType
{
SliceCC, /* If a CC is in progress, continue it. Otherwise, start a new one. */
ManualCC, /* Explicitly triggered. */
ShutdownCC /* Shutdown CC, used for finding leaks. */
@ -1355,7 +1353,7 @@ NS_IMPL_ISUPPORTS(nsCycleCollector, nsIMemoryReporter)
* bool ShouldVisitNode(PtrInfo const *pi);
* void VisitNode(PtrInfo *pi);
*/
template <class Visitor>
template<class Visitor>
class GraphWalker
{
private:
@ -1428,7 +1426,7 @@ ToParticipant(nsISupports* aPtr, nsXPCOMCycleCollectionParticipant** aCp)
CallQueryInterface(aPtr, aCp);
}
template <class Visitor>
template<class Visitor>
MOZ_NEVER_INLINE void
GraphWalker<Visitor>::Walk(PtrInfo* aPi)
{
@ -1437,7 +1435,7 @@ GraphWalker<Visitor>::Walk(PtrInfo* aPi)
DoWalk(queue);
}
template <class Visitor>
template<class Visitor>
MOZ_NEVER_INLINE void
GraphWalker<Visitor>::WalkFromRoots(CCGraph& aGraph)
{
@ -1449,7 +1447,7 @@ GraphWalker<Visitor>::WalkFromRoots(CCGraph& aGraph)
DoWalk(queue);
}
template <class Visitor>
template<class Visitor>
MOZ_NEVER_INLINE void
GraphWalker<Visitor>::DoWalk(nsDeque& aQueue)
{
@ -1476,7 +1474,8 @@ struct CCGraphDescriber : public LinkedListElement<CCGraphDescriber>
{
}
enum Type {
enum Type
{
eRefCountedObject,
eGCedObject,
eGCMarkedObject,
@ -1590,7 +1589,8 @@ private:
}
}
struct FileInfo {
struct FileInfo
{
const char* const mPrefix;
nsCOMPtr<nsIFile> mFile;
FILE* mStream;
@ -1627,9 +1627,7 @@ private:
// aFilename under a memory-reporting-specific folder
// (/data/local/tmp/memory-reports). Otherwise, it will open a
// file named aFilename under "NS_OS_TEMP_DIR".
nsresult rv = nsDumpUtils::OpenTempFile(
filename,
&logFile,
nsresult rv = nsDumpUtils::OpenTempFile(filename, &logFile,
NS_LITERAL_CSTRING("memory-reports"));
if (NS_FAILED(rv)) {
NS_IF_RELEASE(logFile);
@ -1651,13 +1649,15 @@ private:
incomplete += aLog->mPrefix;
MOZ_ASSERT(!aLog->mFile);
aLog->mFile = CreateTempFile(incomplete.get());
if (NS_WARN_IF(!aLog->mFile))
if (NS_WARN_IF(!aLog->mFile)) {
return NS_ERROR_UNEXPECTED;
}
MOZ_ASSERT(!aLog->mStream);
aLog->mFile->OpenANSIFileDesc("w", &aLog->mStream);
if (NS_WARN_IF(!aLog->mStream))
if (NS_WARN_IF(!aLog->mStream)) {
return NS_ERROR_UNEXPECTED;
}
MozillaRegisterDebugFILE(aLog->mStream);
return NS_OK;
}
@ -1674,13 +1674,15 @@ private:
// Strip off "incomplete-".
nsCOMPtr<nsIFile> logFileFinalDestination =
CreateTempFile(aLog->mPrefix);
if (NS_WARN_IF(!logFileFinalDestination))
if (NS_WARN_IF(!logFileFinalDestination)) {
return NS_ERROR_UNEXPECTED;
}
nsAutoString logFileFinalDestinationName;
logFileFinalDestination->GetLeafName(logFileFinalDestinationName);
if (NS_WARN_IF(logFileFinalDestinationName.IsEmpty()))
if (NS_WARN_IF(logFileFinalDestinationName.IsEmpty())) {
return NS_ERROR_UNEXPECTED;
}
aLog->mFile->MoveTo(/* directory */ nullptr, logFileFinalDestinationName);
@ -1695,8 +1697,8 @@ private:
nsAutoString logPath;
logFileFinalDestination->GetPath(logPath);
nsString msg = aCollectorKind
+ NS_LITERAL_STRING(" Collector log dumped to ") + logPath;
nsString msg = aCollectorKind +
NS_LITERAL_STRING(" Collector log dumped to ") + logPath;
cs->LogStringMessage(msg.get());
}
return NS_OK;
@ -1844,7 +1846,7 @@ public:
mCurrentAddress.AssignLiteral("0x");
mCurrentAddress.AppendInt(aAddress, 16);
d->mType = aMarked ? CCGraphDescriber::eGCMarkedObject :
CCGraphDescriber::eGCedObject;
CCGraphDescriber::eGCedObject;
d->mAddress = mCurrentAddress;
d->mName.Append(aObjectDescription);
if (aCompartmentAddress) {
@ -2356,7 +2358,8 @@ CCGraphBuilder::AddWeakMapNode(void* aNode)
}
NS_IMETHODIMP_(void)
CCGraphBuilder::NoteWeakMapping(void* aMap, void* aKey, void* aKdelegate, void* aVal)
CCGraphBuilder::NoteWeakMapping(void* aMap, void* aKey, void* aKdelegate,
void* aVal)
{
// Don't try to optimize away the entry here, as we've already attempted to
// do that in TraceWeakMapping in nsXPConnect.
@ -2650,7 +2653,7 @@ public:
if (val.isMarkable()) {
void* thing = val.toGCThing();
if (thing && xpc_GCThingIsGrayCCThing(thing)) {
MOZ_ASSERT(!js::gc::IsInsideNursery((js::gc::Cell *)thing));
MOZ_ASSERT(!js::gc::IsInsideNursery((js::gc::Cell*)thing));
mCollector->GetJSPurpleBuffer()->mValues.AppendElement(val);
}
}
@ -2661,7 +2664,7 @@ public:
{
}
void AppendJSObjectToPurpleBuffer(JSObject *obj) const
void AppendJSObjectToPurpleBuffer(JSObject* obj) const
{
if (obj && xpc_GCThingIsGrayCCThing(obj)) {
MOZ_ASSERT(!js::gc::IsInsideNursery(JS::AsCell(obj)));
@ -2902,9 +2905,10 @@ private:
static void
FloodBlackNode(uint32_t& aWhiteNodeCount, bool& aFailed, PtrInfo* aPi)
{
GraphWalker<ScanBlackVisitor>(ScanBlackVisitor(aWhiteNodeCount, aFailed)).Walk(aPi);
MOZ_ASSERT(aPi->mColor == black || !aPi->WasTraversed(),
"FloodBlackNode should make aPi black");
GraphWalker<ScanBlackVisitor>(ScanBlackVisitor(aWhiteNodeCount,
aFailed)).Walk(aPi);
MOZ_ASSERT(aPi->mColor == black || !aPi->WasTraversed(),
"FloodBlackNode should make aPi black");
}
// Iterate over the WeakMaps. If we mark anything while iterating
@ -3011,13 +3015,16 @@ nsCycleCollector::ScanIncrementalRoots()
// buffer here, so these objects will be suspected and freed in the next CC
// if they are garbage.
bool failed = false;
PurpleScanBlackVisitor purpleScanBlackVisitor(mGraph, mListener, mWhiteNodeCount, failed);
PurpleScanBlackVisitor purpleScanBlackVisitor(mGraph, mListener,
mWhiteNodeCount, failed);
mPurpleBuf.VisitEntries(purpleScanBlackVisitor);
timeLog.Checkpoint("ScanIncrementalRoots::fix purple");
bool hasJSRuntime = !!mJSRuntime;
nsCycleCollectionParticipant* jsParticipant = hasJSRuntime ? mJSRuntime->GCThingParticipant() : nullptr;
nsCycleCollectionParticipant* zoneParticipant = hasJSRuntime ? mJSRuntime->ZoneParticipant() : nullptr;
nsCycleCollectionParticipant* jsParticipant =
hasJSRuntime ? mJSRuntime->GCThingParticipant() : nullptr;
nsCycleCollectionParticipant* zoneParticipant =
hasJSRuntime ? mJSRuntime->ZoneParticipant() : nullptr;
bool hasListener = !!mListener;
NodePool::Enumerator etor(mGraph.mNodes);
@ -3263,7 +3270,8 @@ nsCycleCollector::CollectWhite()
for (uint32_t i = 0; i < count; ++i) {
PtrInfo* pinfo = whiteNodes.ElementAt(i);
MOZ_ASSERT(pinfo->mParticipant, "Unlink shouldn't see objects removed from graph.");
MOZ_ASSERT(pinfo->mParticipant,
"Unlink shouldn't see objects removed from graph.");
pinfo->mParticipant->Unlink(pinfo->mPointer);
#ifdef DEBUG
if (mJSRuntime) {
@ -3275,7 +3283,8 @@ nsCycleCollector::CollectWhite()
for (uint32_t i = 0; i < count; ++i) {
PtrInfo* pinfo = whiteNodes.ElementAt(i);
MOZ_ASSERT(pinfo->mParticipant, "Unroot shouldn't see objects removed from graph.");
MOZ_ASSERT(pinfo->mParticipant,
"Unroot shouldn't see objects removed from graph.");
pinfo->mParticipant->Unroot(pinfo->mPointer);
}
timeLog.Checkpoint("CollectWhite::Unroot");
@ -3476,8 +3485,8 @@ nsCycleCollector::FixGrayBits(bool aForceGC)
}
TimeLog timeLog;
mJSRuntime->GarbageCollect(aForceGC ? JS::gcreason::SHUTDOWN_CC
: JS::gcreason::CC_FORCED);
mJSRuntime->GarbageCollect(aForceGC ? JS::gcreason::SHUTDOWN_CC :
JS::gcreason::CC_FORCED);
timeLog.Checkpoint("GC()");
}
@ -3743,7 +3752,8 @@ nsCycleCollector::BeginCollection(ccType aCCType,
mResults.mMergedZones = mergeZones;
MOZ_ASSERT(!mBuilder, "Forgot to clear mBuilder");
mBuilder = new CCGraphBuilder(mGraph, mResults, mJSRuntime, mListener, mergeZones);
mBuilder = new CCGraphBuilder(mGraph, mResults, mJSRuntime, mListener,
mergeZones);
if (mJSRuntime) {
mJSRuntime->TraverseRoots(*mBuilder);
@ -4105,7 +4115,7 @@ nsCycleCollector_forgetSkippable(bool aRemoveChildlessNodes,
MOZ_ASSERT(data->mCollector);
PROFILER_LABEL("nsCycleCollector", "forgetSkippable",
js::ProfileEntry::Category::CC);
js::ProfileEntry::Category::CC);
TimeLog timeLog;
data->mCollector->ForgetSkippable(aRemoveChildlessNodes,
@ -4155,7 +4165,7 @@ nsCycleCollector_collect(nsICycleCollectorListener* aManualListener)
MOZ_ASSERT(data->mCollector);
PROFILER_LABEL("nsCycleCollector", "collect",
js::ProfileEntry::Category::CC);
js::ProfileEntry::Category::CC);
SliceBudget unlimitedBudget;
data->mCollector->Collect(ManualCC, unlimitedBudget, aManualListener);
@ -4171,7 +4181,7 @@ nsCycleCollector_collectSlice(int64_t aSliceTime)
MOZ_ASSERT(data->mCollector);
PROFILER_LABEL("nsCycleCollector", "collectSlice",
js::ProfileEntry::Category::CC);
js::ProfileEntry::Category::CC);
SliceBudget budget;
if (aSliceTime >= 0) {
@ -4190,7 +4200,7 @@ nsCycleCollector_collectSliceWork(int64_t aSliceWork)
MOZ_ASSERT(data->mCollector);
PROFILER_LABEL("nsCycleCollector", "collectSliceWork",
js::ProfileEntry::Category::CC);
js::ProfileEntry::Category::CC);
SliceBudget budget;
if (aSliceWork >= 0) {
@ -4235,7 +4245,7 @@ nsCycleCollector_shutdown()
if (data) {
MOZ_ASSERT(data->mCollector);
PROFILER_LABEL("nsCycleCollector", "shutdown",
js::ProfileEntry::Category::CC);
js::ProfileEntry::Category::CC);
data->mCollector->Shutdown();
data->mCollector = nullptr;

View File

@ -236,7 +236,8 @@ InitLog()
}
}
enum nsAssertBehavior {
enum nsAssertBehavior
{
NS_ASSERT_UNINITIALIZED,
NS_ASSERT_WARN,
NS_ASSERT_SUSPEND,
@ -511,7 +512,8 @@ Break(const char* aMsg)
static int ignoreDebugger;
if (!ignoreDebugger) {
const char* shouldIgnoreDebugger = getenv("XPCOM_DEBUG_DLG");
ignoreDebugger = 1 + (shouldIgnoreDebugger && !strcmp(shouldIgnoreDebugger, "1"));
ignoreDebugger =
1 + (shouldIgnoreDebugger && !strcmp(shouldIgnoreDebugger, "1"));
}
if ((ignoreDebugger == 2) || !::IsDebuggerPresent()) {
DWORD code = IDRETRY;
@ -587,8 +589,7 @@ nsDebugImpl::Create(nsISupports* aOuter, const nsIID& aIID, void** aInstancePtr)
return NS_ERROR_NO_AGGREGATION;
}
return const_cast<nsDebugImpl*>(&kImpl)->
QueryInterface(aIID, aInstancePtr);
return const_cast<nsDebugImpl*>(&kImpl)->QueryInterface(aIID, aInstancePtr);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -475,8 +475,7 @@ nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
return rv;
}
while (chmod(dirPath.get(), 0777) == -1 && errno == EINTR)
{
while (chmod(dirPath.get(), 0777) == -1 && errno == EINTR) {
}
}
#endif
@ -503,8 +502,7 @@ nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
return rv;
}
while (chmod(path.get(), 0666) == -1 && errno == EINTR)
{
while (chmod(path.get(), 0666) == -1 && errno == EINTR) {
}
#endif

View File

@ -11,7 +11,8 @@
NS_IMPL_ISUPPORTS(nsErrorService, nsIErrorService)
nsresult
nsErrorService::Create(nsISupports* aOuter, const nsIID& aIID, void** aInstancePtr)
nsErrorService::Create(nsISupports* aOuter, const nsIID& aIID,
void** aInstancePtr)
{
if (NS_WARN_IF(aOuter)) {
return NS_ERROR_NO_AGGREGATION;
@ -21,7 +22,8 @@ nsErrorService::Create(nsISupports* aOuter, const nsIID& aIID, void** aInstanceP
}
NS_IMETHODIMP
nsErrorService::RegisterErrorStringBundle(int16_t aErrorModule, const char* aStringBundleURL)
nsErrorService::RegisterErrorStringBundle(int16_t aErrorModule,
const char* aStringBundleURL)
{
mErrorStringBundleURLMap.Put(aErrorModule, new nsCString(aStringBundleURL));
return NS_OK;

View File

@ -37,7 +37,8 @@ nsMacUtilsImpl::GetArchString(nsAString& aArchString)
CFIndex archCount = ::CFArrayGetCount(archList);
for (CFIndex i = 0; i < archCount; i++) {
CFNumberRef arch = static_cast<CFNumberRef>(::CFArrayGetValueAtIndex(archList, i));
CFNumberRef arch =
static_cast<CFNumberRef>(::CFArrayGetValueAtIndex(archList, i));
int archInt = 0;
if (!::CFNumberGetValue(arch, kCFNumberIntType, &archInt)) {

View File

@ -124,7 +124,8 @@ private:
const bool mDumpChildProcesses;
};
NS_IMPL_ISUPPORTS_INHERITED(GCAndCCLogDumpRunnable, nsRunnable, nsIDumpGCAndCCLogsCallback)
NS_IMPL_ISUPPORTS_INHERITED(GCAndCCLogDumpRunnable, nsRunnable,
nsIDumpGCAndCCLogsCallback)
} // anonymous namespace
@ -178,10 +179,9 @@ void doGCCCDump(const uint8_t aRecvSig)
LOG("SignalWatcher(sig %d) dispatching GC/CC log runnable.", aRecvSig);
// Dump GC and CC logs (from the main thread).
nsRefPtr<GCAndCCLogDumpRunnable> runnable =
new GCAndCCLogDumpRunnable(
/* identifier = */ EmptyString(),
/* allTraces = */ true,
/* dumpChildProcesses = */ true);
new GCAndCCLogDumpRunnable(/* identifier = */ EmptyString(),
/* allTraces = */ true,
/* dumpChildProcesses = */ true);
NS_DispatchToMainThread(runnable);
}
@ -195,7 +195,8 @@ void
doMemoryReport(const nsCString& aInputStr)
{
bool minimize = aInputStr.EqualsLiteral("minimize memory report");
LOG("FifoWatcher(command:%s) dispatching memory report runnable.", aInputStr.get());
LOG("FifoWatcher(command:%s) dispatching memory report runnable.",
aInputStr.get());
nsRefPtr<DumpMemoryInfoToTempDirRunnable> runnable =
new DumpMemoryInfoToTempDirRunnable(/* identifier = */ EmptyString(),
/* anonymize = */ false,
@ -314,7 +315,8 @@ EnsureNonEmptyIdentifier(nsAString& aIdentifier)
// Use XPCOM refcounting to fire |onFinish| when all reference-holders
// (remote dump actors or the |DumpGCAndCCLogsToFile| activation itself)
// have gone away.
class nsDumpGCAndCCLogsCallbackHolder MOZ_FINAL : public nsIDumpGCAndCCLogsCallback
class nsDumpGCAndCCLogsCallbackHolder MOZ_FINAL
: public nsIDumpGCAndCCLogsCallback
{
public:
NS_DECL_ISUPPORTS

View File

@ -1173,7 +1173,8 @@ nsMemoryReporterManager::GetReportsExtended(
}
if (aMinimize) {
rv = MinimizeMemoryUsage(NS_NewRunnableMethod(this, &nsMemoryReporterManager::StartGettingReports));
rv = MinimizeMemoryUsage(NS_NewRunnableMethod(
this, &nsMemoryReporterManager::StartGettingReports));
} else {
rv = StartGettingReports();
}
@ -1186,7 +1187,7 @@ nsMemoryReporterManager::StartGettingReports()
GetReportsState* s = mGetReportsState;
// Get reports for this process.
FILE *parentDMDFile = nullptr;
FILE* parentDMDFile = nullptr;
#ifdef MOZ_DMD
nsresult rv = nsMemoryInfoDumper::OpenDMDFile(s->mDMDDumpIdent, getpid(),
&parentDMDFile);
@ -1200,9 +1201,8 @@ nsMemoryReporterManager::StartGettingReports()
s->mParentDone = true;
// If there are no remaining child processes, we can finish up immediately.
return (s->mNumChildProcessesCompleted >= s->mNumChildProcesses)
? FinishReporting()
: NS_OK;
return (s->mNumChildProcessesCompleted >= s->mNumChildProcesses) ?
FinishReporting() : NS_OK;
}
typedef nsCOMArray<nsIMemoryReporter> MemoryReporterArray;

View File

@ -255,7 +255,7 @@ PrintError(const char* aPrefix)
nullptr,
lastErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPSTR) &lpMsgBuf,
(LPSTR)&lpMsgBuf,
0,
nullptr
);
@ -286,9 +286,8 @@ EnsureWalkThreadReady()
}
unsigned int threadID;
stackWalkThread = (HANDLE)
_beginthreadex(nullptr, 0, WalkStackThread, (void*)readyEvent,
0, &threadID);
stackWalkThread = (HANDLE)_beginthreadex(nullptr, 0, WalkStackThread,
(void*)readyEvent, 0, &threadID);
if (!stackWalkThread) {
PrintError("CreateThread");
::CloseHandle(readyEvent);
@ -455,7 +454,7 @@ WalkStackThread(void* aData)
HANDLE readyEvent = (HANDLE)aData;
::SetEvent(readyEvent);
while ((msgRet = ::GetMessage(&msg, (HWND) - 1, 0, 0)) != 0) {
while ((msgRet = ::GetMessage(&msg, (HWND)-1, 0, 0)) != 0) {
if (msgRet == -1) {
PrintError("GetMessage");
} else {
@ -972,7 +971,7 @@ static void
myinit()
{
if (! initialized) {
if (!initialized) {
#ifndef __GNUC__
void *handle;
const char *libdem = "libdemangle.so.1";

View File

@ -202,7 +202,8 @@ nsSystemInfo::Init()
versionDouble >= 6.2);
NS_ENSURE_SUCCESS(rv, rv);
#else
rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16("hasWindowsTouchInterface"), false);
rv = SetPropertyAsBool(NS_ConvertASCIItoUTF16("hasWindowsTouchInterface"),
false);
NS_ENSURE_SUCCESS(rv, rv);
#endif
@ -235,7 +236,8 @@ nsSystemInfo::Init()
if (NS_FAILED(GetProfileHDDInfo())) {
// We might have been called before profile-do-change. We'll observe that
// event so that we can fill this in later.
nsCOMPtr<nsIObserverService> obsService = do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIObserverService> obsService =
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -263,7 +265,8 @@ nsSystemInfo::Init()
#if defined(MOZ_WIDGET_GTK)
// This must be done here because NSPR can only separate OS's when compiled, not libraries.
char* gtkver = PR_smprintf("GTK %u.%u.%u", gtk_major_version, gtk_minor_version, gtk_micro_version);
char* gtkver = PR_smprintf("GTK %u.%u.%u", gtk_major_version,
gtk_minor_version, gtk_micro_version);
if (gtkver) {
rv = SetPropertyAsACString(NS_LITERAL_STRING("secondaryLibrary"),
nsDependentCString(gtkver));
@ -396,8 +399,8 @@ nsSystemInfo::Observe(nsISupports* aSubject, const char* aTopic,
{
if (!strcmp(aTopic, "profile-do-change")) {
nsresult rv;
nsCOMPtr<nsIObserverService> obsService = do_GetService(
NS_OBSERVERSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIObserverService> obsService =
do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -425,7 +425,8 @@ public:
(aStats->mCreates != aStats->mDestroys));
}
bool PrintDumpHeader(FILE* aOut, const char* aMsg, nsTraceRefcnt::StatisticsType aType)
bool PrintDumpHeader(FILE* aOut, const char* aMsg,
nsTraceRefcnt::StatisticsType aType)
{
fprintf(aOut, "\n== BloatView: %s, %s process %d\n", aMsg,
XRE_ChildProcessTypeToString(XRE_GetProcessType()), getpid());
@ -447,7 +448,8 @@ public:
void Dump(int aIndex, FILE* aOut, nsTraceRefcnt::StatisticsType aType)
{
nsTraceRefcntStats* stats = (aType == nsTraceRefcnt::NEW_STATS) ? &mNewStats : &mAllStats;
nsTraceRefcntStats* stats =
(aType == nsTraceRefcnt::NEW_STATS) ? &mNewStats : &mAllStats;
if (gLogLeaksOnly && !HaveLeaks(stats)) {
return;
}
@ -573,7 +575,7 @@ DumpSerialNumbers(PLHashEntry* aHashEntry, int aIndex, void* aClosure)
}
template <>
template<>
class nsDefaultComparator<BloatEntry*, BloatEntry*>
{
public:
@ -677,7 +679,9 @@ LogThisType(const char* aTypeName)
static intptr_t
GetSerialNumber(void* aPtr, bool aCreate)
{
PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr);
PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers,
PLHashNumber(NS_PTR_TO_INT32(aPtr)),
aPtr);
if (hep && *hep) {
return reinterpret_cast<serialNumberRecord*>((*hep)->value)->serialNumber;
} else if (aCreate) {
@ -685,7 +689,8 @@ GetSerialNumber(void* aPtr, bool aCreate)
record->serialNumber = ++gNextSerialNumber;
record->refCount = 0;
record->COMPtrCount = 0;
PL_HashTableRawAdd(gSerialNumbers, hep, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr, reinterpret_cast<void*>(record));
PL_HashTableRawAdd(gSerialNumbers, hep, PLHashNumber(NS_PTR_TO_INT32(aPtr)),
aPtr, reinterpret_cast<void*>(record));
return gNextSerialNumber;
}
return 0;
@ -694,7 +699,9 @@ GetSerialNumber(void* aPtr, bool aCreate)
static int32_t*
GetRefCount(void* aPtr)
{
PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr);
PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers,
PLHashNumber(NS_PTR_TO_INT32(aPtr)),
aPtr);
if (hep && *hep) {
return &((reinterpret_cast<serialNumberRecord*>((*hep)->value))->refCount);
} else {
@ -706,7 +713,9 @@ GetRefCount(void* aPtr)
static int32_t*
GetCOMPtrCount(void* aPtr)
{
PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers, PLHashNumber(NS_PTR_TO_INT32(aPtr)), aPtr);
PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers,
PLHashNumber(NS_PTR_TO_INT32(aPtr)),
aPtr);
if (hep && *hep) {
return &((reinterpret_cast<serialNumberRecord*>((*hep)->value))->COMPtrCount);
}
@ -959,7 +968,7 @@ PrintStackFrame(void* aPC, void* aSP, void* aClosure)
static void
PrintStackFrameCached(void* aPC, void* aSP, void* aClosure)
{
CodeAddressServiceWriter *writer = static_cast<CodeAddressServiceWriter*>(aClosure);
auto writer = static_cast<CodeAddressServiceWriter*>(aClosure);
gCodeAddressService->WriteLocation(*writer, aPC);
}
#endif
@ -983,8 +992,8 @@ nsTraceRefcnt::WalkTheStackCached(FILE* aStream)
gCodeAddressService = new WalkTheStackCodeAddressService();
}
CodeAddressServiceWriter writer(aStream);
NS_StackWalk(PrintStackFrameCached, /* skipFrames */ 2, /* maxFrames */ 0, &writer,
0, nullptr);
NS_StackWalk(PrintStackFrameCached, /* skipFrames */ 2, /* maxFrames */ 0,
&writer, 0, nullptr);
#endif
}
@ -1092,7 +1101,7 @@ LogTerm()
EXPORT_XPCOM_API(void)
NS_LogAddRef(void* aPtr, nsrefcnt aRefcnt,
const char* aClazz, uint32_t aClassSize)
const char* aClass, uint32_t aClassSize)
{
#ifdef NS_IMPL_REFCNT_LOGGING
ASSERT_ACTIVITY_IS_LEGAL;
@ -1103,7 +1112,7 @@ NS_LogAddRef(void* aPtr, nsrefcnt aRefcnt,
LOCK_TRACELOG();
if (gBloatLog) {
BloatEntry* entry = GetBloatEntry(aClazz, aClassSize);
BloatEntry* entry = GetBloatEntry(aClass, aClassSize);
if (entry) {
entry->AddRef(aRefcnt);
}
@ -1112,7 +1121,7 @@ NS_LogAddRef(void* aPtr, nsrefcnt aRefcnt,
// Here's the case where MOZ_COUNT_CTOR was not used,
// yet we still want to see creation information:
bool loggingThisType = (!gTypesToLog || LogThisType(aClazz));
bool loggingThisType = (!gTypesToLog || LogThisType(aClass));
intptr_t serialno = 0;
if (gSerialNumbers && loggingThisType) {
serialno = GetSerialNumber(aPtr, aRefcnt == 1);
@ -1129,14 +1138,15 @@ NS_LogAddRef(void* aPtr, nsrefcnt aRefcnt,
bool loggingThisObject = (!gObjectsToLog || LogThisObj(serialno));
if (aRefcnt == 1 && gAllocLog && loggingThisType && loggingThisObject) {
fprintf(gAllocLog, "\n<%s> 0x%08X %" PRIdPTR " Create\n",
aClazz, NS_PTR_TO_INT32(aPtr), serialno);
aClass, NS_PTR_TO_INT32(aPtr), serialno);
nsTraceRefcnt::WalkTheStackCached(gAllocLog);
}
if (gRefcntsLog && loggingThisType && loggingThisObject) {
// Can't use PR_LOG(), b/c it truncates the line
fprintf(gRefcntsLog,
"\n<%s> 0x%08X %" PRIuPTR " AddRef %" PRIuPTR "\n", aClazz, NS_PTR_TO_INT32(aPtr), serialno, aRefcnt);
"\n<%s> 0x%08X %" PRIuPTR " AddRef %" PRIuPTR "\n",
aClass, NS_PTR_TO_INT32(aPtr), serialno, aRefcnt);
nsTraceRefcnt::WalkTheStackCached(gRefcntsLog);
fflush(gRefcntsLog);
}
@ -1146,7 +1156,7 @@ NS_LogAddRef(void* aPtr, nsrefcnt aRefcnt,
}
EXPORT_XPCOM_API(void)
NS_LogRelease(void* aPtr, nsrefcnt aRefcnt, const char* aClazz)
NS_LogRelease(void* aPtr, nsrefcnt aRefcnt, const char* aClass)
{
#ifdef NS_IMPL_REFCNT_LOGGING
ASSERT_ACTIVITY_IS_LEGAL;
@ -1157,13 +1167,13 @@ NS_LogRelease(void* aPtr, nsrefcnt aRefcnt, const char* aClazz)
LOCK_TRACELOG();
if (gBloatLog) {
BloatEntry* entry = GetBloatEntry(aClazz, 0);
BloatEntry* entry = GetBloatEntry(aClass, 0);
if (entry) {
entry->Release(aRefcnt);
}
}
bool loggingThisType = (!gTypesToLog || LogThisType(aClazz));
bool loggingThisType = (!gTypesToLog || LogThisType(aClass));
intptr_t serialno = 0;
if (gSerialNumbers && loggingThisType) {
serialno = GetSerialNumber(aPtr, false);
@ -1181,7 +1191,8 @@ NS_LogRelease(void* aPtr, nsrefcnt aRefcnt, const char* aClazz)
if (gRefcntsLog && loggingThisType && loggingThisObject) {
// Can't use PR_LOG(), b/c it truncates the line
fprintf(gRefcntsLog,
"\n<%s> 0x%08X %" PRIuPTR " Release %" PRIuPTR "\n", aClazz, NS_PTR_TO_INT32(aPtr), serialno, aRefcnt);
"\n<%s> 0x%08X %" PRIuPTR " Release %" PRIuPTR "\n", aClass,
NS_PTR_TO_INT32(aPtr), serialno, aRefcnt);
nsTraceRefcnt::WalkTheStackCached(gRefcntsLog);
fflush(gRefcntsLog);
}
@ -1192,7 +1203,7 @@ NS_LogRelease(void* aPtr, nsrefcnt aRefcnt, const char* aClazz)
if (aRefcnt == 0 && gAllocLog && loggingThisType && loggingThisObject) {
fprintf(gAllocLog,
"\n<%s> 0x%08X %" PRIdPTR " Destroy\n",
aClazz, NS_PTR_TO_INT32(aPtr), serialno);
aClass, NS_PTR_TO_INT32(aPtr), serialno);
nsTraceRefcnt::WalkTheStackCached(gAllocLog);
}

View File

@ -17,7 +17,7 @@
#include "nsUUIDGenerator.h"
#ifdef ANDROID
extern "C" NS_EXPORT void arc4random_buf(void *, size_t);
extern "C" NS_EXPORT void arc4random_buf(void*, size_t);
#endif
using namespace mozilla;

View File

@ -11,7 +11,8 @@
NS_IMPL_ISUPPORTS(nsVersionComparatorImpl, nsIVersionComparator)
NS_IMETHODIMP
nsVersionComparatorImpl::Compare(const nsACString& aStr1, const nsACString& aStr2,
nsVersionComparatorImpl::Compare(const nsACString& aStr1,
const nsACString& aStr2,
int32_t* aResult)
{
*aResult = mozilla::CompareVersions(PromiseFlatCString(aStr1).get(),

View File

@ -447,8 +447,9 @@ CountingAllocatorBase<VPXReporter>::sAmount(0);
#endif /* MOZ_VPX */
#ifdef MOZ_WEBM
class NesteggReporter MOZ_FINAL : public nsIMemoryReporter
, public CountingAllocatorBase<NesteggReporter>
class NesteggReporter MOZ_FINAL
: public nsIMemoryReporter
, public CountingAllocatorBase<NesteggReporter>
{
public:
NS_DECL_ISUPPORTS
@ -817,7 +818,7 @@ ShutdownXPCOM(nsIServiceManager* aServMgr)
nsRefPtr<nsObserverService> observerService;
CallGetService("@mozilla.org/observer-service;1",
(nsObserverService**) getter_AddRefs(observerService));
(nsObserverService**)getter_AddRefs(observerService));
if (observerService) {
observerService->NotifyObservers(nullptr,

View File

@ -225,7 +225,7 @@ LogMessageWithContext(FileLocation& aFile,
// This can happen early in component registration. Fall back to a
// generic console message.
LogMessage("Warning: in '%s', line %i: %s", file.get(),
aLineNumber, (char*) formatted);
aLineNumber, (char*)formatted);
return;
}

View File

@ -213,12 +213,7 @@ EntryEnumerator::Create(nsTHashtable<CategoryLeaf>& aTable)
CategoryNode*
CategoryNode::Create(PLArenaPool* aArena)
{
CategoryNode* node = new(aArena) CategoryNode();
if (!node) {
return nullptr;
}
return node;
return new (aArena) CategoryNode();
}
CategoryNode::~CategoryNode()

View File

@ -35,8 +35,7 @@ namespace mozilla {
//
// static members
const char* const BlockingResourceBase::kResourceTypeName[] =
{
const char* const BlockingResourceBase::kResourceTypeName[] = {
// needs to be kept in sync with BlockingResourceType
"Mutex", "ReentrantMonitor", "CondVar"
};
@ -88,7 +87,8 @@ BlockingResourceBase::GetStackTrace(AcquisitionState& aState)
* some info is written into |aOut|
*/
bool
PrintCycle(const BlockingResourceBase::DDT::ResourceAcquisitionArray* aCycle, nsACString& aOut)
PrintCycle(const BlockingResourceBase::DDT::ResourceAcquisitionArray* aCycle,
nsACString& aOut)
{
NS_ASSERTION(aCycle->Length() > 1, "need > 1 element for cycle!");
@ -97,12 +97,15 @@ PrintCycle(const BlockingResourceBase::DDT::ResourceAcquisitionArray* aCycle, ns
fputs("=== Cyclical dependency starts at\n", stderr);
aOut += "Cyclical dependency starts at\n";
const BlockingResourceBase::DDT::ResourceAcquisitionArray::elem_type res = aCycle->ElementAt(0);
const BlockingResourceBase::DDT::ResourceAcquisitionArray::elem_type res =
aCycle->ElementAt(0);
maybeImminent &= res->Print(aOut);
BlockingResourceBase::DDT::ResourceAcquisitionArray::index_type i;
BlockingResourceBase::DDT::ResourceAcquisitionArray::size_type len = aCycle->Length();
const BlockingResourceBase::DDT::ResourceAcquisitionArray::elem_type* it = 1 + aCycle->Elements();
BlockingResourceBase::DDT::ResourceAcquisitionArray::size_type len =
aCycle->Length();
const BlockingResourceBase::DDT::ResourceAcquisitionArray::elem_type* it =
1 + aCycle->Elements();
for (i = 1; i < len - 1; ++i, ++it) {
fputs("\n--- Next dependency:\n", stderr);
aOut += "\nNext dependency:\n";

View File

@ -142,8 +142,8 @@ mozilla::ReadSysFile(
ssize_t bytesRead;
size_t offset = 0;
do {
bytesRead = MOZ_TEMP_FAILURE_RETRY(
read(fd, aBuf + offset, aBufSize - offset));
bytesRead = MOZ_TEMP_FAILURE_RETRY(read(fd, aBuf + offset,
aBufSize - offset));
if (bytesRead == -1) {
return false;
}

View File

@ -16,8 +16,9 @@ nsQueryInterface::operator()(const nsIID& aIID, void** aAnswer) const
NS_ASSERTION(NS_SUCCEEDED(status),
"interface not found---were you expecting that?");
#endif
} else
} else {
status = NS_ERROR_NULL_POINTER;
}
return status;
}
@ -32,8 +33,9 @@ nsQueryInterfaceWithError::operator()(const nsIID& aIID, void** aAnswer) const
NS_ASSERTION(NS_SUCCEEDED(status),
"interface not found---were you expecting that?");
#endif
} else
} else {
status = NS_ERROR_NULL_POINTER;
}
if (mErrorPtr) {
*mErrorPtr = status;

View File

@ -69,7 +69,7 @@ nsDeque::~nsDeque()
printf("Capacity: %i\n", mCapacity);
static int mCaps[15] = {0};
switch(mCapacity) {
switch (mCapacity) {
case 4: mCaps[0]++; break;
case 8: mCaps[1]++; break;
case 16: mCaps[2]++; break;
@ -366,7 +366,8 @@ nsDeque::RemoveObjectAt(int32_t aIndex)
// "Shuffle down" all elements in the array by 1, overwritting the element
// being removed.
for (int32_t i = aIndex; i < mSize; ++i) {
mData[modulus(mOrigin + i, mCapacity)] = mData[modulus(mOrigin + i + 1, mCapacity)];
mData[modulus(mOrigin + i, mCapacity)] =
mData[modulus(mOrigin + i + 1, mCapacity)];
}
mSize--;

View File

@ -227,7 +227,7 @@ nsUnionEnumerator::HasMoreElements(bool* aResult)
return NS_OK;
}
if (! mAtSecond) {
if (!mAtSecond) {
rv = mFirstEnumerator->HasMoreElements(aResult);
if (NS_FAILED(rv)) {
return rv;
@ -266,7 +266,7 @@ nsUnionEnumerator::GetNext(nsISupports** aResult)
return NS_ERROR_UNEXPECTED;
}
if (! mAtSecond) {
if (!mAtSecond) {
return mFirstEnumerator->GetNext(aResult);
}
@ -279,9 +279,9 @@ NS_NewUnionEnumerator(nsISimpleEnumerator** aResult,
nsISimpleEnumerator* aSecondEnumerator)
{
*aResult = nullptr;
if (! aFirstEnumerator) {
if (!aFirstEnumerator) {
*aResult = aSecondEnumerator;
} else if (! aSecondEnumerator) {
} else if (!aSecondEnumerator) {
*aResult = aFirstEnumerator;
} else {
nsUnionEnumerator* enumer = new nsUnionEnumerator(aFirstEnumerator,

View File

@ -258,8 +258,9 @@ PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps,
aTable->entryCount = aTable->removedCount = 0;
aTable->generation = 0;
uint32_t nbytes;
if (!SizeOfEntryStore(capacity, aEntrySize, &nbytes))
return false; // overflowed
if (!SizeOfEntryStore(capacity, aEntrySize, &nbytes)) {
return false; // overflowed
}
aTable->entryStore = (char*)aOps->allocTable(aTable, nbytes);
if (!aTable->entryStore) {

View File

@ -19,7 +19,7 @@ const unsigned char* base =
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
template <typename T>
template<typename T>
static void
Encode3to4(const unsigned char* aSrc, T* aDest)
{
@ -37,7 +37,7 @@ Encode3to4(const unsigned char* aSrc, T* aDest)
}
}
template <typename T>
template<typename T>
static void
Encode2to4(const unsigned char* aSrc, T* aDest)
{
@ -47,7 +47,7 @@ Encode2to4(const unsigned char* aSrc, T* aDest)
aDest[3] = (unsigned char)'=';
}
template <typename T>
template<typename T>
static void
Encode1to4(const unsigned char* aSrc, T* aDest)
{
@ -57,7 +57,7 @@ Encode1to4(const unsigned char* aSrc, T* aDest)
aDest[3] = (unsigned char)'=';
}
template <typename T>
template<typename T>
static void
Encode(const unsigned char* aSrc, uint32_t aSrcLen, T* aDest)
{
@ -84,7 +84,7 @@ Encode(const unsigned char* aSrc, uint32_t aSrcLen, T* aDest)
// END base64 encode code copied and modified from NSPR.
template <typename T>
template<typename T>
struct EncodeInputStream_State
{
unsigned char c[3];
@ -92,7 +92,7 @@ struct EncodeInputStream_State
typename T::char_type* buffer;
};
template <typename T>
template<typename T>
NS_METHOD
EncodeInputStream_Encoder(nsIInputStream* aStream,
void* aClosure,
@ -152,7 +152,7 @@ EncodeInputStream_Encoder(nsIInputStream* aStream,
return NS_OK;
}
template <typename T>
template<typename T>
nsresult
EncodeInputStream(nsIInputStream* aInputStream,
T& aDest,

View File

@ -153,14 +153,16 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent,
}
#ifdef MOZ_WIDGET_COCOA
else if (nsCRT::strcmp(aProp, NS_MACOSX_USER_PLUGIN_DIR) == 0) {
if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false,
&fileRef) == noErr) {
rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv)) {
localFile = macFile;
}
}
} else if (nsCRT::strcmp(aProp, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0) {
if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) {
if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false,
&fileRef) == noErr) {
rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile));
if (NS_SUCCEEDED(rv)) {
localFile = macFile;
@ -169,7 +171,8 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent,
} else if (nsCRT::strcmp(aProp, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0) {
static const char* const java2PluginDirPath =
"/System/Library/Java/Support/Deploy.bundle/Contents/Resources/";
rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), true, getter_AddRefs(localFile));
rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), true,
getter_AddRefs(localFile));
}
#else
else if (nsCRT::strcmp(aProp, NS_ENV_PLUGINS_DIR) == 0) {
@ -294,7 +297,8 @@ nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
#if defined(MOZ_WIDGET_COCOA)
FSRef fsRef;
OSType folderType = aLocal ? (OSType) kCachedDataFolderType : (OSType) kDomainLibraryFolderType;
OSType folderType = aLocal ? (OSType)kCachedDataFolderType :
(OSType)kDomainLibraryFolderType;
OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef);
if (err) {
return NS_ERROR_FAILURE;
@ -320,7 +324,8 @@ nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile,
return rv;
}
#elif defined(XP_UNIX)
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true, getter_AddRefs(localDir));
rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true,
getter_AddRefs(localDir));
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -826,7 +826,7 @@ nsBinaryInputStream::ReadByteArray(uint32_t aLength, uint8_t** aResult)
NS_IMETHODIMP
nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength,
JS::Handle<JS::Value> aBuffer,
JSContext* aCx, uint32_t *rLength)
JSContext* aCx, uint32_t* aReadLength)
{
if (!aBuffer.isObject()) {
return NS_ERROR_FAILURE;
@ -850,7 +850,7 @@ nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength,
UniquePtr<char[]> buf = MakeUnique<char[]>(bufSize);
uint32_t remaining = aLength;
*rLength = 0;
*aReadLength = 0;
do {
// Read data into temporary buffer.
uint32_t bytesRead;
@ -870,7 +870,7 @@ nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength,
return NS_ERROR_FAILURE;
}
*rLength += bytesRead;
*aReadLength += bytesRead;
PodCopy(data, buf.get(), bytesRead);
remaining -= bytesRead;

View File

@ -77,7 +77,8 @@ nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
if (dirService) {
nsCOMPtr <nsIFile> aLocalFile;
dirService->Get(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(aLocalFile));
dirService->Get(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(aLocalFile));
if (aLocalFile) {
*aFile = aLocalFile;
NS_ADDREF(*aFile);
@ -86,8 +87,9 @@ nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile)
}
nsLocalFile* localFile = new nsLocalFile;
if (localFile == nullptr)
if (!localFile) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(localFile);
#ifdef XP_WIN
@ -474,7 +476,8 @@ nsDirectoryService::RegisterCategoryProviders()
strings->GetNext(entry);
nsXPIDLCString contractID;
catman->GetCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, entry.get(), getter_Copies(contractID));
catman->GetCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, entry.get(),
getter_Copies(contractID));
if (contractID) {
nsCOMPtr<nsIDirectoryServiceProvider> provider = do_GetService(contractID.get());

View File

@ -289,7 +289,8 @@ nsLinebreakConverter::ConvertLineBreaks(const char* aSrc,
char* resultString;
if (aSrcBreaks == eLinebreakAny) {
resultString = ConvertUnknownBreaks(aSrc, sourceLen, GetLinebreakString(aDestBreaks));
resultString = ConvertUnknownBreaks(aSrc, sourceLen,
GetLinebreakString(aDestBreaks));
} else
resultString = ConvertBreaks(aSrc, sourceLen,
GetLinebreakString(aSrcBreaks),
@ -376,7 +377,8 @@ nsLinebreakConverter::ConvertUnicharLineBreaks(const char16_t* aSrc,
char16_t* resultString;
if (aSrcBreaks == eLinebreakAny) {
resultString = ConvertUnknownBreaks(aSrc, bufLen, GetLinebreakString(aDestBreaks));
resultString = ConvertUnknownBreaks(aSrc, bufLen,
GetLinebreakString(aDestBreaks));
} else
resultString = ConvertBreaks(aSrc, bufLen, GetLinebreakString(aSrcBreaks),
GetLinebreakString(aDestBreaks));

View File

@ -241,9 +241,11 @@ nsLocalFile::GetRelativeDescriptor(nsIFile* aFromFile, nsACString& aResult)
return NS_ERROR_FAILURE;
}
for (nodeIndex = 0; nodeIndex < thisNodeCnt && nodeIndex < fromNodeCnt; ++nodeIndex) {
for (nodeIndex = 0; nodeIndex < thisNodeCnt &&
nodeIndex < fromNodeCnt; ++nodeIndex) {
#ifdef XP_WIN
if (_wcsicmp(char16ptr_t(thisNodes[nodeIndex]), char16ptr_t(fromNodes[nodeIndex]))) {
if (_wcsicmp(char16ptr_t(thisNodes[nodeIndex]),
char16ptr_t(fromNodes[nodeIndex]))) {
break;
}
#else

View File

@ -129,7 +129,8 @@ nsDirEnumeratorUnix::~nsDirEnumeratorUnix()
Close();
}
NS_IMPL_ISUPPORTS(nsDirEnumeratorUnix, nsISimpleEnumerator, nsIDirectoryEnumerator)
NS_IMPL_ISUPPORTS(nsDirEnumeratorUnix, nsISimpleEnumerator,
nsIDirectoryEnumerator)
NS_IMETHODIMP
nsDirEnumeratorUnix::Init(nsLocalFile* aParent,
@ -394,7 +395,7 @@ nsLocalFile::OpenNSPRFileDesc(int32_t aFlags, int32_t aMode,
PRFileDesc** aResult)
{
*aResult = PR_Open(mPath.get(), aFlags, aMode);
if (! *aResult) {
if (!*aResult) {
return NS_ErrorAccordingToNSPR();
}
@ -415,7 +416,7 @@ NS_IMETHODIMP
nsLocalFile::OpenANSIFileDesc(const char* aMode, FILE** aResult)
{
*aResult = fopen(mPath.get(), aMode);
if (! *aResult) {
if (!*aResult) {
return NS_ERROR_FAILURE;
}
@ -1407,7 +1408,8 @@ nsLocalFile::GetDiskSpaceAvailable(int64_t* aDiskSpaceAvailable)
&& dq.dqb_bhardlimit) {
int64_t QuotaSpaceAvailable = 0;
if (dq.dqb_bhardlimit > dq.dqb_curspace) {
QuotaSpaceAvailable = int64_t(fs_buf.F_BSIZE * (dq.dqb_bhardlimit - dq.dqb_curspace));
QuotaSpaceAvailable =
int64_t(fs_buf.F_BSIZE * (dq.dqb_bhardlimit - dq.dqb_curspace));
}
if (QuotaSpaceAvailable < *aDiskSpaceAvailable) {
*aDiskSpaceAvailable = QuotaSpaceAvailable;
@ -1949,7 +1951,8 @@ nsLocalFile::SetPersistentDescriptor(const nsACString& aPersistentDescriptor)
Boolean changed;
FSRef resolvedFSRef;
OSErr err = ::FSResolveAlias(nullptr, (AliasHandle)newHandle, &resolvedFSRef, &changed);
OSErr err = ::FSResolveAlias(nullptr, (AliasHandle)newHandle, &resolvedFSRef,
&changed);
rv = MacErrorMapper(err);
DisposeHandle(newHandle);
@ -1968,7 +1971,8 @@ nsLocalFile::Reveal()
{
#ifdef MOZ_WIDGET_GTK
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
nsCOMPtr<nsIGnomeVFSService> gnomevfs =
do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
if (!giovfs && !gnomevfs) {
return NS_ERROR_FAILURE;
}
@ -1986,7 +1990,8 @@ nsLocalFile::Reveal()
{
return gnomevfs->ShowURIForInput(mPath);
}
} else if (giovfs && NS_SUCCEEDED(giovfs->OrgFreedesktopFileManager1ShowItems(mPath))) {
} else if (giovfs &&
NS_SUCCEEDED(giovfs->OrgFreedesktopFileManager1ShowItems(mPath))) {
return NS_OK;
} else {
nsCOMPtr<nsIFile> parentDir;
@ -2022,7 +2027,8 @@ nsLocalFile::Launch()
{
#ifdef MOZ_WIDGET_GTK
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
nsCOMPtr<nsIGnomeVFSService> gnomevfs =
do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
if (giovfs) {
return giovfs->ShowURIForInput(mPath);
} else if (gnomevfs) {
@ -2403,7 +2409,8 @@ nsLocalFile::GetFSSpec(FSSpec* aResult)
FSRef fsRef;
nsresult rv = GetFSRef(&fsRef);
if (NS_SUCCEEDED(rv)) {
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNone, nullptr, nullptr, aResult, nullptr);
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNone, nullptr, nullptr,
aResult, nullptr);
return MacErrorMapper(err);
}
@ -2430,7 +2437,8 @@ nsLocalFile::GetFileSizeWithResFork(int64_t* aFileSizeWithResFork)
return MacErrorMapper(err);
}
*aFileSizeWithResFork = catalogInfo.dataLogicalSize + catalogInfo.rsrcLogicalSize;
*aFileSizeWithResFork =
catalogInfo.dataLogicalSize + catalogInfo.rsrcLogicalSize;
return NS_OK;
}

View File

@ -409,10 +409,10 @@ ShortcutResolver::SetShortcut(bool aUpdateExisting,
// Since we reuse our IPersistFile, we have to clear out any values that
// may be left over from previous calls to SetShortcut.
if (FAILED(mShellLink->SetWorkingDirectory(L""))
|| FAILED(mShellLink->SetArguments(L""))
|| FAILED(mShellLink->SetDescription(L""))
|| FAILED(mShellLink->SetIconLocation(L"", 0))) {
if (FAILED(mShellLink->SetWorkingDirectory(L"")) ||
FAILED(mShellLink->SetArguments(L"")) ||
FAILED(mShellLink->SetDescription(L"")) ||
FAILED(mShellLink->SetIconLocation(L"", 0))) {
return NS_ERROR_FAILURE;
}
}
@ -569,7 +569,8 @@ IsShortcutPath(const nsAString& aPath)
// workaround last beyond the switch, |PRFilePrivate| and |_MDFileDesc|
// need to be changed to match the definitions for WinNT.
//-----------------------------------------------------------------------------
typedef enum {
typedef enum
{
_PR_TRI_TRUE = 1,
_PR_TRI_FALSE = 0,
_PR_TRI_UNKNOWN = -1
@ -1006,8 +1007,9 @@ nsLocalFile::nsLocalFileConstructor(nsISupports* aOuter, const nsIID& aIID,
}
nsLocalFile* inst = new nsLocalFile();
if (inst == nullptr)
if (!inst) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = inst->QueryInterface(aIID, aInstancePtr);
if (NS_FAILED(rv)) {
@ -1417,9 +1419,9 @@ nsLocalFile::AppendInternal(const nsAFlatString& aNode,
}
// check the relative path for validity
if (aNode.First() == L'\\' // can't start with an '\'
|| aNode.FindChar(L'/') != kNotFound // can't contain /
|| aNode.EqualsASCII("..")) { // can't be ..
if (aNode.First() == L'\\' || // can't start with an '\'
aNode.FindChar(L'/') != kNotFound || // can't contain /
aNode.EqualsASCII("..")) { // can't be ..
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
}
@ -1696,8 +1698,8 @@ nsLocalFile::GetVersionInfoField(const char* aField, nsAString& aResult)
rv = NS_ERROR_FAILURE;
const WCHAR* path = mFollowSymlinks ? mResolvedPath.get()
: mWorkingPath.get();
const WCHAR* path =
mFollowSymlinks ? mResolvedPath.get() : mWorkingPath.get();
DWORD dummy;
DWORD size = ::GetFileVersionInfoSizeW(path, &dummy);
@ -1720,8 +1722,7 @@ nsLocalFile::GetVersionInfoField(const char* aField, nsAString& aResult)
wchar_t subBlock[MAX_PATH];
_snwprintf(subBlock, MAX_PATH,
L"\\StringFileInfo\\%04x%04x\\%s",
(i == 0 ? translate[0].wLanguage
: ::GetUserDefaultLangID()),
(i == 0 ? translate[0].wLanguage : ::GetUserDefaultLangID()),
translate[0].wCodePage,
NS_ConvertASCIItoUTF16(
nsDependentCString(aField)).get());
@ -1995,8 +1996,9 @@ nsLocalFile::CopyMove(nsIFile* aParentDir, const nsAString& aNewName,
newParentDir->GetTarget(target);
nsCOMPtr<nsIFile> realDest = new nsLocalFile();
if (realDest == nullptr)
if (!realDest) {
return NS_ERROR_OUT_OF_MEMORY;
}
rv = realDest->InitWithPath(target);
@ -2268,7 +2270,7 @@ nsLocalFile::Load(PRLibrary** aResult)
return rv;
}
if (! isFile) {
if (!isFile) {
return NS_ERROR_FILE_IS_DIRECTORY;
}
@ -2755,7 +2757,8 @@ nsLocalFile::GetParent(nsIFile** aParent)
}
nsCOMPtr<nsIFile> localFile;
nsresult rv = NS_NewLocalFile(parentPath, mFollowSymlinks, getter_AddRefs(localFile));
nsresult rv = NS_NewLocalFile(parentPath, mFollowSymlinks,
getter_AddRefs(localFile));
if (NS_FAILED(rv)) {
return rv;
@ -3340,8 +3343,9 @@ nsresult
NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks, nsIFile** aResult)
{
nsLocalFile* file = new nsLocalFile();
if (file == nullptr)
if (!file) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(file);
file->SetFollowLinks(aFollowLinks);

View File

@ -150,7 +150,8 @@ SeekableStreamAtBeginning(nsIInputStream* aStream)
NS_IMETHODIMP
nsMultiplexInputStream::AppendStream(nsIInputStream* aStream)
{
NS_ASSERTION(SeekableStreamAtBeginning(aStream), "Appended stream not at beginning.");
NS_ASSERTION(SeekableStreamAtBeginning(aStream),
"Appended stream not at beginning.");
return mStreams.AppendElement(aStream) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -158,7 +159,8 @@ nsMultiplexInputStream::AppendStream(nsIInputStream* aStream)
NS_IMETHODIMP
nsMultiplexInputStream::InsertStream(nsIInputStream* aStream, uint32_t aIndex)
{
NS_ASSERTION(SeekableStreamAtBeginning(aStream), "Inserted stream not at beginning.");
NS_ASSERTION(SeekableStreamAtBeginning(aStream),
"Inserted stream not at beginning.");
mStreams.InsertElementAt(aIndex, aStream);
if (mCurrentStream > aIndex ||
(mCurrentStream == aIndex && mStartedReadingCurrent)) {

View File

@ -56,7 +56,8 @@ nsScriptableInputStream::Read(uint32_t aCount, char** aResult)
}
// bug716556 - Ensure count+1 doesn't overflow
uint32_t count = XPCOM_MIN((uint32_t)XPCOM_MIN<uint64_t>(count64, aCount), UINT32_MAX - 1);
uint32_t count =
XPCOM_MIN((uint32_t)XPCOM_MIN<uint64_t>(count64, aCount), UINT32_MAX - 1);
buffer = (char*)moz_malloc(count + 1); // make room for '\0'
if (!buffer) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -479,7 +479,7 @@ nsStorageInputStream::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure,
count = XPCOM_MIN(availableInSegment, remainingCapacity);
rv = aWriter(this, aClosure, cur + mReadCursor, aCount - remainingCapacity,
count, &bytesConsumed);
count, &bytesConsumed);
if (NS_FAILED(rv) || (bytesConsumed == 0)) {
break;
}
@ -609,7 +609,8 @@ nsStorageInputStream::Serialize(InputStreamParams& aParams, FileDescriptorArray&
}
bool
nsStorageInputStream::Deserialize(const InputStreamParams& aParams, const FileDescriptorArray&)
nsStorageInputStream::Deserialize(const InputStreamParams& aParams,
const FileDescriptorArray&)
{
NS_NOTREACHED("We should never attempt to deserialize a storage input stream.");
return false;

View File

@ -616,8 +616,7 @@ NS_AsyncCopy(nsIInputStream* aSource,
aCloseSource, aCloseSink, aProgressCallback);
if (aCopierCtx) {
*aCopierCtx = static_cast<nsISupports*>(
static_cast<nsIRunnable*>(copier));
*aCopierCtx = static_cast<nsISupports*>(static_cast<nsIRunnable*>(copier));
NS_ADDREF(*aCopierCtx);
}
NS_RELEASE(copier);
@ -630,15 +629,16 @@ NS_AsyncCopy(nsIInputStream* aSource,
nsresult
NS_CancelAsyncCopy(nsISupports* aCopierCtx, nsresult aReason)
{
nsAStreamCopier* copier = static_cast<nsAStreamCopier*>(
static_cast<nsIRunnable *>(aCopierCtx));
nsAStreamCopier* copier =
static_cast<nsAStreamCopier*>(static_cast<nsIRunnable *>(aCopierCtx));
return copier->Cancel(aReason);
}
//-----------------------------------------------------------------------------
nsresult
NS_ConsumeStream(nsIInputStream* aStream, uint32_t aMaxCount, nsACString& aResult)
NS_ConsumeStream(nsIInputStream* aStream, uint32_t aMaxCount,
nsACString& aResult)
{
nsresult rv = NS_OK;
aResult.Truncate();
@ -712,8 +712,7 @@ NS_InputStreamIsBuffered(nsIInputStream* aStream)
bool result = false;
uint32_t n;
nsresult rv = aStream->ReadSegments(TestInputStream,
&result, 1, &n);
nsresult rv = aStream->ReadSegments(TestInputStream, &result, 1, &n);
return result || NS_SUCCEEDED(rv);
}

View File

@ -231,7 +231,8 @@ nsStringInputStream::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure,
if (aCount > maxCount) {
aCount = maxCount;
}
nsresult rv = aWriter(this, aClosure, mData.BeginReading() + mOffset, 0, aCount, aResult);
nsresult rv = aWriter(this, aClosure, mData.BeginReading() + mOffset, 0,
aCount, aResult);
if (NS_SUCCEEDED(rv)) {
NS_ASSERTION(*aResult <= aCount,
"writer should not write more than we asked it to write");
@ -344,7 +345,7 @@ NS_NewByteInputStream(nsIInputStream** aStreamResult,
NS_PRECONDITION(aStreamResult, "null out ptr");
nsStringInputStream* stream = new nsStringInputStream();
if (! stream) {
if (!stream) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -390,7 +391,7 @@ NS_NewCStringInputStream(nsIInputStream** aStreamResult,
NS_PRECONDITION(aStreamResult, "null out ptr");
nsStringInputStream* stream = new nsStringInputStream();
if (! stream) {
if (!stream) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -404,7 +405,8 @@ NS_NewCStringInputStream(nsIInputStream** aStreamResult,
// factory method for constructing a nsStringInputStream object
nsresult
nsStringInputStreamConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult)
nsStringInputStreamConstructor(nsISupports* aOuter, REFNSIID aIID,
void** aResult)
{
*aResult = nullptr;

View File

@ -422,8 +422,9 @@ nsSimpleUnicharStreamFactory::CreateInstanceFromString(const nsAString& aString,
}
NS_IMETHODIMP
nsSimpleUnicharStreamFactory::CreateInstanceFromUTF8Stream(nsIInputStream* aStreamToWrap,
nsIUnicharInputStream** aResult)
nsSimpleUnicharStreamFactory::CreateInstanceFromUTF8Stream(
nsIInputStream* aStreamToWrap,
nsIUnicharInputStream** aResult)
{
*aResult = nullptr;

View File

@ -87,7 +87,8 @@ LossyAppendUTF16toASCII(const nsAString& aSource, nsACString& aDest)
// right now, this won't work on multi-fragment destinations
LossyConvertEncoding16to8 converter(dest.get());
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
converter);
}
void
@ -103,7 +104,8 @@ AppendASCIItoUTF16(const nsACString& aSource, nsAString& aDest,
const mozilla::fallible_t&)
{
uint32_t old_dest_length = aDest.Length();
if (!aDest.SetLength(old_dest_length + aSource.Length(), mozilla::fallible_t())) {
if (!aDest.SetLength(old_dest_length + aSource.Length(),
mozilla::fallible_t())) {
return false;
}
@ -117,7 +119,8 @@ AppendASCIItoUTF16(const nsACString& aSource, nsAString& aDest,
// right now, this won't work on multi-fragment destinations
LossyConvertEncoding8to16 converter(dest.get());
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
converter);
return true;
}
@ -254,7 +257,8 @@ inline
ToCharT*
AllocateStringCopy(const FromStringT& aSource, ToCharT*)
{
return static_cast<ToCharT*>(nsMemory::Alloc((aSource.Length() + 1) * sizeof(ToCharT)));
return static_cast<ToCharT*>(nsMemory::Alloc(
(aSource.Length() + 1) * sizeof(ToCharT)));
}
@ -311,7 +315,8 @@ ToNewCString(const nsACString& aSource)
nsACString::const_iterator fromBegin, fromEnd;
char* toBegin = result;
*copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), toBegin) = char(0);
*copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
toBegin) = char(0);
return result;
}
@ -327,7 +332,8 @@ ToNewUnicode(const nsAString& aSource)
nsAString::const_iterator fromBegin, fromEnd;
char16_t* toBegin = result;
*copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), toBegin) = char16_t(0);
*copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
toBegin) = char16_t(0);
return result;
}
@ -643,7 +649,8 @@ ToUpperCase(const nsACString& aSource, nsACString& aDest)
aDest.SetLength(aSource.Length());
CopyToUpperCase converter(aDest.BeginWriting(toBegin));
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
converter);
}
/**
@ -723,7 +730,8 @@ ToLowerCase(const nsACString& aSource, nsACString& aDest)
aDest.SetLength(aSource.Length());
CopyToLowerCase converter(aDest.BeginWriting(toBegin));
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd), converter);
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
converter);
}
bool

View File

@ -23,7 +23,7 @@ nsTAdoptingString_CharT::operator=(const self_type& str)
SetDataFlags(F_TERMINATED | F_OWNED);
// Make str forget the buffer we just took ownership of.
new(mutable_str) self_type();
new (mutable_str) self_type();
} else {
Assign(str);

View File

@ -76,17 +76,18 @@ nsTSubstringTuple_CharT::WriteTo(char_type* aBuf, uint32_t aBufLen) const
*/
bool
nsTSubstringTuple_CharT::IsDependentOn(const char_type* start, const char_type* end) const
nsTSubstringTuple_CharT::IsDependentOn(const char_type* aStart,
const char_type* aEnd) const
{
// we start with the right-most fragment since it is faster to check.
// we aStart with the right-most fragment since it is faster to check.
if (TO_SUBSTRING(mFragB).IsDependentOn(start, end)) {
if (TO_SUBSTRING(mFragB).IsDependentOn(aStart, aEnd)) {
return true;
}
if (mHead) {
return mHead->IsDependentOn(start, end);
return mHead->IsDependentOn(aStart, aEnd);
}
return TO_SUBSTRING(mFragA).IsDependentOn(start, end);
return TO_SUBSTRING(mFragA).IsDependentOn(aStart, aEnd);
}

View File

@ -18,7 +18,8 @@ LossyConvertEncoding16to8::write_sse2(const char16_t* aSource,
// Align source to a 16-byte boundary.
uint32_t i = 0;
uint32_t alignLen =
XPCOM_MIN<uint32_t>(aSourceLength, uint32_t(-NS_PTR_TO_INT32(aSource) & 0xf) / sizeof(char16_t));
XPCOM_MIN<uint32_t>(aSourceLength,
uint32_t(-NS_PTR_TO_INT32(aSource) & 0xf) / sizeof(char16_t));
for (; i < alignLen; ++i) {
dest[i] = static_cast<unsigned char>(aSource[i]);
}
@ -71,7 +72,8 @@ LossyConvertEncoding8to16::write_sse2(const char* aSource,
// to wait for a load to complete, but you can keep on moving after issuing a
// store.
uint32_t i = 0;
uint32_t alignLen = XPCOM_MIN(aSourceLength, uint32_t(-NS_PTR_TO_INT32(aSource) & 0xf));
uint32_t alignLen = XPCOM_MIN(aSourceLength,
uint32_t(-NS_PTR_TO_INT32(aSource) & 0xf));
for (; i < alignLen; ++i) {
dest[i] = static_cast<unsigned char>(aSource[i]);
}

View File

@ -187,8 +187,7 @@ void ThreadStackHelper::GetThreadStackBase()
#elif defined(XP_WIN)
::MEMORY_BASIC_INFORMATION meminfo = {};
NS_ENSURE_TRUE_VOID(::VirtualQuery(
&meminfo, &meminfo, sizeof(meminfo)));
NS_ENSURE_TRUE_VOID(::VirtualQuery(&meminfo, &meminfo, sizeof(meminfo)));
#ifdef MOZ_THREADSTACKHELPER_STACK_GROWS_DOWN
mThreadStackBase = intptr_t(meminfo.BaseAddress) + meminfo.RegionSize;
#else
@ -206,7 +205,7 @@ void ThreadStackHelper::GetThreadStackBase()
#endif // MOZ_THREADSTACKHELPER_NATIVE
namespace {
template <typename T>
template<typename T>
class ScopedSetPtr
{
private:
@ -278,7 +277,8 @@ ThreadStackHelper::GetStack(Stack& aStack)
#ifdef MOZ_THREADSTACKHELPER_NATIVE
class ThreadStackHelper::CodeModulesProvider
: public google_breakpad::CodeModules {
: public google_breakpad::CodeModules
{
private:
typedef google_breakpad::CodeModule CodeModule;
typedef google_breakpad::BasicCodeModule BasicCodeModule;
@ -290,24 +290,29 @@ public:
CodeModulesProvider() : mLibs(SharedLibraryInfo::GetInfoForSelf()) {}
virtual ~CodeModulesProvider() {}
virtual unsigned int module_count() const {
virtual unsigned int module_count() const
{
return mLibs.GetSize();
}
virtual const CodeModule* GetModuleForAddress(uint64_t address) const {
virtual const CodeModule* GetModuleForAddress(uint64_t aAddress) const
{
MOZ_CRASH("Not implemented");
}
virtual const CodeModule* GetMainModule() const {
virtual const CodeModule* GetMainModule() const
{
return nullptr;
}
virtual const CodeModule* GetModuleAtSequence(unsigned int sequence) const {
virtual const CodeModule* GetModuleAtSequence(unsigned int aSequence) const
{
MOZ_CRASH("Not implemented");
}
virtual const CodeModule* GetModuleAtIndex(unsigned int index) const {
const SharedLibrary& lib = mLibs.GetEntry(index);
virtual const CodeModule* GetModuleAtIndex(unsigned int aIndex) const
{
const SharedLibrary& lib = mLibs.GetEntry(aIndex);
mModule = new BasicCodeModule(lib.GetStart(), lib.GetEnd() - lib.GetStart(),
lib.GetName(), lib.GetBreakpadId(),
lib.GetName(), lib.GetBreakpadId(), "");
@ -315,13 +320,15 @@ public:
return mModule;
}
virtual const CodeModules* Copy() const {
virtual const CodeModules* Copy() const
{
MOZ_CRASH("Not implemented");
}
};
class ThreadStackHelper::ThreadContext
: public google_breakpad::MemoryRegion {
: public google_breakpad::MemoryRegion
{
public:
#if defined(MOZ_THREADSTACKHELPER_X86)
typedef MDRawContextX86 Context;
@ -347,39 +354,41 @@ public:
// End of stack area
const void* mStackEnd;
ThreadContext() : mValid(false)
, mStackBase(0)
, mStackSize(0)
, mStackEnd(nullptr) {}
ThreadContext()
: mValid(false)
, mStackBase(0)
, mStackSize(0)
, mStackEnd(nullptr) {}
virtual ~ThreadContext() {}
virtual uint64_t GetBase() const {
return uint64_t(mStackBase);
virtual uint64_t GetBase() const { return uint64_t(mStackBase); }
virtual uint32_t GetSize() const { return mStackSize; }
virtual bool GetMemoryAtAddress(uint64_t aAddress, uint8_t* aValue) const
{
return GetMemoryAtAddressInternal(aAddress, aValue);
}
virtual uint32_t GetSize() const {
return mStackSize;
virtual bool GetMemoryAtAddress(uint64_t aAddress, uint16_t* aValue) const
{
return GetMemoryAtAddressInternal(aAddress, aValue);
}
virtual bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const {
return GetMemoryAtAddressInternal(address, value);
virtual bool GetMemoryAtAddress(uint64_t aAddress, uint32_t* aValue) const
{
return GetMemoryAtAddressInternal(aAddress, aValue);
}
virtual bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const {
return GetMemoryAtAddressInternal(address, value);
}
virtual bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const {
return GetMemoryAtAddressInternal(address, value);
}
virtual bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const {
return GetMemoryAtAddressInternal(address, value);
virtual bool GetMemoryAtAddress(uint64_t aAddress, uint64_t* aValue) const
{
return GetMemoryAtAddressInternal(aAddress, aValue);
}
private:
template <typename T>
bool GetMemoryAtAddressInternal(uint64_t address, T* value) const {
const intptr_t offset = intptr_t(address) - intptr_t(GetBase());
template<typename T>
bool GetMemoryAtAddressInternal(uint64_t aAddress, T* aValue) const
{
const intptr_t offset = intptr_t(aAddress) - intptr_t(GetBase());
if (offset < 0 || uintptr_t(offset) > (GetSize() - sizeof(T))) {
return false;
}
*value = *reinterpret_cast<const T*>(&mStack[offset]);
*aValue = *reinterpret_cast<const T*>(&mStack[offset]);
return true;
}
};

View File

@ -85,10 +85,10 @@ nsEventQueue::GetEvent(bool aMayWait, nsIRunnable** aResult)
}
void
nsEventQueue::PutEvent(nsIRunnable *runnable)
nsEventQueue::PutEvent(nsIRunnable* aRunnable)
{
// Avoid calling AddRef+Release while holding our monitor.
nsRefPtr<nsIRunnable> event(runnable);
nsRefPtr<nsIRunnable> event(aRunnable);
if (ChaosMode::isActive()) {
// With probability 0.5, yield so other threads have a chance to
@ -108,7 +108,7 @@ nsEventQueue::PutEvent(nsIRunnable *runnable)
mOffsetHead = 0;
mOffsetTail = 0;
} else if (mOffsetTail == EVENTS_PER_PAGE) {
Page *page = NewPage();
Page* page = NewPage();
MOZ_ASSERT(page);
mTail->mNext = page;
@ -118,6 +118,6 @@ nsEventQueue::PutEvent(nsIRunnable *runnable)
event.swap(mTail->mEvents[mOffsetTail]);
++mOffsetTail;
LOG(("EVENTQ(%p): notify\n", this));
LOG(("EVENTQ(%p): notify\n", this));
mon.NotifyAll();
}

View File

@ -214,9 +214,7 @@ public:
// This method needs to be public to support older compilers (xlC_r on AIX).
// It should be called directly as this class type is reference counted.
virtual ~nsThreadStartupEvent()
{
}
virtual ~nsThreadStartupEvent() {}
private:
NS_IMETHOD Run()
@ -688,7 +686,8 @@ nsThread::ProcessNextEvent(bool aMayWait, bool* aResult)
LOG(("THRD(%p) ProcessNextEvent [%u %u]\n", this, aMayWait, mRunningEvent));
// If we're on the main thread, we shouldn't be dispatching CPOWs.
MOZ_RELEASE_ASSERT(mIsMainThread != MAIN_THREAD || !ipc::ProcessingUrgentMessages());
MOZ_RELEASE_ASSERT(mIsMainThread != MAIN_THREAD ||
!ipc::ProcessingUrgentMessages());
if (NS_WARN_IF(PR_GetCurrentThread() != mThread)) {
return NS_ERROR_NOT_SAME_THREAD;

View File

@ -557,7 +557,7 @@ nsTimerImpl::Fire()
}
PROFILER_LABEL("Timer", "Fire",
js::ProfileEntry::Category::OTHER);
js::ProfileEntry::Category::OTHER);
#ifdef MOZ_TASK_TRACER
mozilla::tasktracer::AutoRunFakeTracedTask runTracedTask(mTracedTask);