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.
This commit is contained in:
@@ -249,42 +249,41 @@ int mathutils_array_parse_alloc(float **array,
|
||||
memcpy(*array, ((BaseMathObject *)value)->data, size * sizeof(float));
|
||||
return size;
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
PyObject *value_fast = NULL;
|
||||
// *array = NULL;
|
||||
int ret;
|
||||
|
||||
/* non list/tuple cases */
|
||||
if (!(value_fast = PySequence_Fast(value, error_prefix))) {
|
||||
/* PySequence_Fast sets the error */
|
||||
return -1;
|
||||
}
|
||||
PyObject *value_fast = NULL;
|
||||
// *array = NULL;
|
||||
int ret;
|
||||
|
||||
size = PySequence_Fast_GET_SIZE(value_fast);
|
||||
|
||||
if (size < array_min) {
|
||||
Py_DECREF(value_fast);
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s: sequence size is %d, expected > %d",
|
||||
error_prefix,
|
||||
size,
|
||||
array_min);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*array = PyMem_Malloc(size * sizeof(float));
|
||||
|
||||
ret = mathutils_array_parse_fast(*array, size, value_fast, error_prefix);
|
||||
Py_DECREF(value_fast);
|
||||
|
||||
if (ret == -1) {
|
||||
PyMem_Free(*array);
|
||||
}
|
||||
|
||||
return ret;
|
||||
/* non list/tuple cases */
|
||||
if (!(value_fast = PySequence_Fast(value, error_prefix))) {
|
||||
/* PySequence_Fast sets the error */
|
||||
return -1;
|
||||
}
|
||||
|
||||
size = PySequence_Fast_GET_SIZE(value_fast);
|
||||
|
||||
if (size < array_min) {
|
||||
Py_DECREF(value_fast);
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"%.200s: sequence size is %d, expected > %d",
|
||||
error_prefix,
|
||||
size,
|
||||
array_min);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*array = PyMem_Malloc(size * sizeof(float));
|
||||
|
||||
ret = mathutils_array_parse_fast(*array, size, value_fast, error_prefix);
|
||||
Py_DECREF(value_fast);
|
||||
|
||||
if (ret == -1) {
|
||||
PyMem_Free(*array);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* parse an array of vectors */
|
||||
@@ -482,45 +481,41 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
eulO_to_mat3(rmat, ((EulerObject *)value)->eul, ((EulerObject *)value)->order);
|
||||
return 0;
|
||||
}
|
||||
|
||||
eulO_to_mat3(rmat, ((EulerObject *)value)->eul, ((EulerObject *)value)->order);
|
||||
return 0;
|
||||
}
|
||||
else if (QuaternionObject_Check(value)) {
|
||||
if (QuaternionObject_Check(value)) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
float tquat[4];
|
||||
normalize_qt_qt(tquat, ((QuaternionObject *)value)->quat);
|
||||
quat_to_mat3(rmat, tquat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
float tquat[4];
|
||||
normalize_qt_qt(tquat, ((QuaternionObject *)value)->quat);
|
||||
quat_to_mat3(rmat, tquat);
|
||||
return 0;
|
||||
}
|
||||
else if (MatrixObject_Check(value)) {
|
||||
if (MatrixObject_Check(value)) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
|
||||
return -1;
|
||||
}
|
||||
else if (((MatrixObject *)value)->num_row < 3 || ((MatrixObject *)value)->num_col < 3) {
|
||||
if (((MatrixObject *)value)->num_row < 3 || ((MatrixObject *)value)->num_col < 3) {
|
||||
PyErr_Format(
|
||||
PyExc_ValueError, "%.200s: matrix must have minimum 3x3 dimensions", error_prefix);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
matrix_as_3x3(rmat, (MatrixObject *)value);
|
||||
normalize_m3(rmat);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: expected a Euler, Quaternion or Matrix type, "
|
||||
"found %.200s",
|
||||
error_prefix,
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
|
||||
matrix_as_3x3(rmat, (MatrixObject *)value);
|
||||
normalize_m3(rmat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"%.200s: expected a Euler, Quaternion or Matrix type, "
|
||||
"found %.200s",
|
||||
error_prefix,
|
||||
Py_TYPE(value)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ----------------------------------MATRIX FUNCTIONS-------------------- */
|
||||
|
||||
Reference in New Issue
Block a user