Make GS macro return proper IDType type
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 28 Aug 2017 09:19:58 +0000 (11:19 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 28 Aug 2017 09:21:55 +0000 (11:21 +0200)
Previously it was returning short, which was really easy to (a) compare against
non-ID type value (b) forget to handle some specific value in switch statement.

Both issues happened in the nearest past, so it's time to tighten some nuts
here.

Most of the change related on silencing strict compiler warning now, but there
is also one tricky aspect: ID_NLA is not in the IDType enum. So there is still
cast to short to handle that switch. If someone has better ideas how to deal
with this please go ahead :)

22 files changed:
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/icons.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object_deform.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/texture.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/render/render_shading.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_time/space_time.c
source/blender/makesdna/DNA_ID.h
source/blender/makesrna/intern/rna_image.c
source/blender/makesrna/intern/rna_key.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_texture.c
source/blender/windowmanager/intern/wm_operators.c

index 6afa251bce787e0c60bb47ed58079183cc21b37d..64b33326aa95af166a2e6c4cfb16b6eb0b930c2c 100644 (file)
@@ -624,6 +624,8 @@ char *BKE_animdata_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *p
                                        }
                                        break;
                                }
+                               default:
+                                       break;
                        }
 
                        /* fix RNA pointer, as we've now changed the ID root by changing the paths */
index bccf930791216b11d8342c6fded9aeabf04aaa48..a98a1b13402d410795860512df06594c4040b97d 100644 (file)
@@ -253,6 +253,8 @@ PreviewImage **BKE_previewimg_id_get_p(const ID *id)
                ID_PRV_CASE(ID_GR, Group);
                ID_PRV_CASE(ID_SCE, Scene);
 #undef ID_PRV_CASE
+               default:
+                       break;
        }
 
        return NULL;
index 364817438c5ffd819b9e664d63acf99b88870aff..fd42556067e7c0486514c8a73c295c78514b6ce5 100644 (file)
@@ -146,6 +146,9 @@ Key *BKE_key_add(ID *id)    /* common function */
                        key->elemsize = 16;
 
                        break;
+
+               default:
+                       break;
        }
        
        return key;
@@ -1406,6 +1409,8 @@ Key **BKE_key_from_id_p(ID *id)
                        Lattice *lt = (Lattice *)id;
                        return &lt->key;
                }
+               default:
+                       break;
        }
 
        return NULL;
index 710af30aa3ae456b9860df5f33a965b420b29468..f5be72c6b4dd6a17c7a11843ad6265172e9f0e4f 100644 (file)
@@ -361,6 +361,8 @@ Material ***give_matarar_id(ID *id)
                        return &(((Curve *)id)->mat);
                case ID_MB:
                        return &(((MetaBall *)id)->mat);
+               default:
+                       break;
        }
        return NULL;
 }
@@ -377,6 +379,8 @@ short *give_totcolp_id(ID *id)
                        return &(((Curve *)id)->totcol);
                case ID_MB:
                        return &(((MetaBall *)id)->totcol);
+               default:
+                       break;
        }
        return NULL;
 }
@@ -396,6 +400,8 @@ static void material_data_index_remove_id(ID *id, short index)
                case ID_MB:
                        /* meta-elems don't have materials atm */
                        break;
+               default:
+                       break;
        }
 }
 
@@ -414,6 +420,8 @@ static void material_data_index_clear_id(ID *id)
                case ID_MB:
                        /* meta-elems don't have materials atm */
                        break;
+               default:
+                       break;
        }
 }
 
index ccf2aec5c7aa2ad9556ae6dcf8ca89aaf7a8b17c..d387e30050c9c267cbeec8d71038a5961be13cf6 100644 (file)
@@ -481,6 +481,8 @@ bool BKE_object_defgroup_array_get(ID *id, MDeformVert **dvert_arr, int *dvert_t
                                *dvert_tot = lt->pntsu * lt->pntsv * lt->pntsw;
                                return true;
                        }
+                       default:
+                               break;
                }
        }
 
index 64f90ef5c520be61568451bd1b0bedd9abdd60fc..89f25136caf0efc699fc5ccefd7b61c42cd7ca69 100644 (file)
@@ -522,6 +522,8 @@ static void unpack_generate_paths(
                case ID_IM:
                        BLI_snprintf(r_relpath, relpathlen, "//textures/%s", tempname);
                        break;
+               default:
+                       break;
        }
 
        {
@@ -712,6 +714,8 @@ bool BKE_pack_check(ID *id)
                        Library *li = (Library *)id;
                        return li->packedfile != NULL;
                }
+               default:
+                       break;
        }
        return false;
 }
@@ -750,5 +754,7 @@ void BKE_unpack_id(Main *bmain, ID *id, ReportList *reports, int how)
                        BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);
                        break;
                }
+               default:
+                       break;
        }
 }
index e733f9dbd863145477e71af45d43f5334eb48ffc..3a04bd79360508c47356272d39dfd3234fde1ef3 100644 (file)
@@ -377,6 +377,8 @@ static void seqclipboard_ptr_restore(Main *bmain, ID **id_pt)
                                        }
                                        break;
                                }
+                               default:
+                                       break;
                        }
                }
 
index 89a3842a23098fc024183dd8e4d330490ac219ba..8f0334a475278e329fbe396f8b749360f0264676 100644 (file)
@@ -1129,6 +1129,8 @@ void set_active_mtex(ID *id, short act)
                case ID_PA:
                        ((ParticleSettings *)id)->texact = act;
                        break;
+               default:
+                       break;
        }
 }
 
index 319643737167bf9d891ca6b4a95865d2e8b139f1..ff4c52967f35e3d5acddaaecad6716986bd1c471 100644 (file)
@@ -9912,6 +9912,8 @@ void BLO_expand_main(void *fdhandle, Main *mainvar)
                                        case ID_CF:
                                                expand_cachefile(fd, mainvar, (CacheFile *)id);
                                                break;
+                                       default:
+                                               break;
                                        }
                                        
                                        do_it = true;
index 2f73eb6b71c875252fa5d47bf44704f06fc6eb00..e18560b95aff10e238940239f72f92ad566856f2 100644 (file)
@@ -2247,6 +2247,8 @@ static void animfilter_modifier_idpoin_cb(void *afm_ptr, Object *ob, ID **idpoin
                }
                
                /* TODO: images? */
+               default:
+                       break;
        }
 }
 
index 4408ec26b3f01b91b87e9b3651bf07c0a75cf20d..0a27fe14de7d9566ad7b27528b478eea3d1145b4 100644 (file)
@@ -1052,6 +1052,8 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe
                                DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
                                break;
                        }
+                       default:
+                               break;
                }
                
                /* send notifiers for updates (this doesn't require context to work!) */
index 3c406764157de5dd26445653e6627b35f6ec5a09..1ae3961360cebdeaf00eb8ca9f81f13779edb385 100644 (file)
@@ -238,6 +238,9 @@ bool ED_vgroup_parray_alloc(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, co
                                }
                                return false;
                        }
+
+                       default:
+                               break;
                }
        }
 
index 28bce6b3798dfc3374842c1d396b7c9e1f6f141e..d252d764b42c20ad5596ad321aeb56bd5b474d90 100644 (file)
@@ -1781,6 +1781,8 @@ static void copy_mtex_copybuf(ID *id)
                case ID_LS:
                        mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
                        break;
+               default:
+                       break;
        }
        
        if (mtex && *mtex) {
index 121fe8120168306203c0dd3ba261755a3f404e9c..af6fdf2ab866ca4a62a8c2e060975d1e22e6c102 100644 (file)
@@ -1273,7 +1273,10 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
                        }
                }
                else {
-                       switch (GS(tselem->id->name)) {
+                       /* TODO(sergey): Casting to short here just to handle ID_NLA which is
+                        * NOT inside of IDType enum.
+                        */
+                       switch ((short)GS(tselem->id->name)) {
                                case ID_SCE:
                                        tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break;
                                case ID_ME:
@@ -1343,6 +1346,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
                                        tselem_draw_icon_uibut(&arg, ICON_LINE_DATA); break;
                                case ID_GD:
                                        tselem_draw_icon_uibut(&arg, ICON_GREASEPENCIL); break;
+                               default:
+                                       break;
                        }
                }
        }
index 09a49f201d4e5199b9df6dbad9f4867814679765..4b0b0e2e0f060dbc9b4b5038f69894021672b3e7 100644 (file)
@@ -882,6 +882,8 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor
                        }
                        break;
                }
+               default:
+                       break;
        }
 }
 
index 15eb154c757b5740300119eeceb68d16865e2bcd..f29d2b30ffef0672d447e87c012ee95495929c12 100644 (file)
@@ -329,6 +329,8 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel)
                case ID_CF:
                        cachefile_to_keylist(&ads, (CacheFile *)id, &keys, NULL);
                        break;
+               default:
+                       break;
        }
                
        /* build linked-list for searching */
index a940e4bf65d925a37032115e9eb23f9d697300ff..b2a3cb4f9bc3ff24aae8de8f67281785d177b261 100644 (file)
@@ -287,7 +287,7 @@ typedef enum ID_Type {
 #ifdef GS
 #  undef GS
 #endif
-#define GS(a)  (CHECK_TYPE_ANY(a, char *, const char *, char [66], const char[66]), (*((const short *)(a))))
+#define GS(a)  (CHECK_TYPE_ANY(a, char *, const char *, char [66], const char[66]), (ID_Type)(*((const short *)(a))))
 
 #define ID_NEW_SET(_id, _idn) \
        (((ID *)(_id))->newid = (ID *)(_idn), ((ID *)(_id))->newid->tag |= LIB_TAG_NEW, (void *)((ID *)(_id))->newid)
index b6e84cf8ac355946c454d7da1f73a52d372b8d8b..5ca7e624d88bcfcfa58cec20ba662fe74640232d 100644 (file)
@@ -192,6 +192,8 @@ static char *rna_ImageUser_path(PointerRNA *ptr)
                        {
                                return rna_Node_ImageUser_path(ptr);
                        }
+                       default:
+                               break;
                }
        }
        
index a5abc8a3be20ffda012b382abee4109bec3f9832..b960890457b3652bd15f30a37ad39f0690dd0655 100644 (file)
@@ -178,6 +178,8 @@ static Mesh *rna_KeyBlock_normals_get_mesh(PointerRNA *ptr, ID *id)
                                        return ob->data;
                                }
                        }
+                       default:
+                               break;
                }
        }
 
index 7a1b5bb678bf0ce2de9c49d15397d2ede0f335ed..2fd471a66efff8404b6c84a93ee2fcb5d58b6e03 100644 (file)
@@ -1045,6 +1045,8 @@ static void rna_SpaceProperties_pin_id_update(Main *UNUSED(bmain), Scene *UNUSED
                case ID_LA:
                        WM_main_add_notifier(NC_LAMP, NULL);
                        break;
+               default:
+                       break;
        }
 }
 
index 1e88585a2863bebd7d53343f6f293a4e2299f178..4ad2832b9530dd3fe07c3a3afd6957bce8ef651e 100644 (file)
@@ -267,6 +267,8 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
                        WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
                        break;
                }
+               default:
+                       break;
        }
 }
 
index 9314e7af5333f8c702d0fe3724f9128a93216de1..51c551cd9a531ceef655c10fb9710750e6abb864 100644 (file)
@@ -907,6 +907,8 @@ static char *wm_prop_pystring_from_context(bContext *C, PointerRNA *ptr, Propert
                                CTX_TEST_SPACE_TYPE(SPACE_FILE, "space_data.params", CTX_wm_space_file(C)->params);
                                break;
                        }
+                       default:
+                               break;
                }
 
                if (member_id) {