[Bf-blender-cvs] [3d48d99647b] master: Cleanup: Python, Clang-Tidy else-after-return fixes

Sybren A. Stüvel noreply at git.blender.org
Fri Aug 7 13:48:45 CEST 2020


Commit: 3d48d99647b59a6f0461baa4456660917f1bbda6
Author: Sybren A. Stüvel
Date:   Fri Aug 7 12:41:06 2020 +0200
Branches: master
https://developer.blender.org/rB3d48d99647b59a6f0461baa4456660917f1bbda6

Cleanup: Python, Clang-Tidy else-after-return fixes

This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/python` module.

No functional changes.

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

M	source/blender/python/bmesh/bmesh_py_ops.c
M	source/blender/python/bmesh/bmesh_py_ops_call.c
M	source/blender/python/bmesh/bmesh_py_types.c
M	source/blender/python/bmesh/bmesh_py_types_customdata.c
M	source/blender/python/bmesh/bmesh_py_types_meshdata.c
M	source/blender/python/bmesh/bmesh_py_types_select.c
M	source/blender/python/bmesh/bmesh_py_utils.c
M	source/blender/python/generic/bgl.c
M	source/blender/python/generic/idprop_py_api.c
M	source/blender/python/generic/imbuf_py_api.c
M	source/blender/python/generic/py_capi_utils.c
M	source/blender/python/gpu/gpu_py_batch.c
M	source/blender/python/intern/bpy_app_handlers.c
M	source/blender/python/intern/bpy_driver.c
M	source/blender/python/intern/bpy_library_load.c
M	source/blender/python/intern/bpy_props.c
M	source/blender/python/intern/bpy_rna.c
M	source/blender/python/intern/bpy_rna_anim.c
M	source/blender/python/intern/bpy_rna_array.c
M	source/blender/python/intern/bpy_rna_callback.c
M	source/blender/python/intern/bpy_rna_gizmo.c
M	source/blender/python/mathutils/mathutils.c
M	source/blender/python/mathutils/mathutils_Color.c
M	source/blender/python/mathutils/mathutils_Euler.c
M	source/blender/python/mathutils/mathutils_Matrix.c
M	source/blender/python/mathutils/mathutils_Quaternion.c
M	source/blender/python/mathutils/mathutils_Vector.c
M	source/blender/python/mathutils/mathutils_bvhtree.c
M	source/blender/python/mathutils/mathutils_geometry.c

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

diff --git a/source/blender/python/bmesh/bmesh_py_ops.c b/source/blender/python/bmesh/bmesh_py_ops.c
index 1eccfe06d15..cdbd4832159 100644
--- a/source/blender/python/bmesh/bmesh_py_ops.c
+++ b/source/blender/python/bmesh/bmesh_py_ops.c
@@ -250,11 +250,9 @@ static PyObject *bpy_bmesh_ops_fakemod_getattro(PyObject *UNUSED(self), PyObject
   if (BMO_opcode_from_opname(opname) != -1) {
     return bpy_bmesh_op_CreatePyObject(opname);
   }
-  else {
-    PyErr_Format(
-        PyExc_AttributeError, "BMeshOpsModule: operator \"%.200s\" doesn't exist", opname);
-    return NULL;
-  }
+
+  PyErr_Format(PyExc_AttributeError, "BMeshOpsModule: operator \"%.200s\" doesn't exist", opname);
+  return NULL;
 }
 
 static PyObject *bpy_bmesh_ops_fakemod_dir(PyObject *UNUSED(self))
diff --git a/source/blender/python/bmesh/bmesh_py_ops_call.c b/source/blender/python/bmesh/bmesh_py_ops_call.c
index b1e5c1c761b..a387ba31c84 100644
--- a/source/blender/python/bmesh/bmesh_py_ops_call.c
+++ b/source/blender/python/bmesh/bmesh_py_ops_call.c
@@ -82,7 +82,7 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value,
                  Py_TYPE(value)->tp_name);
     return -1;
   }
-  else if (value->bm == NULL) {
+  if (value->bm == NULL) {
     PyErr_Format(PyExc_TypeError,
                  "%.200s: keyword \"%.200s\" %.200s invalidated element",
                  opname,
@@ -90,7 +90,7 @@ static int bpy_slot_from_py_elem_check(BPy_BMElem *value,
                  descr);
     return -1;
   }
-  else if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
+  if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
     PyErr_Format(PyExc_TypeError,
                  "%.200s: keyword \"%.200s\" %.200s invalidated element",
                  opname,
@@ -127,7 +127,7 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value,
                  descr);
     return -1;
   }
-  else if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
+  if (value->bm != bm) { /* we may want to make this check optional by setting 'bm' to NULL */
     PyErr_Format(PyExc_TypeError,
                  "%.200s: keyword \"%.200s\" %.200s, invalidated sequence",
                  opname,
@@ -135,7 +135,7 @@ static int bpy_slot_from_py_elemseq_check(BPy_BMGeneric *value,
                  descr);
     return -1;
   }
-  else if ((htype_py & htype_bmo) == 0) {
+  if ((htype_py & htype_bmo) == 0) {
     char str_bmo[32];
     char str_py[32];
     PyErr_Format(PyExc_TypeError,
@@ -175,9 +175,8 @@ static int bpy_slot_from_py(BMesh *bm,
                      Py_TYPE(value)->tp_name);
         return -1;
       }
-      else {
-        BMO_SLOT_AS_BOOL(slot) = param;
-      }
+
+      BMO_SLOT_AS_BOOL(slot) = param;
 
       break;
     }
@@ -223,9 +222,8 @@ static int bpy_slot_from_py(BMesh *bm,
                        Py_TYPE(value)->tp_name);
           return -1;
         }
-        else {
-          BMO_SLOT_AS_INT(slot) = param;
-        }
+
+        BMO_SLOT_AS_INT(slot) = param;
       }
       break;
     }
@@ -239,9 +237,9 @@ static int bpy_slot_from_py(BMesh *bm,
                      Py_TYPE(value)->tp_name);
         return -1;
       }
-      else {
-        BMO_SLOT_AS_FLOAT(slot) = param;
-      }
+
+      BMO_SLOT_AS_FLOAT(slot) = param;
+
       break;
     }
     case BMO_OP_SLOT_MAT: {
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index fccdfe7fbdc..e39b5faf3c4 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -292,14 +292,13 @@ static int bpy_bmesh_select_mode_set(BPy_BMesh *self, PyObject *value)
       -1) {
     return -1;
   }
-  else if (flag == 0) {
+  if (flag == 0) {
     PyErr_SetString(PyExc_TypeError, "bm.select_mode: cant assignt an empty value");
     return -1;
   }
-  else {
-    self->bm->selectmode = flag;
-    return 0;
-  }
+
+  self->bm->selectmode = flag;
+  return 0;
 }
 
 PyDoc_STRVAR(bpy_bmesh_select_history_doc,
@@ -338,9 +337,8 @@ static int bpy_bmvert_co_set(BPy_BMVert *self, PyObject *value)
   if (mathutils_array_parse(self->v->co, 3, 3, value, "BMVert.co") != -1) {
     return 0;
   }
-  else {
-    return -1;
-  }
+
+  return -1;
 }
 
 PyDoc_STRVAR(
@@ -359,9 +357,8 @@ static int bpy_bmvert_normal_set(BPy_BMVert *self, PyObject *value)
   if (mathutils_array_parse(self->v->no, 3, 3, value, "BMVert.normal") != -1) {
     return 0;
   }
-  else {
-    return -1;
-  }
+
+  return -1;
 }
 
 PyDoc_STRVAR(bpy_bmvert_is_manifold_doc,
@@ -453,9 +450,8 @@ static int bpy_bmface_normal_set(BPy_BMFace *self, PyObject *value)
   if (mathutils_array_parse(self->f->no, 3, 3, value, "BMFace.normal") != -1) {
     return 0;
   }
-  else {
-    return -1;
-  }
+
+  return -1;
 }
 
 PyDoc_STRVAR(bpy_bmface_material_index_doc, "The face's material index.\n\n:type: int");
@@ -481,10 +477,9 @@ static int bpy_bmface_material_index_set(BPy_BMFace *self, PyObject *value)
     PyErr_SetString(PyExc_ValueError, "material index outside of usable range (0 - 32766)");
     return -1;
   }
-  else {
-    self->f->mat_nr = (short)param;
-    return 0;
-  }
+
+  self->f->mat_nr = (short)param;
+  return 0;
 }
 
 /* Loop
@@ -586,9 +581,8 @@ static PyObject *bpy_bmfaceseq_active_get(BPy_BMElemSeq *self, void *UNUSED(clos
   if (bm->act_face) {
     return BPy_BMElem_CreatePyObject(bm, (BMHeader *)bm->act_face);
   }
-  else {
-    Py_RETURN_NONE;
-  }
+
+  Py_RETURN_NONE;
 }
 
 static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNUSED(closure))
@@ -598,18 +592,17 @@ static int bpy_bmfaceseq_active_set(BPy_BMElem *self, PyObject *value, void *UNU
     bm->act_face = NULL;
     return 0;
   }
-  else if (BPy_BMFace_Check(value)) {
+  if (BPy_BMFace_Check(value)) {
     BPY_BM_CHECK_SOURCE_INT(bm, "faces.active = f", value);
 
     bm->act_face = ((BPy_BMFace *)value)->f;
     return 0;
   }
-  else {
-    PyErr_Format(PyExc_TypeError,
-                 "faces.active = f: expected BMFace or None, not %.200s",
-                 Py_TYPE(value)->tp_name);
-    return -1;
-  }
+
+  PyErr_Format(PyExc_TypeError,
+               "faces.active = f: expected BMFace or None, not %.200s",
+               Py_TYPE(value)->tp_name);
+  return -1;
 }
 
 static PyGetSetDef bpy_bmesh_getseters[] = {
@@ -971,10 +964,9 @@ static PyObject *bpy_bmesh_copy(BPy_BMesh *self)
   if (bm_copy) {
     return BPy_BMesh_CreatePyObject(bm_copy, BPY_BMFLAG_NOP);
   }
-  else {
-    PyErr_SetString(PyExc_SystemError, "Unable to copy BMesh, internal error");
-    return NULL;
-  }
+
+  PyErr_SetString(PyExc_SystemError, "Unable to copy BMesh, internal error");
+  return NULL;
 }
 
 PyDoc_STRVAR(bpy_bmesh_clear_doc,
@@ -1141,9 +1133,8 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
                         "evaluation mode is RENDER");
         return NULL;
       }
-      else {
-        me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, &data_masks);
-      }
+
+      me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, &data_masks);
     }
     else {
       if (use_cage) {
@@ -1161,7 +1152,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
                       "from_object(...): cage arg is unsupported when deform=False");
       return NULL;
     }
-    else if (use_render) {
+    if (use_render) {
       me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, &data_masks);
     }
     else {
@@ -1329,38 +1320,36 @@ static PyObject *bpy_bmesh_transform(BPy_BMElem *self, PyObject *args, PyObject
                                    &filter)) {
     return NULL;
   }
-  else {
-    BMVert *eve;
-    BMIter iter;
-    void *mat_ptr;
 
-    if (BaseMath_ReadCallback(mat) == -1) {
-      return NULL;
-    }
-    else if (mat->num_col != 4 || mat->num_row != 4) {
-      PyErr_SetString(PyExc_ValueError, "expected a 4x4 matrix");
-      return NULL;
-    }
+  BMVert *eve;
+  BMIter iter;
+  void *mat_ptr;
 
-    if (filter != NULL &&
-        PyC_FlagSet_ToBitfield(bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") ==
-            -1) {
-      return NULL;
-    }
+  if (BaseMath_ReadCallback(mat) == -1) {
+    return NULL;
+  }
+  if (mat->num_col != 4 || mat->num_row != 4) {
+    PyErr_SetString(PyExc_ValueError, "expected a 4x4 matrix");
+    return NULL;
+  }
 
-    mat_ptr = mat->matrix;
+  if (filter != NULL && PyC_FlagSet_ToBitfield(
+                            bpy_bm_hflag_all_flags, filter, &filter_flags, "bm.transform") == -1) {
+    return NULL;
+  }
 
-    if (!filter_flags) {
-      BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
-        mul_m4_v3((float(*)[4])mat_ptr, eve->co);
-      }
+  mat_ptr = mat->matrix;
+
+  if (!filter_flags) {
+    BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
+      mul_m4_v3((float(*)[4])mat_ptr, eve->co);
     }
-    else {
-      char filter_flags_ch = (char)filter_flags;
-      BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
-        if (BM_elem_flag_test(eve, filter_flags_ch)) {
-          mul_m4_v3((float(*)[4])mat_ptr, eve->co);
-        }
+  }
+  else {
+    char filter_flags_ch = (char)filter_flags;
+    BM_ITER_MESH (eve, &iter, self->bm, BM_VERTS_OF_MESH) {
+      if (BM_elem_flag_test(eve, filter_flags_ch)) {
+        mul_m4_v3((float(*)[4])mat_ptr, eve->co);
       }
     }
   }
@@ -1388,9 +1377,8 @@ static PyObject *bpy_bmesh_calc_volume(BPy_BMElem *self, PyObject *args, PyObjec
           args, kw, "|O!:calc_volume", (char **)kwlist, &PyBool_Type, &is_signed)) {
     return NULL;
   }
-  else {
-    return PyFloat_FromDouble(BM_mesh_calc_volume(self->bm, is_signed != Py_False));
-  }
+
+  return PyFloat_FromDouble(BM_mesh_calc_volume(self->bm, is_signed != Py_False));
 }
 
 PyDoc_STRVAR(bpy_bmesh_calc_loop_triangles_doc,
@@ -1531,30 +1519,29 @@ static PyObject *bpy_bmvert_copy_from_vert_interp(BPy_BMVert *self, PyObject *ar
   if (!PyArg_ParseTuple(args, "Of:BMVert.copy_from_vert_interp", &vert_seq, &fac)) {
     return NULL;
   }
-  else {
- 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list