Bug 1293212 - Add MOZ_MUST_USE to prevent potential bugs. r=smaug

MozReview-Commit-ID: EuyeBkDlk2G

--HG--
extra : rebase_source : b728e1dd7e1ddfec3315f397e35dcb11eeab1ffa
This commit is contained in:
Wei-Cheng Pan 2016-08-08 18:16:15 +08:00
Родитель 37e7cf1020
Коммит 4ae87d0adc
14 изменённых файлов: 42 добавлений и 37 удалений

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

@ -3316,7 +3316,8 @@ nsDocShell::SetDocLoaderParent(nsDocLoader* aParent)
{
bool wasFrame = IsFrame();
nsDocLoader::SetDocLoaderParent(aParent);
nsresult rv = nsDocLoader::SetDocLoaderParent(aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISupportsPriority> priorityGroup = do_QueryInterface(mLoadGroup);
if (wasFrame != IsFrame() && priorityGroup) {
@ -4036,7 +4037,8 @@ nsDocShell::AddChild(nsIDocShellTreeItem* aChild)
// Make sure to remove the child from its current parent.
nsDocLoader* childsParent = childAsDocLoader->GetParent();
if (childsParent) {
childsParent->RemoveChildLoader(childAsDocLoader);
nsresult rv = childsParent->RemoveChildLoader(childAsDocLoader);
NS_ENSURE_SUCCESS(rv, rv);
}
// Make sure to clear the treeowner in case this child is a different type

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

@ -345,7 +345,8 @@ nsDocLoader::Destroy()
// Remove the document loader from the parent list of loaders...
if (mParent)
{
mParent->RemoveChildLoader(this);
nsresult rv = mParent->RemoveChildLoader(this);
NS_WARN_IF(NS_FAILED(rv));
}
// Release all the information about network requests...
@ -376,7 +377,8 @@ nsDocLoader::DestroyChildren()
if (loader) {
// This is a safe cast, as we only put nsDocLoader objects into the
// array
static_cast<nsDocLoader*>(loader)->SetDocLoaderParent(nullptr);
nsresult rv = static_cast<nsDocLoader*>(loader)->SetDocLoaderParent(nullptr);
NS_WARN_IF(NS_FAILED(rv));
}
}
mChildList.Clear();
@ -616,7 +618,7 @@ nsresult nsDocLoader::RemoveChildLoader(nsDocLoader* aChild)
{
nsresult rv = mChildList.RemoveElement(aChild) ? NS_OK : NS_ERROR_FAILURE;
if (NS_SUCCEEDED(rv)) {
aChild->SetDocLoaderParent(nullptr);
rv = aChild->SetDocLoaderParent(nullptr);
}
return rv;
}
@ -625,7 +627,7 @@ nsresult nsDocLoader::AddChildLoader(nsDocLoader* aChild)
{
nsresult rv = mChildList.AppendElement(aChild) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
if (NS_SUCCEEDED(rv)) {
aChild->SetDocLoaderParent(this);
rv = aChild->SetDocLoaderParent(this);
}
return rv;
}

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

@ -58,7 +58,7 @@ public:
nsDocLoader();
virtual nsresult Init();
virtual MOZ_MUST_USE nsresult Init();
static already_AddRefed<nsDocLoader> GetAsDocLoader(nsISupports* aSupports);
// Needed to deal with ambiguous inheritance from nsISupports...
@ -67,7 +67,7 @@ public:
}
// Add aDocLoader as a child to the docloader service.
static nsresult AddDocLoaderAsChildOfRoot(nsDocLoader* aDocLoader);
static MOZ_MUST_USE nsresult AddDocLoaderAsChildOfRoot(nsDocLoader* aDocLoader);
NS_DECL_ISUPPORTS
NS_DECL_NSIDOCUMENTLOADER
@ -89,10 +89,10 @@ public:
// Remove aChild from our childlist. This nulls out the child's mParent
// pointer.
nsresult RemoveChildLoader(nsDocLoader *aChild);
MOZ_MUST_USE nsresult RemoveChildLoader(nsDocLoader *aChild);
// Add aChild to our child list. This will set aChild's mParent pointer to
// |this|.
nsresult AddChildLoader(nsDocLoader* aChild);
MOZ_MUST_USE nsresult AddChildLoader(nsDocLoader* aChild);
nsDocLoader* GetParent() const { return mParent; }
struct nsListenerInfo {
@ -112,7 +112,7 @@ public:
protected:
virtual ~nsDocLoader();
virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);
virtual MOZ_MUST_USE nsresult SetDocLoaderParent(nsDocLoader * aLoader);
bool IsBusy();
@ -164,7 +164,7 @@ protected:
nsIURI *aUri,
uint32_t aFlags);
bool RefreshAttempted(nsIWebProgress* aWebProgress,
MOZ_MUST_USE bool RefreshAttempted(nsIWebProgress* aWebProgress,
nsIURI *aURI,
int32_t aDelay,
bool aSameURI);
@ -187,7 +187,7 @@ protected:
// Inform a parent docloader that aChild is about to call its onload
// handler.
bool ChildEnteringOnload(nsIDocumentLoader* aChild) {
MOZ_MUST_USE bool ChildEnteringOnload(nsIDocumentLoader* aChild) {
// It's ok if we're already in the list -- we'll just be in there twice
// and then the RemoveObject calls from ChildDoneWithOnload will remove
// us.

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

@ -35,11 +35,11 @@ protected:
* Equivalent to nsIURILoader::openChannel, but allows specifying whether the
* channel is opened already.
*/
nsresult OpenChannel(nsIChannel* channel,
uint32_t aFlags,
nsIInterfaceRequestor* aWindowContext,
bool aChannelOpen,
nsIStreamListener** aListener);
MOZ_MUST_USE nsresult OpenChannel(nsIChannel* channel,
uint32_t aFlags,
nsIInterfaceRequestor* aWindowContext,
bool aChannelOpen,
nsIStreamListener** aListener);
/**
* we shouldn't need to have an owning ref count on registered

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

@ -21,7 +21,7 @@ public:
NS_DECL_NSIHANDLERSERVICE
ContentHandlerService();
nsresult Init();
MOZ_MUST_USE nsresult Init();
static void nsIHandlerInfoToHandlerInfo(nsIHandlerInfo* aInfo, HandlerInfo* aHandlerInfo);
private:

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

@ -33,7 +33,7 @@ public:
virtual bool RecvCancel(const nsresult& aStatus) override;
private:
virtual ~ExternalHelperAppChild();
nsresult DivertToParent(nsIDivertableChannel *divertable, nsIRequest *request);
MOZ_MUST_USE nsresult DivertToParent(nsIDivertableChannel *divertable, nsIRequest *request);
RefPtr<nsExternalAppHandler> mHandler;
nsresult mStatus;

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

@ -13,14 +13,14 @@
class nsMIMEInfoAndroid final : public nsIMIMEInfo
{
public:
static bool
static MOZ_MUST_USE bool
GetMimeInfoForMimeType(const nsACString& aMimeType,
nsMIMEInfoAndroid** aMimeInfo);
static bool
static MOZ_MUST_USE bool
GetMimeInfoForFileExt(const nsACString& aFileExt,
nsMIMEInfoAndroid** aMimeInfo);
static nsresult
static MOZ_MUST_USE nsresult
GetMimeInfoForURL(const nsACString &aURL, bool *found,
nsIHandlerInfo **info);
@ -33,8 +33,8 @@ public:
private:
~nsMIMEInfoAndroid() {}
virtual nsresult LaunchDefaultWithFile(nsIFile* aFile);
virtual nsresult LoadUriInternal(nsIURI *aURI);
virtual MOZ_MUST_USE nsresult LaunchDefaultWithFile(nsIFile* aFile);
virtual MOZ_MUST_USE nsresult LoadUriInternal(nsIURI *aURI);
nsCOMPtr<nsIMutableArray> mHandlerApps;
nsCString mType;
nsTArray<nsCString> mExtensions;

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

@ -20,7 +20,7 @@ public:
const nsACString& aFileExt,
bool* aFound);
virtual nsresult
virtual MOZ_MUST_USE nsresult
OSProtocolHandlerExists(const char* aScheme,
bool* aExists);

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

@ -31,7 +31,7 @@ public:
const nsACString& aFileExt,
bool* aFound);
virtual nsresult
virtual MOZ_MUST_USE nsresult
OSProtocolHandlerExists(const char* aScheme,
bool* aExists);
};

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

@ -83,7 +83,7 @@ public:
nsDecodeAppleFile();
virtual ~nsDecodeAppleFile();
nsresult Initialize(nsIOutputStream *output, nsIFile *file);
MOZ_MUST_USE nsresult Initialize(nsIOutputStream *output, nsIFile *file);
private:
#define MAX_BUFFERSIZE 1024

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

@ -16,15 +16,15 @@ class nsMIMEInfoMac : public nsMIMEInfoImpl {
NS_IMETHOD LaunchWithFile(nsIFile* aFile);
protected:
virtual nsresult LoadUriInternal(nsIURI *aURI);
virtual MOZ_MUST_USE nsresult LoadUriInternal(nsIURI *aURI);
#ifdef DEBUG
virtual nsresult LaunchDefaultWithFile(nsIFile* aFile) {
virtual MOZ_MUST_USE nsresult LaunchDefaultWithFile(nsIFile* aFile) {
NS_NOTREACHED("do not call this method, use LaunchWithFile");
return NS_ERROR_UNEXPECTED;
}
#endif
static nsresult OpenApplicationWithURI(nsIFile *aApplication,
const nsCString& aURI);
static MOZ_MUST_USE nsresult OpenApplicationWithURI(nsIFile *aApplication,
const nsCString& aURI);
NS_IMETHOD GetDefaultDescription(nsAString& aDefaultDescription);

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

@ -36,10 +36,10 @@ public:
// platformAppPath --> a platform specific path to an application that we got out of the
// rdf data source. This can be a mac file spec, a unix path or a windows path depending on the platform
// aFile --> an nsIFile representation of that platform application path.
virtual nsresult GetFileTokenForPath(const char16_t * platformAppPath, nsIFile ** aFile);
virtual MOZ_MUST_USE nsresult GetFileTokenForPath(const char16_t * platformAppPath, nsIFile ** aFile);
nsresult OSProtocolHandlerExists(const char * aScheme,
bool * aHandlerExists);
MOZ_MUST_USE nsresult OSProtocolHandlerExists(const char * aScheme,
bool * aHandlerExists);
private:
uint32_t mPermissions;

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

@ -560,7 +560,8 @@ nsOSHelperAppService::GetProtocolHandlerInfoFromOS(const nsACString &aScheme,
}
nsAutoString desc;
GetApplicationDescription(aScheme, desc);
rv = GetApplicationDescription(aScheme, desc);
NS_ENSURE_SUCCESS(rv, rv);
handlerInfo->SetDefaultDescription(desc);
return NS_OK;

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

@ -67,7 +67,7 @@ public:
* Initializes internal state. Will be called automatically when
* this service is first instantiated.
*/
nsresult Init();
MOZ_MUST_USE nsresult Init();
/**
* Given a mimetype and an extension, looks up a mime info from the OS.