Bug 1251891 - Fix -Wunreachable-code warnings in testplugin. r=jimm
authorChris Peterson <cpeterson@mozilla.com>
Wed, 10 Feb 2016 22:12:19 -0800
changeset 322541 a1800ff23514f93ad5dbdb74ddfa33be9268cf26
parent 322540 65f7f2ffd30c41a291779d89ecd8ed07e6f19567
child 322542 5cafa6f3019b57c43312a75e7d7d58aeb032f1bc
child 322571 d267ea30eb20ef3b835f9d25d81a831c00d15a73
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1251891
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1251891 - Fix -Wunreachable-code warnings in testplugin. r=jimm dom/plugins/test/testplugin/nptest_macosx.mm:278:10: warning: will never be executed [-Wunreachable-code] dom/plugins/test/testplugin/nptest_macosx.mm:307:10: warning: will never be executed [-Wunreachable-code] dom/plugins/test/testplugin/nptest.cpp:697:7: warning: will never be executed [-Wunreachable-code] dom/plugins/test/testplugin/nptest.cpp:2300:15: warning: will never be executed [-Wunreachable-code]
dom/plugins/test/testplugin/nptest.cpp
dom/plugins/test/testplugin/nptest_gtk2.cpp
dom/plugins/test/testplugin/nptest_macosx.mm
--- a/dom/plugins/test/testplugin/nptest.cpp
+++ b/dom/plugins/test/testplugin/nptest.cpp
@@ -689,17 +689,16 @@ NP_GetValue(void* future, NPPVariable aV
     case NPPVpluginNameString:
       *((const char**)aValue) = sPluginName;
       break;
     case NPPVpluginDescriptionString:
       *((const char**)aValue) = sPluginDescription;
       break;
     default:
       return NPERR_INVALID_PARAM;
-      break;
   }
   return NPERR_NO_ERROR;
 }
 #endif
 
 static bool fillPluginFunctionTable(NPPluginFuncs* pFuncs)
 {
   // Check the size of the provided structure based on the offset of the
@@ -2201,17 +2200,19 @@ compareVariants(NPP instance, const NPVa
   bool success = true;
   InstanceData* id = static_cast<InstanceData*>(instance->pdata);
   if (var1->type != var2->type) {
     id->err << "Variant types don't match; got " << var1->type <<
         " expected " << var2->type;
     return false;
   }
 
-  switch (var1->type) {
+  // Cast var1->type from NPVariantType to int to avoid compiler warnings about
+  // not needing a default case when we have cases for every enum value.
+  switch (static_cast<int>(var1->type)) {
     case NPVariantType_Int32: {
         int32_t result = NPVARIANT_TO_INT32(*var1);
         int32_t expected = NPVARIANT_TO_INT32(*var2);
         if (result != expected) {
           id->err << "Variant values don't match; got " << result <<
               " expected " << expected;
           success = false;
         }
@@ -2294,16 +2295,17 @@ compareVariants(NPP instance, const NPVa
           }
         }
         NPN_MemFree(identifiers);
         break;
       }
     default:
       id->err << "Unknown variant type";
       success = false;
+      MOZ_ASSERT_UNREACHABLE("Unknown variant type?!");
   }
 
   return success;
 }
 
 static bool
 throwExceptionNextInvoke(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
@@ -3976,9 +3978,8 @@ getAudioMuted(NPObject* npobj, const NPV
     return false;
   }
 
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
   BOOLEAN_TO_NPVARIANT(id->audioMuted, *result);
   return true;
 }
-
--- a/dom/plugins/test/testplugin/nptest_gtk2.cpp
+++ b/dom/plugins/test/testplugin/nptest_gtk2.cpp
@@ -466,18 +466,17 @@ int32_t pluginGetEdge(InstanceData* inst
     return pluginX;
   case EDGE_TOP:
     return pluginY;
   case EDGE_RIGHT:
     return pluginX + pluginWidth;
   case EDGE_BOTTOM:
     return pluginY + pluginHeight;
   }
-
-  return NPTEST_INT32_ERROR;
+  MOZ_CRASH("Unexpected RectEdge?!");
 }
 
 #ifdef MOZ_X11
 static void intersectWithShapeRects(Display* display, Window window,
                                     int kind, GdkRegion* region)
 {
   int count = -1, order;
   XRectangle* shapeRects =
--- a/dom/plugins/test/testplugin/nptest_macosx.mm
+++ b/dom/plugins/test/testplugin/nptest_macosx.mm
@@ -270,17 +270,17 @@ int32_t pluginGetEdge(InstanceData* inst
     return w->x;
   case EDGE_TOP:
     return w->y;
   case EDGE_RIGHT:
     return w->x + w->width;
   case EDGE_BOTTOM:
     return w->y + w->height;
   }
-  return NPTEST_INT32_ERROR;
+  MOZ_CRASH("Unexpected RectEdge?!");
 }
 
 int32_t pluginGetClipRegionRectCount(InstanceData* instanceData)
 {
   return 1;
 }
 
 int32_t pluginGetClipRegionRectEdge(InstanceData* instanceData, 
@@ -299,14 +299,14 @@ int32_t pluginGetClipRegionRectEdge(Inst
     return w->clipRect.left;
   case EDGE_TOP:
     return w->clipRect.top + COCOA_TITLEBAR_HEIGHT;
   case EDGE_RIGHT:
     return w->clipRect.right;
   case EDGE_BOTTOM:
     return w->clipRect.bottom + COCOA_TITLEBAR_HEIGHT;
   }
-  return NPTEST_INT32_ERROR;
+  MOZ_CRASH("Unexpected RectEdge?!");
 }
 
 void pluginDoInternalConsistencyCheck(InstanceData* instanceData, string& error)
 {
 }