[Bf-blender-cvs] [7d0a0b8a6da] master: Cleanup: Editors/Armature, Clang-Tidy else-after-return fixes

Sybren A. Stüvel noreply at git.blender.org
Fri Jul 3 16:15:11 CEST 2020


Commit: 7d0a0b8a6da0e1cd41a1b40971e7c803ed162963
Author: Sybren A. Stüvel
Date:   Fri Jul 3 14:52:32 2020 +0200
Branches: master
https://developer.blender.org/rB7d0a0b8a6da0e1cd41a1b40971e7c803ed162963

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.

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

M	source/blender/editors/armature/armature_add.c
M	source/blender/editors/armature/armature_edit.c
M	source/blender/editors/armature/armature_relations.c
M	source/blender/editors/armature/armature_select.c
M	source/blender/editors/armature/armature_utils.c
M	source/blender/editors/armature/meshlaplacian.c
M	source/blender/editors/armature/pose_group.c
M	source/blender/editors/armature/pose_lib.c
M	source/blender/editors/armature/pose_select.c
M	source/blender/editors/armature/pose_slide.c

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

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);
-  }
+
+  /* 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list