Cleanup: break before the default case in switch statements

While missing the break before a default that only breaks isn't
an error, it means adding new cases needs to remember to add the
break for an existing case, changing the default case will also
result in an unintended fall-through.

Also avoid `default:;` and add an explicit break.
This commit is contained in:
Campbell Barton 2022-08-31 15:58:33 +10:00
parent ff651a08b5
commit 70035e6473
7 changed files with 12 additions and 3 deletions

View File

@ -421,6 +421,7 @@ int BKE_id_attribute_data_length(ID *id, CustomDataLayer *layer)
if (mesh->edit_mesh != nullptr) {
return 0;
}
break;
}
default:
break;

View File

@ -62,6 +62,7 @@ void RuntimeBackup::init_from_id(ID *id)
break;
case ID_GD:
gpencil_backup.init_from_gpencil(reinterpret_cast<bGPdata *>(id));
break;
default:
break;
}
@ -104,6 +105,7 @@ void RuntimeBackup::restore_to_id(ID *id)
break;
case ID_GD:
gpencil_backup.restore_to_gpencil(reinterpret_cast<bGPdata *>(id));
break;
default:
break;
}

View File

@ -6754,10 +6754,11 @@ void UI_but_extra_icon_string_info_get(struct bContext *C, uiButExtraOpIcon *ext
if (ui_but_extra_icon_event_operator_string(C, extra_icon, buf, sizeof(buf))) {
tmp = BLI_strdup(buf);
}
break;
}
default:
/* Other types not supported. The caller should expect that outcome, no need to message or
* assert here. */
default:
break;
}

View File

@ -918,6 +918,7 @@ static void menu_search_arg_free_fn(void *data_v)
WM_operator_properties_free(item->op.opptr);
MEM_freeN(item->op.opptr);
}
break;
}
case MenuSearch_Item::Type::RNA: {
break;

View File

@ -1773,7 +1773,8 @@ static void vgroup_lock_all(Object *ob, int action, int mask)
continue;
}
break;
default:;
default:
break;
}
if (dg->flag & DG_LOCK_WEIGHT) {
@ -1795,7 +1796,8 @@ static void vgroup_lock_all(Object *ob, int action, int mask)
continue;
}
break;
default:;
default:
break;
}
switch (action) {

View File

@ -297,6 +297,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
case ID_IM:
case ID_TE: {
DEG_add_generic_id_relation(ctx->node, id, "Nodes Modifier");
break;
}
default: {
/* Purposefully don't add relations for materials. While there are material sockets,

View File

@ -1591,6 +1591,7 @@ static int wm_operator_call_internal(bContext *C,
case WM_OP_EXEC_AREA:
case WM_OP_EXEC_SCREEN:
event = nullptr;
break;
default:
break;
}