[Bf-blender-cvs] [0e78dacb4d3] master: Cleanup: change enum usage so types are explicitly listed

Campbell Barton noreply at git.blender.org
Fri Sep 18 03:17:16 CEST 2020


Commit: 0e78dacb4d30070fd5ac727a7566d54bd11de545
Author: Campbell Barton
Date:   Fri Sep 18 11:06:41 2020 +1000
Branches: master
https://developer.blender.org/rB0e78dacb4d30070fd5ac727a7566d54bd11de545

Cleanup: change enum usage so types are explicitly listed

Structure switch statements so new missing items cause warnings.

===================================================================

M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_templates.c

===================================================================

diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 57e7fb0eb62..c9b3b3cc516 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -415,10 +415,12 @@ const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode)
       return "gpencil_sculpt_tool";
     case PAINT_MODE_WEIGHT_GPENCIL:
       return "gpencil_weight_tool";
-    default:
-      /* invalid paint mode */
-      return NULL;
+    case PAINT_MODE_INVALID:
+      break;
   }
+
+  /* Invalid paint mode. */
+  return NULL;
 }
 
 Paint *BKE_paint_get_active(Scene *sce, ViewLayer *view_layer)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 1a9abe99012..bc04720d5e4 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6221,7 +6221,7 @@ static void placeholders_ensure_valid(Main *bmain)
 
 static const char *dataname(short id_code)
 {
-  switch (id_code) {
+  switch ((ID_Type)id_code) {
     case ID_OB:
       return "Data from OB";
     case ID_ME:
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 6cd005b59e5..d8a2ec53011 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -2257,7 +2257,7 @@ int UI_icon_from_rnaptr(bContext *C, PointerRNA *ptr, int rnaicon, const bool bi
 
 int UI_icon_from_idcode(const int idcode)
 {
-  switch (idcode) {
+  switch ((ID_Type)idcode) {
     case ID_AC:
       return ICON_ACTION;
     case ID_AR:
@@ -2329,14 +2329,21 @@ int UI_icon_from_idcode(const int idcode)
     case ID_SIM:
       /* TODO: Use correct icon. */
       return ICON_PHYSICS;
-    default:
-      return ICON_NONE;
+
+    /* No icons for these ID-types. */
+    case ID_LI:
+    case ID_IP:
+    case ID_KE:
+    case ID_SCR:
+    case ID_WM:
+      break;
   }
+  return ICON_NONE;
 }
 
 int UI_icon_from_object_mode(const int mode)
 {
-  switch (mode) {
+  switch ((eObjectMode)mode) {
     case OB_MODE_OBJECT:
       return ICON_OBJECT_DATAMODE;
     case OB_MODE_EDIT:
@@ -2359,9 +2366,8 @@ int UI_icon_from_object_mode(const int mode)
       return ICON_POSE_HLT;
     case OB_MODE_PAINT_GPENCIL:
       return ICON_GREASEPENCIL;
-    default:
-      return ICON_NONE;
   }
+  return ICON_NONE;
 }
 
 int UI_icon_color_from_collection(const Collection *collection)
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 30b98717505..9d9a7e53c49 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -675,7 +675,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
 static const char *template_id_browse_tip(const StructRNA *type)
 {
   if (type) {
-    switch (RNA_type_to_ID_code(type)) {
+    switch ((ID_Type)RNA_type_to_ID_code(type)) {
       case ID_SCE:
         return N_("Browse Scene to be linked");
       case ID_OB:
@@ -744,6 +744,15 @@ static const char *template_id_browse_tip(const StructRNA *type)
         return N_("Browse Volume Data to be linked");
       case ID_SIM:
         return N_("Browse Simulation to be linked");
+
+      /* Use generic text. */
+      case ID_LI:
+      case ID_IP:
+      case ID_KE:
+      case ID_VF:
+      case ID_GR:
+      case ID_WM:
+        break;
     }
   }
   return N_("Browse ID data to be linked");



More information about the Bf-blender-cvs mailing list