Cleanup: Use switch
and BLI_assert_unreachable()
more.
Replace some `if/else if` chains by proper `switch` statement. Replace some `BLI_assert(0)` calls by `BLI_assert_unreachable()` ones.
This commit is contained in:
@@ -1125,7 +1125,7 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList *
|
||||
&LOG, "Unexpected unset append action for '%s' ID, assuming 'keep link'", id->name);
|
||||
break;
|
||||
default:
|
||||
BLI_assert(0);
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
|
||||
if (local_appended_new_id != NULL) {
|
||||
|
@@ -3652,7 +3652,7 @@ void CustomData_bmesh_init_pool(CustomData *data, int totelem, const char htype)
|
||||
chunksize = bm_mesh_chunksize_default.totface;
|
||||
break;
|
||||
default:
|
||||
BLI_assert(0);
|
||||
BLI_assert_unreachable();
|
||||
chunksize = 512;
|
||||
break;
|
||||
}
|
||||
|
@@ -222,7 +222,7 @@ int BKE_object_data_transfer_dttype_to_cdtype(const int dtdata_type)
|
||||
case DT_TYPE_MPROPCOL_LOOP:
|
||||
return CD_PROP_COLOR;
|
||||
default:
|
||||
BLI_assert(0);
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
return 0; /* Should never be reached! */
|
||||
}
|
||||
|
@@ -114,32 +114,35 @@ static void icon_free(void *val)
|
||||
|
||||
static void icon_free_data(int icon_id, Icon *icon)
|
||||
{
|
||||
if (icon->obj_type == ICON_DATA_ID) {
|
||||
((ID *)(icon->obj))->icon_id = 0;
|
||||
}
|
||||
else if (icon->obj_type == ICON_DATA_IMBUF) {
|
||||
ImBuf *imbuf = (ImBuf *)icon->obj;
|
||||
if (imbuf) {
|
||||
IMB_freeImBuf(imbuf);
|
||||
switch (icon->obj_type) {
|
||||
case ICON_DATA_ID:
|
||||
((ID *)(icon->obj))->icon_id = 0;
|
||||
break;
|
||||
case ICON_DATA_IMBUF: {
|
||||
ImBuf *imbuf = (ImBuf *)icon->obj;
|
||||
if (imbuf) {
|
||||
IMB_freeImBuf(imbuf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (icon->obj_type == ICON_DATA_PREVIEW) {
|
||||
((PreviewImage *)(icon->obj))->icon_id = 0;
|
||||
}
|
||||
else if (icon->obj_type == ICON_DATA_GPLAYER) {
|
||||
((bGPDlayer *)(icon->obj))->runtime.icon_id = 0;
|
||||
}
|
||||
else if (icon->obj_type == ICON_DATA_GEOM) {
|
||||
((struct Icon_Geom *)(icon->obj))->icon_id = 0;
|
||||
}
|
||||
else if (icon->obj_type == ICON_DATA_STUDIOLIGHT) {
|
||||
StudioLight *sl = (StudioLight *)icon->obj;
|
||||
if (sl != nullptr) {
|
||||
BKE_studiolight_unset_icon_id(sl, icon_id);
|
||||
case ICON_DATA_PREVIEW:
|
||||
((PreviewImage *)(icon->obj))->icon_id = 0;
|
||||
break;
|
||||
case ICON_DATA_GPLAYER:
|
||||
((bGPDlayer *)(icon->obj))->runtime.icon_id = 0;
|
||||
break;
|
||||
case ICON_DATA_GEOM:
|
||||
((struct Icon_Geom *)(icon->obj))->icon_id = 0;
|
||||
break;
|
||||
case ICON_DATA_STUDIOLIGHT: {
|
||||
StudioLight *sl = (StudioLight *)icon->obj;
|
||||
if (sl != nullptr) {
|
||||
BKE_studiolight_unset_icon_id(sl, icon_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BLI_assert(0);
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -872,7 +872,7 @@ bool IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const bool is
|
||||
case IDP_ID:
|
||||
return (IDP_Id(prop1) == IDP_Id(prop2));
|
||||
default:
|
||||
BLI_assert(0);
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -181,7 +181,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
BLI_assert(0);
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -1223,7 +1223,7 @@ static ID *lib_override_root_find(Main *bmain, ID *id, const int curr_level, int
|
||||
}
|
||||
|
||||
if (!ID_IS_OVERRIDE_LIBRARY(id)) {
|
||||
BLI_assert(0);
|
||||
BLI_assert_unreachable();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2087,9 +2087,7 @@ static bool lib_override_resync_tagging_finalize_recurse(
|
||||
|
||||
CLOG_INFO(&LOG, 4, "Found root ID '%s' for resync root ID '%s'", id_root->name, id->name);
|
||||
|
||||
if (id_root->override_library == NULL) {
|
||||
BLI_assert(0);
|
||||
}
|
||||
BLI_assert(id_root->override_library != NULL);
|
||||
|
||||
LinkNodePair **id_resync_roots_p;
|
||||
if (!BLI_ghash_ensure_p(id_roots, id_root, (void ***)&id_resync_roots_p)) {
|
||||
|
@@ -75,6 +75,7 @@ static void foreach_libblock_remap_callback_skip(const ID *UNUSED(id_owner),
|
||||
{
|
||||
ID *id = *id_ptr;
|
||||
BLI_assert(id != NULL);
|
||||
|
||||
if (is_indirect) {
|
||||
id->runtime.remap.skipped_indirect++;
|
||||
}
|
||||
@@ -82,8 +83,9 @@ static void foreach_libblock_remap_callback_skip(const ID *UNUSED(id_owner),
|
||||
id->runtime.remap.skipped_direct++;
|
||||
}
|
||||
else {
|
||||
BLI_assert(0);
|
||||
BLI_assert_unreachable();
|
||||
}
|
||||
|
||||
if (cb_flag & IDWALK_CB_USER) {
|
||||
id->runtime.remap.skipped_refcounted++;
|
||||
}
|
||||
|
@@ -1822,7 +1822,7 @@ void BKE_mesh_mselect_validate(Mesh *me)
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
BLI_assert(0);
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user