Bug 1476557: Fix DEAD_STORE errors reported by infer in dom/plugins/*. r?froydnj draft
authorRobert Bartlensky <rbartlensky@mozilla.com>
Wed, 18 Jul 2018 13:51:40 +0100
changeset 820748 c7d231195e65a82a9a7c2ab821ec8fb628c8814d
parent 820696 4aa8eb6e5ca75109e97e0c3f64c5529fd74c94eb
push id116921
push userbmo:rbartlensky@mozilla.com
push dateFri, 20 Jul 2018 10:52:30 +0000
reviewersfroydnj
bugs1476557
milestone63.0a1
Bug 1476557: Fix DEAD_STORE errors reported by infer in dom/plugins/*. r?froydnj MozReview-Commit-ID: CUHXbqLVuzb
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsPluginHost.cpp
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -1052,17 +1052,17 @@ bool
   options.setFileAndLine(spec, 0);
   JS::Rooted<JS::Value> rval(cx);
   JS::AutoObjectVector scopeChain(cx);
   if (obj != js::GetGlobalForObjectCrossCompartment(obj) &&
       !scopeChain.append(obj)) {
     return false;
   }
   obj = js::GetGlobalForObjectCrossCompartment(obj);
-  nsresult rv = NS_OK;
+  nsresult rv;
   {
     nsJSUtils::ExecutionContext exec(cx, obj);
     exec.SetScopeChain(scopeChain);
     exec.CompileAndExec(options, utf16script);
     rv = exec.ExtractReturnValue(&rval);
   }
 
   if (!JS_WrapValue(cx, &rval)) {
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -487,18 +487,16 @@ nsresult nsPluginHost::ReloadPlugins()
     return NS_ERROR_PLUGINS_PLUGINSNOTCHANGED;
 
   return ActuallyReloadPlugins();
 }
 
 nsresult
 nsPluginHost::ActuallyReloadPlugins()
 {
-  nsresult rv = NS_OK;
-
   // shutdown plugins and kill the list if there are no running plugins
   RefPtr<nsPluginTag> prev;
   RefPtr<nsPluginTag> next;
 
   for (RefPtr<nsPluginTag> p = mPlugins; p != nullptr;) {
     next = p->mNext;
 
     // only remove our plugin from the list if it's not running.
@@ -520,17 +518,17 @@ nsPluginHost::ActuallyReloadPlugins()
     prev = p;
     p = next;
   }
 
   // set flags
   mPluginsLoaded = false;
 
   // load them again
-  rv = LoadPlugins();
+  nsresult rv = LoadPlugins();
 
   if (XRE_IsParentProcess())
   {
     // If the plugin list changed, update content. If the plugin list changed
     // for the content process, it will also reload plugins.
     SendPluginsToContent();
   }
 
@@ -1410,25 +1408,25 @@ nsPluginHost::NotifyContentModuleDestroy
   RefPtr<nsPluginUnloadRunnable> runnable =
     new nsPluginUnloadRunnable(aPluginId);
   NS_DispatchToMainThread(runnable);
 }
 
 nsresult nsPluginHost::GetPlugin(const nsACString &aMimeType,
                                  nsNPAPIPlugin** aPlugin)
 {
-  nsresult rv = NS_ERROR_FAILURE;
   *aPlugin = nullptr;
 
+  nsresult rv;
+
   // If plugins haven't been scanned yet, do so now
   LoadPlugins();
 
   nsPluginTag* pluginTag = FindNativePluginForType(aMimeType, true);
   if (pluginTag) {
-    rv = NS_OK;
     PLUGIN_LOG(PLUGIN_LOG_BASIC,
     ("nsPluginHost::GetPlugin Begin mime=%s, plugin=%s\n",
      PromiseFlatCString(aMimeType).get(), pluginTag->FileName().get()));
 
 #ifdef DEBUG
     if (!pluginTag->FileName().IsEmpty())
       printf("For %s found plugin %s\n",
              PromiseFlatCString(aMimeType).get(), pluginTag->FileName().get());
@@ -3273,17 +3271,17 @@ nsresult nsPluginHost::NewPluginURLStrea
   if (aURL.Length() <= 0)
     return NS_OK;
 
   // get the base URI for the plugin to create an absolute url
   // in case aURL is relative
   RefPtr<nsPluginInstanceOwner> owner = aInstance->GetOwner();
   if (owner) {
     nsCOMPtr<nsIURI> baseURI = owner->GetBaseURI();
-    rv = NS_MakeAbsoluteURI(absUrl, aURL, baseURI);
+    Unused << NS_MakeAbsoluteURI(absUrl, aURL, baseURI);
   }
 
   if (absUrl.IsEmpty())
     absUrl.Assign(aURL);
 
   rv = NS_NewURI(getter_AddRefs(url), absUrl);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -3384,18 +3382,16 @@ nsresult nsPluginHost::NewPluginURLStrea
   return rv;
 }
 
 nsresult
 nsPluginHost::AddHeadersToChannel(const char *aHeadersData,
                                   uint32_t aHeadersDataLen,
                                   nsIChannel *aGenericChannel)
 {
-  nsresult rv = NS_OK;
-
   nsCOMPtr<nsIHttpChannel> aChannel = do_QueryInterface(aGenericChannel);
   if (!aChannel) {
     return NS_ERROR_NULL_POINTER;
   }
 
   // used during the manipulation of the String from the aHeadersData
   nsAutoCString headersString;
   nsAutoCString oneHeader;
@@ -3405,16 +3401,17 @@ nsPluginHost::AddHeadersToChannel(const 
   int32_t colon = 0;
 
   // Turn the char * buffer into an nsString.
   headersString = aHeadersData;
 
   // Iterate over the nsString: for each "\r\n" delimited chunk,
   // add the value as a header to the nsIHTTPChannel
   while (true) {
+    nsresult rv;
     crlf = headersString.Find("\r\n", true);
     if (-1 == crlf) {
       rv = NS_OK;
       return rv;
     }
     headersString.Mid(oneHeader, 0, crlf);
     headersString.Cut(0, crlf + 2);
     oneHeader.StripWhitespace();