Bug 1217307 - Remove some unnecessary null checks in rest of dom/. r=njn

This commit is contained in:
Birunthan Mohanathas
2015-11-19 09:13:49 +02:00
parent 87edb9df5e
commit e95885610b
20 changed files with 5 additions and 68 deletions

View File

@@ -848,7 +848,6 @@ GetSubmissionFromForm(nsGenericHTMLElement* aForm,
*aFormSubmission = new nsFSURLEncoded(charset, method, doc,
aOriginatingElement);
}
NS_ENSURE_TRUE(*aFormSubmission, NS_ERROR_OUT_OF_MEMORY);
return NS_OK;
}

View File

@@ -298,8 +298,6 @@ nsJSONWriter::Write(const char16_t *aBuffer, uint32_t aLength)
if (!mDidWrite) {
mBuffer = new char16_t[JSON_STREAM_BUFSIZE];
if (!mBuffer)
return NS_ERROR_OUT_OF_MEMORY;
mDidWrite = true;
}
@@ -481,9 +479,6 @@ nsresult
NS_NewJSON(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
nsJSON* json = new nsJSON();
if (!json)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(json);
*aResult = json;

View File

@@ -410,8 +410,6 @@ nsresult nsJSChannel::Init(nsIURI *aURI)
// Create the nsIStreamIO layer used by the nsIStreamIOChannel.
mIOThunk = new nsJSThunk();
if (!mIOThunk)
return NS_ERROR_OUT_OF_MEMORY;
// Create a stock input stream channel...
// Remember, until AsyncOpen is called, the script will not be evaluated
@@ -1129,8 +1127,6 @@ nsJSProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
return NS_ERROR_NO_AGGREGATION;
nsJSProtocolHandler* ph = new nsJSProtocolHandler();
if (!ph)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(ph);
nsresult rv = ph->Init();
if (NS_SUCCEEDED(rv)) {

View File

@@ -640,9 +640,6 @@ InitMediaCache()
return;
gMediaCache = new MediaCache();
if (!gMediaCache)
return;
nsresult rv = gMediaCache->Init();
if (NS_FAILED(rv)) {
delete gMediaCache;

View File

@@ -549,8 +549,6 @@ nsresult ChannelMediaResource::OpenChannel(nsIStreamListener** aStreamListener)
}
mListener = new Listener(this);
NS_ENSURE_TRUE(mListener, NS_ERROR_OUT_OF_MEMORY);
if (aStreamListener) {
*aStreamListener = mListener;
NS_ADDREF(*aStreamListener);

View File

@@ -582,9 +582,6 @@ nsNPAPIPluginInstance::NewStreamFromPlugin(const char* type, const char* target,
nsIOutputStream* *result)
{
nsPluginStreamToFile* stream = new nsPluginStreamToFile(target, mOwner);
if (!stream)
return NS_ERROR_OUT_OF_MEMORY;
return stream->QueryInterface(kIOutputStreamIID, (void**)result);
}

View File

@@ -2227,9 +2227,6 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
pluginTag = new nsPluginTag(&info, fileModTime, fromExtension);
pluginFile.FreePluginInfo(info);
if (!pluginTag)
return NS_ERROR_OUT_OF_MEMORY;
pluginTag->mLibrary = library;
uint32_t state;
rv = pluginTag->GetBlocklistState(&state);
@@ -3319,8 +3316,6 @@ nsPluginHost::EnsurePrivateDirServiceProvider()
if (!mPrivateDirServiceProvider) {
nsresult rv;
mPrivateDirServiceProvider = new nsPluginDirServiceProvider();
if (!mPrivateDirServiceProvider)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIDirectoryService> dirService(do_GetService(kDirectoryServiceContractID, &rv));
if (NS_FAILED(rv))
return rv;

View File

@@ -1150,9 +1150,6 @@ void nsPluginInstanceOwner::AddToCARefreshTimer() {
if (!sCARefreshListeners) {
sCARefreshListeners = new nsTArray<nsPluginInstanceOwner*>();
if (!sCARefreshListeners) {
return;
}
}
if (sCARefreshListeners->Contains(this)) {
@@ -1163,9 +1160,6 @@ void nsPluginInstanceOwner::AddToCARefreshTimer() {
if (!sCATimer) {
sCATimer = new nsCOMPtr<nsITimer>();
if (!sCATimer) {
return;
}
}
if (sCARefreshListeners->Length() == 1) {

View File

@@ -41,7 +41,7 @@ nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow)
{
NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
*aPluginNativeWindow = new nsPluginNativeWindowPLATFORM();
return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow)

View File

@@ -57,7 +57,7 @@ nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow)
{
NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
*aPluginNativeWindow = new nsPluginNativeWindowGtk();
return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow)

View File

@@ -62,7 +62,7 @@ nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow **aPluginNativeWindow)
{
NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
*aPluginNativeWindow = new nsPluginNativeWindowQt();
return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow)

View File

@@ -575,13 +575,11 @@ nsPluginNativeWindowWin::GetPluginWindowEvent(HWND aWnd, UINT aMsg, WPARAM aWPar
if (!mCachedPluginWindowEvent)
{
event = new PluginWindowEvent();
if (!event) return nullptr;
mCachedPluginWindowEvent = event;
}
else if (mCachedPluginWindowEvent->InUse())
{
event = new PluginWindowEvent();
if (!event) return nullptr;
}
else
{
@@ -739,8 +737,7 @@ nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow)
NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
*aPluginNativeWindow = new nsPluginNativeWindowWin();
return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow)

View File

@@ -735,12 +735,7 @@ nsPluginStreamListenerPeer::RequestRead(NPByteRange* rangeList)
} else {
nsWeakPtr weakpeer =
do_GetWeakReference(static_cast<nsISupportsWeakReference*>(this));
nsPluginByteRangeStreamListener *brrListener =
new nsPluginByteRangeStreamListener(weakpeer);
if (brrListener)
converter = brrListener;
else
return NS_ERROR_OUT_OF_MEMORY;
converter = new nsPluginByteRangeStreamListener(weakpeer);
}
mPendingRequests += numRequests;

View File

@@ -2161,9 +2161,6 @@ PluginInstanceChild::FlashThrottleMessage(HWND aWnd,
// that's done in Destroy.
FlashThrottleAsyncMsg* task = new FlashThrottleAsyncMsg(this,
aWnd, aMsg, aWParam, aLParam, isWindowed);
if (!task)
return;
{
MutexAutoLock lock(mAsyncCallMutex);
mPendingAsyncCalls.AppendElement(task);

View File

@@ -1533,11 +1533,6 @@ PluginInstanceParent::GetActorForNPObject(NPObject* aObject)
}
actor = new PluginScriptableObjectParent(LocalObject);
if (!actor) {
NS_ERROR("Out of memory!");
return nullptr;
}
if (!SendPPluginScriptableObjectConstructor(actor)) {
NS_WARNING("Failed to send constructor message!");
return nullptr;

View File

@@ -778,8 +778,6 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
// set up our our instance data
InstanceData* instanceData = new InstanceData;
if (!instanceData)
return NPERR_OUT_OF_MEMORY_ERROR;
instanceData->npp = instance;
instanceData->streamMode = NP_ASFILEONLY;
instanceData->testFunction = FUNCTION_NONE;

View File

@@ -175,9 +175,6 @@ MulticastDNSDeviceProvider::Init()
}
mWrappedListener = new DNSServiceWrappedListener();
if (NS_WARN_IF(!mWrappedListener)) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (NS_WARN_IF(NS_FAILED(rv = mWrappedListener->SetListener(this)))) {
return rv;
}

View File

@@ -50,8 +50,6 @@ nsXBLProtoImplMethod::AppendBodyText(const nsAString& aText)
nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod();
if (!uncompiledMethod) {
uncompiledMethod = new nsXBLUncompiledMethod();
if (!uncompiledMethod)
return;
SetUncompiledMethod(uncompiledMethod);
}
@@ -72,8 +70,6 @@ nsXBLProtoImplMethod::AddParameter(const nsAString& aText)
nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod();
if (!uncompiledMethod) {
uncompiledMethod = new nsXBLUncompiledMethod();
if (!uncompiledMethod)
return;
SetUncompiledMethod(uncompiledMethod);
}
@@ -89,8 +85,6 @@ nsXBLProtoImplMethod::SetLineNumber(uint32_t aLineNumber)
nsXBLUncompiledMethod* uncompiledMethod = GetUncompiledMethod();
if (!uncompiledMethod) {
uncompiledMethod = new nsXBLUncompiledMethod();
if (!uncompiledMethod)
return;
SetUncompiledMethod(uncompiledMethod);
}
@@ -168,8 +162,6 @@ nsXBLProtoImplMethod::CompileMember(AutoJSAPI& jsapi, const nsString& aClassStr,
char** args = nullptr;
if (paramCount > 0) {
args = new char*[paramCount];
if (!args)
return NS_ERROR_OUT_OF_MEMORY;
// Add our parameters to our args array.
int32_t argPos = 0;

View File

@@ -65,8 +65,6 @@ struct nsXBLUncompiledMethod {
void AddParameter(const nsAString& aText) {
nsXBLParameter* param = new nsXBLParameter(aText);
if (!param)
return;
if (!mParameters)
mParameters = param;
else

View File

@@ -197,9 +197,6 @@ void
nsXBLResourceLoader::AddResource(nsIAtom* aResourceType, const nsAString& aSrc)
{
nsXBLResource* res = new nsXBLResource(aResourceType, aSrc);
if (!res)
return;
if (!mResourceList)
mResourceList = res;
else