Skip to content

Commit

Permalink
Bug 1180993 - Part 3: Correct use sites of functions which return alr…
Browse files Browse the repository at this point in the history
…eady_AddRefed. r=ehsan
  • Loading branch information
mystor committed Jul 10, 2015
1 parent 4d4ea0a commit f62619f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion dom/base/ImageEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "mozilla/gfx/DataSurfaceHelpers.h"
#include "mozilla/RefPtr.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/unused.h"
#include "gfxUtils.h"
#include "nsNetUtil.h"

Expand Down Expand Up @@ -206,7 +207,7 @@ class EncodingRunnable : public nsRunnable
rv = NS_DispatchToMainThread(mEncodingCompleteEvent);
if (NS_FAILED(rv)) {
// Better to leak than to crash.
mEncodingCompleteEvent.forget();
unused << mEncodingCompleteEvent.forget();
return rv;
}

Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/TabParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class OpenFileAndSendFDRunnable : public nsRunnable
// Intentionally leak the runnable (but not the fd) rather
// than crash when trying to release a main thread object
// off the main thread.
mTabParent.forget();
mozilla::unused << mTabParent.forget();
CloseFile();
}
}
Expand Down
3 changes: 1 addition & 2 deletions dom/storage/DOMStorageDBThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ nsReverseStringSQLFunction::OnFunctionCall(
rv = outVar->SetAsAUTF8String(result);
NS_ENSURE_SUCCESS(rv, rv);

*aResult = outVar.get();
outVar.forget();
outVar.forget(aResult);
return NS_OK;
}

Expand Down
3 changes: 2 additions & 1 deletion netwerk/cache2/CacheIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "mozilla/AutoRestore.h"
#include <algorithm>
#include "mozilla/Telemetry.h"
#include "mozilla/unused.h"


#define kMinUnwrittenChanges 300
Expand Down Expand Up @@ -3045,7 +3046,7 @@ CacheIndex::FinishUpdate(bool aSucceeded)
NS_WARNING(("CacheIndex::FinishUpdate() - Leaking mDirEnumerator!"));
// This can happen only in case dispatching event to IO thread failed in
// CacheIndex::PreShutdown().
mDirEnumerator.forget(); // Leak it since dir enumerator is not threadsafe
unused << mDirEnumerator.forget(); // Leak it since dir enumerator is not threadsafe
} else {
mDirEnumerator->Close();
mDirEnumerator = nullptr;
Expand Down
3 changes: 2 additions & 1 deletion widget/gtk/nsSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "nsDirectoryServiceDefs.h"
#include "mozilla/FileUtils.h"
#include "mozilla/Services.h"
#include "mozilla/unused.h"
#include "nsIStringBundle.h"
#include "nsIXULAppInfo.h"
#include "nsContentUtils.h"
Expand Down Expand Up @@ -80,7 +81,7 @@ struct ScopedCanberraFile {
}

void forget() {
mFile.forget();
mozilla::unused << mFile.forget();
}
nsIFile* operator->() { return mFile; }
operator nsIFile*() { return mFile; }
Expand Down

0 comments on commit f62619f

Please sign in to comment.