From 7d0a0b8a6da0e1cd41a1b40971e7c803ed162963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Jul 2020 14:52:32 +0200 Subject: Cleanup: Editors/Armature, Clang-Tidy else-after-return fixes This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/editors/armature` module. No functional changes. --- source/blender/editors/armature/armature_add.c | 17 +++---- source/blender/editors/armature/armature_edit.c | 6 ++- .../blender/editors/armature/armature_relations.c | 6 +-- source/blender/editors/armature/armature_select.c | 13 +++--- source/blender/editors/armature/armature_utils.c | 4 +- source/blender/editors/armature/meshlaplacian.c | 6 +-- source/blender/editors/armature/pose_group.c | 17 +++---- source/blender/editors/armature/pose_lib.c | 33 +++++--------- source/blender/editors/armature/pose_select.c | 6 +-- source/blender/editors/armature/pose_slide.c | 52 +++++++++------------- 10 files changed, 61 insertions(+), 99 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 895b4953992..016a00bda56 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -182,9 +182,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) if (flipbone == NULL) { break; } - else { - SWAP(EditBone *, flipbone, ebone); - } + SWAP(EditBone *, flipbone, ebone); } newbone = ED_armature_ebone_add(arm, ebone->name); @@ -1084,13 +1082,12 @@ static EditBone *get_symmetrized_bone(bArmature *arm, EditBone *bone) if (bone == NULL) { return NULL; } - else if (bone->temp.ebone != NULL) { + if (bone->temp.ebone != NULL) { return bone->temp.ebone; } - else { - EditBone *mirror = ED_armature_ebone_get_mirrored(arm->edbo, bone); - return (mirror != NULL) ? mirror : bone; - } + + EditBone *mirror = ED_armature_ebone_get_mirrored(arm->edbo, bone); + return (mirror != NULL) ? mirror : bone; } /** @@ -1417,9 +1414,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) if (flipbone == NULL) { break; } - else { - SWAP(EditBone *, flipbone, ebone); - } + SWAP(EditBone *, flipbone, ebone); } totbone++; diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index a010fbd5e81..113fd54713e 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -728,7 +728,8 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No joints selected"); return OPERATOR_CANCELLED; } - else if (mixed_object_error) { + + if (mixed_object_error) { BKE_report(op->reports, RPT_ERROR, "Bones for different objects selected"); BLI_freelistN(&points); return OPERATOR_CANCELLED; @@ -1093,7 +1094,8 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone"); return OPERATOR_CANCELLED; } - else if (arm->flag & ARM_MIRROR_EDIT) { + + if (arm->flag & ARM_MIRROR_EDIT) { /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone * (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R"). diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index f90d781baca..0dd35fb9fdc 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -207,7 +207,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data id, dtar->rna_path, "pose.bones", old_name, new_name, 0, 0, false); break; /* no need to try any more names for bone path */ } - else if (STREQ(dtar->pchan_name, old_name)) { + if (STREQ(dtar->pchan_name, old_name)) { /* Change target bone name */ BLI_strncpy(dtar->pchan_name, new_name, sizeof(dtar->pchan_name)); break; /* no need to try any more names for bone subtarget */ @@ -636,7 +636,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op) has_selected_bone = true; break; } - else if (ebone->flag & (BONE_TIPSEL | BONE_ROOTSEL)) { + if (ebone->flag & (BONE_TIPSEL | BONE_ROOTSEL)) { has_selected_any = true; } } @@ -816,7 +816,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone"); return OPERATOR_CANCELLED; } - else if (arm->flag & ARM_MIRROR_EDIT) { + if (arm->flag & ARM_MIRROR_EDIT) { /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone: * - If there's a mirrored copy of selbone, try to find a mirrored copy of actbone * (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R"). diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index ccd39429704..7fba855ffdb 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -263,10 +263,8 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode *r_base = firstunSel_base; return firstunSel; } - else { - *r_base = firstSel_base; - return firstSel; - } + *r_base = firstSel_base; + return firstSel; } EditBone *ED_armature_pick_ebone_from_selectbuffer(Base **bases, @@ -2253,10 +2251,9 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const return OPERATOR_FINISHED; } - else { - BKE_report(op->reports, RPT_WARNING, "Unselectable bone in chain"); - return OPERATOR_CANCELLED; - } + + BKE_report(op->reports, RPT_WARNING, "Unselectable bone in chain"); + return OPERATOR_CANCELLED; } void ARMATURE_OT_shortest_path_pick(wmOperatorType *ot) diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 34f2b4f12be..b2e329deee7 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -915,9 +915,7 @@ int ED_armature_ebone_selectflag_get(const EditBone *ebone) return ((ebone->flag & (BONE_SELECTED | BONE_TIPSEL)) | ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0)); } - else { - return (ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)); - } + return (ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)); } void ED_armature_ebone_selectflag_set(EditBone *ebone, int flag) diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 145071522ed..23fb6c0ab27 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -640,13 +640,11 @@ static float heat_limit_weight(float weight) if (weight < WEIGHT_LIMIT_END) { return 0.0f; } - else if (weight < WEIGHT_LIMIT_START) { + if (weight < WEIGHT_LIMIT_START) { t = (weight - WEIGHT_LIMIT_END) / (WEIGHT_LIMIT_START - WEIGHT_LIMIT_END); return t * WEIGHT_LIMIT_START; } - else { - return weight; - } + return weight; } void heat_bone_weighting(Object *ob, diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index c10e204e3a4..cb7c68178d9 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -177,11 +177,10 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U return OPERATOR_INTERFACE; } - else { - /* just use the active group index, and call the exec callback for the calling operator */ - RNA_int_set(op->ptr, "type", pose->active_group); - return op->type->exec(C, op); - } + + /* just use the active group index, and call the exec callback for the calling operator */ + RNA_int_set(op->ptr, "type", pose->active_group); + return op->type->exec(C, op); } /* Assign selected pchans to the bone group that the user selects */ @@ -221,9 +220,7 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op) if (done) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void POSE_OT_group_assign(wmOperatorType *ot) @@ -272,9 +269,7 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) if (done) { return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void POSE_OT_group_unassign(wmOperatorType *ot) diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index aa57fb5844d..9d70f8877c6 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -141,9 +141,7 @@ static int poselib_get_free_index(bAction *act) if (low < high) { return (low + 1); } - else { - return (high + 1); - } + return (high + 1); } /* returns the active pose for a poselib */ @@ -152,9 +150,7 @@ static TimeMarker *poselib_get_active_pose(bAction *act) if ((act) && (act->active_marker)) { return BLI_findlink(&act->markers, act->active_marker - 1); } - else { - return NULL; - } + return NULL; } /* Get object that Pose Lib should be found on */ @@ -173,9 +169,7 @@ static Object *get_poselib_object(bContext *C) if (area && (area->spacetype == SPACE_PROPERTIES)) { return ED_object_context(C); } - else { - return BKE_object_pose_armature_get(CTX_data_active_object(C)); - } + return BKE_object_pose_armature_get(CTX_data_active_object(C)); } /* Poll callback for operators that require existing PoseLib data (with poses) to work */ @@ -221,12 +215,10 @@ static bAction *poselib_validate(Main *bmain, Object *ob) if (ELEM(NULL, ob, ob->pose)) { return NULL; } - else if (ob->poselib == NULL) { + if (ob->poselib == NULL) { return poselib_init_new(bmain, ob); } - else { - return ob->poselib; - } + return ob->poselib; } /* ************************************************************* */ @@ -697,12 +689,11 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve BKE_report(op->reports, RPT_ERROR, "Invalid index for pose"); return OPERATOR_CANCELLED; } - else { - /* Use the existing name of the marker as the name, - * and use the active marker as the one to rename. */ - RNA_enum_set(op->ptr, "pose", act->active_marker - 1); - RNA_string_set(op->ptr, "name", marker->name); - } + + /* Use the existing name of the marker as the name, + * and use the active marker as the one to rename. */ + RNA_enum_set(op->ptr, "pose", act->active_marker - 1); + RNA_string_set(op->ptr, "name", marker->name); /* part to sync with other similar operators... */ return WM_operator_props_popup_confirm(C, op, event); @@ -1755,9 +1746,7 @@ static int poselib_preview_exit(bContext *C, wmOperator *op) if (ELEM(exit_state, PL_PREVIEW_CANCEL, PL_PREVIEW_ERROR)) { return OPERATOR_CANCELLED; } - else { - return OPERATOR_FINISHED; - } + return OPERATOR_FINISHED; } /* Cancel previewing operation (called when exiting Blender) */ diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 9525fcf2154..0e766e6a75f 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -1016,7 +1016,7 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex BKE_report(reports, RPT_ERROR, "No active Keying Set to use"); return false; } - else if (ANIM_validate_keyingset(C, NULL, ks) != 0) { + if (ANIM_validate_keyingset(C, NULL, ks) != 0) { if (ks->paths.first == NULL) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { BKE_report(reports, @@ -1129,9 +1129,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - else { - return OPERATOR_CANCELLED; - } + return OPERATOR_CANCELLED; } void POSE_OT_select_grouped(wmOperatorType *ot) diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index d9621dba730..8df9c99896e 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -1122,7 +1122,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) do_pose_update = true; break; } - else if (event->val == KM_PRESS) { + if (event->val == KM_PRESS) { switch (event->type) { /* Transform Channel Limits */ /* XXX: Replace these hardcoded hotkeys with a modalmap that can be customised */ @@ -1307,9 +1307,8 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* initialise percentage so that it won't pop on first mouse move */ pose_slide_mouse_update_percentage(pso, op, event); @@ -1328,9 +1327,8 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op) pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -1369,9 +1367,8 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* initialise percentage so that it won't pop on first mouse move */ pose_slide_mouse_update_percentage(pso, op, event); @@ -1390,9 +1387,8 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op) pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -1430,9 +1426,8 @@ static int pose_slide_push_rest_invoke(bContext *C, wmOperator *op, const wmEven pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* initialise percentage so that it won't pop on first mouse move */ pose_slide_mouse_update_percentage(pso, op, event); @@ -1451,9 +1446,8 @@ static int pose_slide_push_rest_exec(bContext *C, wmOperator *op) pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -1492,9 +1486,8 @@ static int pose_slide_relax_rest_invoke(bContext *C, wmOperator *op, const wmEve pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* initialise percentage so that it won't pop on first mouse move */ pose_slide_mouse_update_percentage(pso, op, event); @@ -1513,9 +1506,8 @@ static int pose_slide_relax_rest_exec(bContext *C, wmOperator *op) pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -1554,9 +1546,8 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* initialise percentage so that it won't pop on first mouse move */ pose_slide_mouse_update_percentage(pso, op, event); @@ -1575,9 +1566,8 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op) pose_slide_exit(op); return OPERATOR_CANCELLED; } - else { - pso = op->customdata; - } + + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); -- cgit v1.2.3