[gjs/wip/ptomato/warnings: 1/3] WIP - add superfluous switch defaults :-P



commit c5626612886a79d699dffe0e18b0c7d1de93be72
Author: Philip Chimento <philip endlessm com>
Date:   Mon Oct 3 13:48:12 2016 -0700

    WIP - add superfluous switch defaults :-P

 gi/arg.cpp                |    9 ++++++-
 gi/boxed.cpp              |   53 +++++++++++++++++++++++----------------------
 gi/function.cpp           |    8 ++++++
 gi/object.cpp             |    2 +
 gi/repo.cpp               |    9 ++++++-
 gi/value.cpp              |    5 ++++
 gjs/importer.cpp          |    3 ++
 gjs/jsapi-private.cpp     |    2 +
 modules/cairo-surface.cpp |    5 ++++
 9 files changed, 66 insertions(+), 30 deletions(-)
---
diff --git a/gi/arg.cpp b/gi/arg.cpp
index 7044ce1..1eb6c2f 100644
--- a/gi/arg.cpp
+++ b/gi/arg.cpp
@@ -40,6 +40,11 @@
 
 #include <util/log.h>
 
+/* -Wswitch-enum: We do a lot of switching on GI type enums here, and it would
+ * be unreadable to list each of the 20 or so enum values every time.
+ */
+#pragma GCC diagnostic ignored "-Wswitch-enum"
+
 bool
 _gjs_flags_value_is_valid(JSContext   *context,
                           GType        gtype,
@@ -1028,9 +1033,9 @@ get_argument_display_name(const char     *arg_name,
         return g_strdup("Hash element");
     case GJS_ARGUMENT_ARRAY_ELEMENT:
         return g_strdup("Array element");
+    default:
+        g_assert_not_reached ();
     }
-
-    g_assert_not_reached ();
 }
 
 static const char *
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index b74e6d2..dce99ff 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -971,29 +971,6 @@ type_can_be_allocated_directly(GITypeInfo *type_info)
         }
     } else {
         switch (g_type_info_get_tag(type_info)) {
-        case GI_TYPE_TAG_BOOLEAN:
-        case GI_TYPE_TAG_INT8:
-        case GI_TYPE_TAG_UINT8:
-        case GI_TYPE_TAG_INT16:
-        case GI_TYPE_TAG_UINT16:
-        case GI_TYPE_TAG_INT32:
-        case GI_TYPE_TAG_UINT32:
-        case GI_TYPE_TAG_INT64:
-        case GI_TYPE_TAG_UINT64:
-        case GI_TYPE_TAG_FLOAT:
-        case GI_TYPE_TAG_DOUBLE:
-        case GI_TYPE_TAG_UNICHAR:
-            break;
-        case GI_TYPE_TAG_VOID:
-        case GI_TYPE_TAG_GTYPE:
-        case GI_TYPE_TAG_ERROR:
-        case GI_TYPE_TAG_UTF8:
-        case GI_TYPE_TAG_FILENAME:
-        case GI_TYPE_TAG_ARRAY:
-        case GI_TYPE_TAG_GLIST:
-        case GI_TYPE_TAG_GSLIST:
-        case GI_TYPE_TAG_GHASH:
-            break;
         case GI_TYPE_TAG_INTERFACE:
             {
                 GIBaseInfo *interface = g_type_info_get_interface(type_info);
@@ -1007,9 +984,6 @@ type_can_be_allocated_directly(GITypeInfo *type_info)
                     /* FIXME: Need to implement */
                     is_simple = false;
                     break;
-                case GI_INFO_TYPE_ENUM:
-                case GI_INFO_TYPE_FLAGS:
-                    break;
                 case GI_INFO_TYPE_OBJECT:
                 case GI_INFO_TYPE_VFUNC:
                 case GI_INFO_TYPE_CALLBACK:
@@ -1029,11 +1003,38 @@ type_can_be_allocated_directly(GITypeInfo *type_info)
                 case GI_INFO_TYPE_INVALID_0:
                     g_assert_not_reached();
                     break;
+                case GI_INFO_TYPE_ENUM:
+                case GI_INFO_TYPE_FLAGS:
+                default:
+                    break;
                 }
 
                 g_base_info_unref(interface);
                 break;
             }
+        case GI_TYPE_TAG_BOOLEAN:
+        case GI_TYPE_TAG_INT8:
+        case GI_TYPE_TAG_UINT8:
+        case GI_TYPE_TAG_INT16:
+        case GI_TYPE_TAG_UINT16:
+        case GI_TYPE_TAG_INT32:
+        case GI_TYPE_TAG_UINT32:
+        case GI_TYPE_TAG_INT64:
+        case GI_TYPE_TAG_UINT64:
+        case GI_TYPE_TAG_FLOAT:
+        case GI_TYPE_TAG_DOUBLE:
+        case GI_TYPE_TAG_UNICHAR:
+        case GI_TYPE_TAG_VOID:
+        case GI_TYPE_TAG_GTYPE:
+        case GI_TYPE_TAG_ERROR:
+        case GI_TYPE_TAG_UTF8:
+        case GI_TYPE_TAG_FILENAME:
+        case GI_TYPE_TAG_ARRAY:
+        case GI_TYPE_TAG_GLIST:
+        case GI_TYPE_TAG_GSLIST:
+        case GI_TYPE_TAG_GHASH:
+        default:
+            break;
         }
     }
     return is_simple;
diff --git a/gi/function.cpp b/gi/function.cpp
index 01bf596..89c295f 100644
--- a/gi/function.cpp
+++ b/gi/function.cpp
@@ -45,6 +45,11 @@
 #include <errno.h>
 #include <string.h>
 
+/* -Wswitch-enum: We do a lot of switching on GI type enums here, and it would
+ * be unreadable to list each of the 20 or so enum values every time.
+ */
+#pragma GCC diagnostic ignored "-Wswitch-enum"
+
 /* We use guint8 for arguments; functions can't
  * have more than this.
  */
@@ -942,6 +947,9 @@ gjs_invoke_c_function(JSContext       *context,
                     failed = true;
                     break;
                 }
+
+            default:
+                ;
             }
 
             if (direction == GI_DIRECTION_INOUT && !arg_removed && !failed) {
diff --git a/gi/object.cpp b/gi/object.cpp
index f1fee8f..82e3884 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -359,6 +359,7 @@ object_instance_set_prop(JSContext              *context,
     case NO_SUCH_G_PROPERTY:
         goto out;
     case VALUE_WAS_SET:
+    default:
         break;
     }
 
@@ -721,6 +722,7 @@ object_instance_props_to_g_parameters(JSContext   *context,
             g_free(name);
             goto free_array_and_fail;
         case VALUE_WAS_SET:
+        default:
             break;
         }
 
diff --git a/gi/repo.cpp b/gi/repo.cpp
index 1975355..cf23b98 100644
--- a/gi/repo.cpp
+++ b/gi/repo.cpp
@@ -45,6 +45,11 @@
 #include <girepository.h>
 #include <string.h>
 
+/* -Wswitch-enum: We do a lot of switching on GI type enums here, and it would
+ * be unreadable to list each of the 20 or so enum values every time.
+ */
+#pragma GCC diagnostic ignored "-Wswitch-enum"
+
 typedef struct {
     void *dummy;
 
@@ -703,9 +708,9 @@ gjs_info_type_name(GIInfoType type)
     case GI_INFO_TYPE_INVALID_0:
         g_assert_not_reached();
         break;
+    default:
+      return "???";
     }
-
-    return "???";
 }
 
 char*
diff --git a/gi/value.cpp b/gi/value.cpp
index 1c5cc34..f46c6c3 100644
--- a/gi/value.cpp
+++ b/gi/value.cpp
@@ -41,6 +41,11 @@
 
 #include <girepository.h>
 
+/* -Wswitch-enum: We do a lot of switching on GI type enums here, and it would
+ * be unreadable to list each of the 20 or so enum values every time.
+ */
+#pragma GCC diagnostic ignored "-Wswitch-enum"
+
 static bool gjs_value_from_g_value_internal(JSContext    *context,
                                             JS::Value    *value_p,
                                             const GValue *gvalue,
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index 9e07c65..4b5383d 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -824,6 +824,9 @@ importer_new_enumerate(JSContext  *context,
             statep.setNull();
         }
     }
+
+    default:
+        ;
     }
 
     return true;
diff --git a/gjs/jsapi-private.cpp b/gjs/jsapi-private.cpp
index d7713f6..e0314e3 100644
--- a/gjs/jsapi-private.cpp
+++ b/gjs/jsapi-private.cpp
@@ -67,6 +67,8 @@ gjs_error_reporter(JSContext     *context,
              */
         case 162:
             return;
+        default:
+            ;
         }
     } else {
         warning = "REPORTED";
diff --git a/modules/cairo-surface.cpp b/modules/cairo-surface.cpp
index af9ca15..6ed13ea 100644
--- a/modules/cairo-surface.cpp
+++ b/modules/cairo-surface.cpp
@@ -29,6 +29,11 @@
 #include <cairo-gobject.h>
 #include "cairo-private.h"
 
+/* -Wswitch-enum: We have a switch on Cairo surface type enum here, and it would
+ * be unreadable to list each of the 20 or so enum values every time.
+ */
+#pragma GCC diagnostic ignored "-Wswitch-enum"
+
 typedef struct {
     void            *dummy;
     JSContext       *context;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]