diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-08-07 14:37:22 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-08-07 14:38:07 +0300 |
commit | c04088fed1b8faea6b2928bb5e09ab367076950c (patch) | |
tree | f4aed4491f5af44dade7d84a52901a56fd6dddd7 /source | |
parent | 3d48d99647b59a6f0461baa4456660917f1bbda6 (diff) |
Cleanup: Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule. This should be the final commit of the series of commits that
addresses this particular rule.
No functional changes.
Diffstat (limited to 'source')
20 files changed, 254 insertions, 285 deletions
diff --git a/source/blender/blentranslation/intern/blt_translation.c b/source/blender/blentranslation/intern/blt_translation.c index 0ca068d4263..00118bc72e6 100644 --- a/source/blender/blentranslation/intern/blt_translation.c +++ b/source/blender/blentranslation/intern/blt_translation.c @@ -120,9 +120,9 @@ const char *BLT_translate_do(const char *msgctxt, const char *msgid) if (BLT_translate()) { return BLT_pgettext(msgctxt, msgid); } - else { - return msgid; - } + + return msgid; + #else (void)msgctxt; return msgid; @@ -135,9 +135,9 @@ const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid) if (BLT_translate_iface()) { return BLT_pgettext(msgctxt, msgid); } - else { - return msgid; - } + + return msgid; + #else (void)msgctxt; return msgid; @@ -150,9 +150,9 @@ const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid) if (BLT_translate_tooltips()) { return BLT_pgettext(msgctxt, msgid); } - else { - return msgid; - } + + return msgid; + #else (void)msgctxt; return msgid; @@ -165,9 +165,9 @@ const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid if (BLT_translate_new_dataname()) { return BLT_pgettext(msgctxt, msgid); } - else { - return msgid; - } + + return msgid; + #else (void)msgctxt; return msgid; diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c index 80634618f6f..a9d1972bd7e 100644 --- a/source/blender/bmesh/intern/bmesh_query.c +++ b/source/blender/bmesh/intern/bmesh_query.c @@ -179,13 +179,12 @@ BMLoop *BM_loop_other_vert_loop_by_edge(BMLoop *l, BMEdge *e) if (l->e == e) { return l->next; } - else if (l->prev->e == e) { + if (l->prev->e == e) { return l->prev; } - else { - BLI_assert(0); - return NULL; - } + + BLI_assert(0); + return NULL; } /** diff --git a/source/blender/functions/intern/attributes_ref.cc b/source/blender/functions/intern/attributes_ref.cc index 8f7f41be079..9f1e7fa65e5 100644 --- a/source/blender/functions/intern/attributes_ref.cc +++ b/source/blender/functions/intern/attributes_ref.cc @@ -42,14 +42,13 @@ bool AttributesInfoBuilder::add(StringRef name, const CPPType &type, const void defaults_.append(dst); return true; } - else { - const CPPType &stored_type = *types_[names_.index_of_as(name)]; - if (stored_type != type) { - std::cout << "Warning: Tried to add an attribute twice with different types (" << name - << ": " << stored_type.name() << ", " << type.name() << ").\n"; - } - return false; + + const CPPType &stored_type = *types_[names_.index_of_as(name)]; + if (stored_type != type) { + std::cout << "Warning: Tried to add an attribute twice with different types (" << name << ": " + << stored_type.name() << ", " << type.name() << ").\n"; } + return false; } AttributesInfo::AttributesInfo(const AttributesInfoBuilder &builder) diff --git a/source/blender/functions/intern/multi_function_network_evaluation.cc b/source/blender/functions/intern/multi_function_network_evaluation.cc index 25e983d2eeb..480a048b510 100644 --- a/source/blender/functions/intern/multi_function_network_evaluation.cc +++ b/source/blender/functions/intern/multi_function_network_evaluation.cc @@ -519,7 +519,7 @@ MFNetworkEvaluationStorage::~MFNetworkEvaluationStorage() if (any_value == nullptr) { continue; } - else if (any_value->type == ValueType::OwnSingle) { + if (any_value->type == ValueType::OwnSingle) { OwnSingleValue *value = (OwnSingleValue *)any_value; GMutableSpan span = value->span; const CPPType &type = span.type(); @@ -710,10 +710,9 @@ GMutableSpan MFNetworkEvaluationStorage::get_single_output__full(const MFOutputS return span; } - else { - BLI_assert(any_value->type == ValueType::OutputSingle); - return ((OutputSingleValue *)any_value)->span; - } + + BLI_assert(any_value->type == ValueType::OutputSingle); + return ((OutputSingleValue *)any_value)->span; } GMutableSpan MFNetworkEvaluationStorage::get_single_output__single(const MFOutputSocket &socket) @@ -729,12 +728,11 @@ GMutableSpan MFNetworkEvaluationStorage::get_single_output__single(const MFOutpu return value->span; } - else { - BLI_assert(any_value->type == ValueType::OutputSingle); - GMutableSpan span = ((OutputSingleValue *)any_value)->span; - BLI_assert(span.size() == 1); - return span; - } + + BLI_assert(any_value->type == ValueType::OutputSingle); + GMutableSpan span = ((OutputSingleValue *)any_value)->span; + BLI_assert(span.size() == 1); + return span; } GVectorArray &MFNetworkEvaluationStorage::get_vector_output__full(const MFOutputSocket &socket) @@ -749,10 +747,9 @@ GVectorArray &MFNetworkEvaluationStorage::get_vector_output__full(const MFOutput return *value->vector_array; } - else { - BLI_assert(any_value->type == ValueType::OutputVector); - return *((OutputVectorValue *)any_value)->vector_array; - } + + BLI_assert(any_value->type == ValueType::OutputVector); + return *((OutputVectorValue *)any_value)->vector_array; } GVectorArray &MFNetworkEvaluationStorage::get_vector_output__single(const MFOutputSocket &socket) @@ -767,12 +764,11 @@ GVectorArray &MFNetworkEvaluationStorage::get_vector_output__single(const MFOutp return *value->vector_array; } - else { - BLI_assert(any_value->type == ValueType::OutputVector); - GVectorArray &vector_array = *((OutputVectorValue *)any_value)->vector_array; - BLI_assert(vector_array.size() == 1); - return vector_array; - } + + BLI_assert(any_value->type == ValueType::OutputVector); + GVectorArray &vector_array = *((OutputVectorValue *)any_value)->vector_array; + BLI_assert(vector_array.size() == 1); + return vector_array; } GMutableSpan MFNetworkEvaluationStorage::get_mutable_single__full(const MFInputSocket &input, @@ -955,15 +951,14 @@ GVSpan MFNetworkEvaluationStorage::get_single_input__full(const MFInputSocket &s if (value->is_single_allocated) { return GVSpan::FromSingle(value->span.type(), value->span.data(), min_array_size_); } - else { - return value->span; - } + + return value->span; } - else if (any_value->type == ValueType::InputSingle) { + if (any_value->type == ValueType::InputSingle) { InputSingleValue *value = (InputSingleValue *)any_value; return value->virtual_span; } - else if (any_value->type == ValueType::OutputSingle) { + if (any_value->type == ValueType::OutputSingle) { OutputSingleValue *value = (OutputSingleValue *)any_value; BLI_assert(value->is_computed); return value->span; @@ -984,12 +979,12 @@ GVSpan MFNetworkEvaluationStorage::get_single_input__single(const MFInputSocket BLI_assert(value->span.size() == 1); return value->span; } - else if (any_value->type == ValueType::InputSingle) { + if (any_value->type == ValueType::InputSingle) { InputSingleValue *value = (InputSingleValue *)any_value; BLI_assert(value->virtual_span.is_single_element()); return value->virtual_span; } - else if (any_value->type == ValueType::OutputSingle) { + if (any_value->type == ValueType::OutputSingle) { OutputSingleValue *value = (OutputSingleValue *)any_value; BLI_assert(value->is_computed); BLI_assert(value->span.size() == 1); @@ -1012,15 +1007,14 @@ GVArraySpan MFNetworkEvaluationStorage::get_vector_input__full(const MFInputSock GSpan span = (*value->vector_array)[0]; return GVArraySpan(span, min_array_size_); } - else { - return *value->vector_array; - } + + return *value->vector_array; } - else if (any_value->type == ValueType::InputVector) { + if (any_value->type == ValueType::InputVector) { InputVectorValue *value = (InputVectorValue *)any_value; return value->virtual_array_span; } - else if (any_value->type == ValueType::OutputVector) { + if (any_value->type == ValueType::OutputVector) { OutputVectorValue *value = (OutputVectorValue *)any_value; return *value->vector_array; } @@ -1040,12 +1034,12 @@ GVArraySpan MFNetworkEvaluationStorage::get_vector_input__single(const MFInputSo BLI_assert(value->vector_array->size() == 1); return *value->vector_array; } - else if (any_value->type == ValueType::InputVector) { + if (any_value->type == ValueType::InputVector) { InputVectorValue *value = (InputVectorValue *)any_value; BLI_assert(value->virtual_array_span.is_single_array()); return value->virtual_array_span; } - else if (any_value->type == ValueType::OutputVector) { + if (any_value->type == ValueType::OutputVector) { OutputVectorValue *value = (OutputVectorValue *)any_value; BLI_assert(value->vector_array->size() == 1); return *value->vector_array; diff --git a/source/blender/functions/intern/multi_function_network_optimization.cc b/source/blender/functions/intern/multi_function_network_optimization.cc index af1e77aa355..e53b9a2c648 100644 --- a/source/blender/functions/intern/multi_function_network_optimization.cc +++ b/source/blender/functions/intern/multi_function_network_optimization.cc @@ -45,9 +45,8 @@ static bool set_tag_and_check_if_modified(bool &tag, bool new_value) tag = new_value; return true; } - else { - return false; - } + + return false; } static Array<bool> mask_nodes_to_the_left(MFNetwork &network, Span<MFNode *> nodes) diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c index f7929b58650..077a454db73 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c @@ -180,9 +180,8 @@ float get_modifier_point_weight(MDeformVert *dvert, bool inverse, int def_nr) if (inverse == 1) { return 1.0f; } - else { - return -1.0f; - } + + return -1.0f; } return weight; diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c index 56d94611b5d..bf6c47b2df5 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c @@ -484,7 +484,7 @@ static void generate_geometry(GpencilModifierData *md, /* Early exit */ return; } - else if (ctime >= end_frame) { + if (ctime >= end_frame) { /* Past End - Animation finished. Display final result. */ if (reverse) { /* 1) Reverse = Start with all, end with nothing. diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c index 10f775ee340..30ac18c64ae 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c @@ -120,7 +120,7 @@ static float gpencil_hook_falloff(const struct GPHookData_cb *tData, const float if (len_sq > tData->falloff_sq) { return 0.0f; } - else if (len_sq > 0.0f) { + if (len_sq > 0.0f) { float fac; if (tData->falloff_type == eGPHook_Falloff_Const) { diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index 3646686e81f..ba096653e0f 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -452,21 +452,20 @@ static void execute_posetree(struct Depsgraph *depsgraph, /* don't solve IK when we are setting the pole angle */ break; } - else { - mul_m4_m4m4(goal, goalinv, rootmat); - copy_v3_v3(polepos, goal[3]); - poleconstrain = 1; - - /* for pole targets, we blend the result of the ik solver - * instead of the target position, otherwise we can't get - * a smooth transition */ - resultblend = 1; - resultinf = target->con->enforce; - - if (data->flag & CONSTRAINT_IK_GETANGLE) { - poleangledata = data; - data->flag &= ~CONSTRAINT_IK_GETANGLE; - } + + mul_m4_m4m4(goal, goalinv, rootmat); + copy_v3_v3(polepos, goal[3]); + poleconstrain = 1; + + /* for pole targets, we blend the result of the ik solver + * instead of the target position, otherwise we can't get + * a smooth transition */ + resultblend = 1; + resultinf = target->con->enforce; + + if (data->flag & CONSTRAINT_IK_GETANGLE) { + poleangledata = data; + data->flag &= ~CONSTRAINT_IK_GETANGLE; } } diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 8f84d04f602..a5fdb9ef491 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -446,24 +446,21 @@ static double EulerAngleFromMatrix(const KDL::Rotation &R, int axis) if (axis == 0) { return -KDL::atan2(R(1, 2), R(2, 2)); } - else if (axis == 1) { + if (axis == 1) { return KDL::atan2(-R(0, 2), t); } - else { - return -KDL::atan2(R(0, 1), R(0, 0)); - } + + return -KDL::atan2(R(0, 1), R(0, 0)); } - else { - if (axis == 0) { - return -KDL::atan2(-R(2, 1), R(1, 1)); - } - else if (axis == 1) { - return KDL::atan2(-R(0, 2), t); - } - else { - return 0.0f; - } + + if (axis == 0) { + return -KDL::atan2(-R(2, 1), R(1, 1)); + } + if (axis == 1) { + return KDL::atan2(-R(0, 2), t); } + + return 0.0f; } static double ComputeTwist(const KDL::Rotation &R) diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 3d95eba4aed..53ed010952e 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -356,141 +356,140 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error *r_error_message = "SDNA error in SDNA file"; return false; } - else { - const char *cp; - data++; - /* Names array ('NAME') */ - if (*data == MAKE_ID('N', 'A', 'M', 'E')) { - data++; + const char *cp; - sdna->names_len = *data; - if (do_endian_swap) { - BLI_endian_switch_int32(&sdna->names_len); - } - sdna->names_len_alloc = sdna->names_len; + data++; + /* Names array ('NAME') */ + if (*data == MAKE_ID('N', 'A', 'M', 'E')) { + data++; - data++; - sdna->names = MEM_callocN(sizeof(void *) * sdna->names_len, "sdnanames"); - } - else { - *r_error_message = "NAME error in SDNA file"; - return false; + sdna->names_len = *data; + if (do_endian_swap) { + BLI_endian_switch_int32(&sdna->names_len); } + sdna->names_len_alloc = sdna->names_len; - cp = (char *)data; - for (int nr = 0; nr < sdna->names_len; nr++) { - sdna->names[nr] = cp; - - /* "float gravity [3]" was parsed wrong giving both "gravity" and - * "[3]" members. we rename "[3]", and later set the type of - * "gravity" to "void" so the offsets work out correct */ - if (*cp == '[' && strcmp(cp, "[3]") == 0) { - if (nr && strcmp(sdna->names[nr - 1], "Cvi") == 0) { - sdna->names[nr] = "gravity[3]"; - gravity_fix = nr; - } - } - while (*cp) { - cp++; + data++; + sdna->names = MEM_callocN(sizeof(void *) * sdna->names_len, "sdnanames"); + } + else { + *r_error_message = "NAME error in SDNA file"; + return false; + } + + cp = (char *)data; + for (int nr = 0; nr < sdna->names_len; nr++) { + sdna->names[nr] = cp; + + /* "float gravity [3]" was parsed wrong giving both "gravity" and + * "[3]" members. we rename "[3]", and later set the type of + * "gravity" to "void" so the offsets work out correct */ + if (*cp == '[' && strcmp(cp, "[3]") == 0) { + if (nr && strcmp(sdna->names[nr - 1], "Cvi") == 0) { + sdna->names[nr] = "gravity[3]"; + gravity_fix = nr; } + } + while (*cp) { cp++; } + cp++; + } - cp = pad_up_4(cp); - - /* Type names array ('TYPE') */ - data = (int *)cp; - if (*data == MAKE_ID('T', 'Y', 'P', 'E')) { - data++; + cp = pad_up_4(cp); - sdna->types_len = *data; - if (do_endian_swap) { - BLI_endian_switch_int32(&sdna->types_len); - } + /* Type names array ('TYPE') */ + data = (int *)cp; + if (*data == MAKE_ID('T', 'Y', 'P', 'E')) { + data++; - data++; - sdna->types = MEM_callocN(sizeof(void *) * sdna->types_len, "sdnatypes"); - } - else { - *r_error_message = "TYPE error in SDNA file"; - return false; + sdna->types_len = *data; + if (do_endian_swap) { + BLI_endian_switch_int32(&sdna->types_len); } - cp = (char *)data; - for (int nr = 0; nr < sdna->types_len; nr++) { - /* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */ - sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp); - while (*cp) { - cp++; - } + data++; + sdna->types = MEM_callocN(sizeof(void *) * sdna->types_len, "sdnatypes"); + } + else { + *r_error_message = "TYPE error in SDNA file"; + return false; + } + + cp = (char *)data; + for (int nr = 0; nr < sdna->types_len; nr++) { + /* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */ + sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp); + while (*cp) { cp++; } + cp++; + } - cp = pad_up_4(cp); - - /* Type lengths array ('TLEN') */ - data = (int *)cp; - if (*data == MAKE_ID('T', 'L', 'E', 'N')) { - data++; - sp = (short *)data; - sdna->types_size = sp; + cp = pad_up_4(cp); - if (do_endian_swap) { - BLI_endian_switch_int16_array(sp, sdna->types_len); - } + /* Type lengths array ('TLEN') */ + data = (int *)cp; + if (*data == MAKE_ID('T', 'L', 'E', 'N')) { + data++; + sp = (short *)data; + sdna->types_size = sp; - sp += sdna->types_len; - } - else { - *r_error_message = "TLEN error in SDNA file"; - return false; - } - /* prevent BUS error */ - if (sdna->types_len & 1) { - sp++; + if (do_endian_swap) { + BLI_endian_switch_int16_array(sp, sdna->types_len); } - /* Struct array ('STRC') */ - data = (int *)sp; - if (*data == MAKE_ID('S', 'T', 'R', 'C')) { - data++; + sp += sdna->types_len; + } + else { + *r_error_message = "TLEN error in SDNA file"; + return false; + } + /* prevent BUS error */ + if (sdna->types_len & 1) { + sp++; + } - sdna->structs_len = *data; - if (do_endian_swap) { - BLI_endian_switch_int32(&sdna->structs_len); - } + /* Struct array ('STRC') */ + data = (int *)sp; + if (*data == MAKE_ID('S', 'T', 'R', 'C')) { + data++; - data++; - sdna->structs = MEM_callocN(sizeof(void *) * sdna->structs_len, "sdnastrcs"); - } - else { - *r_error_message = "STRC error in SDNA file"; - return false; + sdna->structs_len = *data; + if (do_endian_swap) { + BLI_endian_switch_int32(&sdna->structs_len); } - sp = (short *)data; - for (int nr = 0; nr < sdna->structs_len; nr++) { - sdna->structs[nr] = sp; + data++; + sdna->structs = MEM_callocN(sizeof(void *) * sdna->structs_len, "sdnastrcs"); + } + else { + *r_error_message = "STRC error in SDNA file"; + return false; + } + + sp = (short *)data; + for (int nr = 0; nr < sdna->structs_len; nr++) { + sdna->structs[nr] = sp; - if (do_endian_swap) { - short a; + if (do_endian_swap) { + short a; + BLI_endian_switch_int16(&sp[0]); + BLI_endian_switch_int16(&sp[1]); + + a = sp[1]; + sp += 2; + while (a--) { BLI_endian_switch_int16(&sp[0]); BLI_endian_switch_int16(&sp[1]); - - a = sp[1]; sp += 2; - while (a--) { - BLI_endian_switch_int16(&sp[0]); - BLI_endian_switch_int16(&sp[1]); - sp += 2; - } - } - else { - sp += 2 * sp[1] + 2; } } + else { + sp += 2 * sp[1] + 2; + } } { @@ -578,16 +577,15 @@ SDNA *DNA_sdna_from_data(const void *data, if (init_structDNA(sdna, do_endian_swap, &error_message)) { return sdna; } + + if (r_error_message == NULL) { + fprintf(stderr, "Error decoding blend file SDNA: %s\n", error_message); + } else { - if (r_error_message == NULL) { - fprintf(stderr, "Error decoding blend file SDNA: %s\n", error_message); - } - else { - *r_error_message = error_message; - } - DNA_sdna_free(sdna); - return NULL; + *r_error_message = error_message; } + DNA_sdna_free(sdna); + return NULL; } /** @@ -764,34 +762,33 @@ static eSDNA_Type sdna_type_nr(const char *dna_type) if (STR_ELEM(dna_type, "char", "const char")) { return SDNA_TYPE_CHAR; } - else if (STR_ELEM(dna_type, "uchar", "unsigned char")) { + if (STR_ELEM(dna_type, "uchar", "unsigned char")) { return SDNA_TYPE_UCHAR; } - else if (STR_ELEM(dna_type, "short")) { + if (STR_ELEM(dna_type, "short")) { return SDNA_TYPE_SHORT; } - else if (STR_ELEM(dna_type, "ushort", "unsigned short")) { + if (STR_ELEM(dna_type, "ushort", "unsigned short")) { return SDNA_TYPE_USHORT; } - else if (STR_ELEM(dna_type, "int")) { + if (STR_ELEM(dna_type, "int")) { return SDNA_TYPE_INT; } - else if (STR_ELEM(dna_type, "float")) { + if (STR_ELEM(dna_type, "float")) { return SDNA_TYPE_FLOAT; } - else if (STR_ELEM(dna_type, "double")) { + if (STR_ELEM(dna_type, "double")) { return SDNA_TYPE_DOUBLE; } - else if (STR_ELEM(dna_type, "int64_t")) { + if (STR_ELEM(dna_type, "int64_t")) { return SDNA_TYPE_INT64; } - else if (STR_ELEM(dna_type, "uint64_t")) { + if (STR_ELEM(dna_type, "uint64_t")) { return SDNA_TYPE_UINT64; } /* invalid! */ - else { - return -1; - } + + return -1; } /** @@ -1150,7 +1147,7 @@ static void reconstruct_elem(const SDNA *newsdna, return; } - else if (countpos != 0) { /* name is an array */ + if (countpos != 0) { /* name is an array */ if (oname[countpos] == '[' && strncmp(name, oname, countpos) == 0) { /* basis equal */ const int new_name_array_len = newsdna->names_array_len[new_name_nr]; diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 628b9bdff75..af0d914391a 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -360,7 +360,7 @@ static int add_type(const char *str, int size) if (str[0] == 0) { return -1; } - else if (strchr(str, '*')) { + if (strchr(str, '*')) { /* note: this is valid C syntax but we can't parse, complain! * `struct SomeStruct* some_var;` <-- correct but we cant handle right now. */ return -1; diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 02baaa7b830..9821ead2340 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -117,12 +117,11 @@ static float mix_weight(float weight, float weight2, char mix_mode) if (mix_mode == MOD_WVG_MIX_DIF) { return (weight < weight2 ? weight2 - weight : weight - weight2); } - else if (mix_mode == MOD_WVG_MIX_AVG) { + if (mix_mode == MOD_WVG_MIX_AVG) { return (weight + weight2) * 0.5f; } - else { - return weight2; - } + + return weight2; } /************************************** diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 7b28728cfe7..f7ae51dd141 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -491,7 +491,7 @@ static float clipx_rctf(rctf *rf, float x1, float x2) rf->xmin = rf->xmax; return 0.0; } - else if (size != 0.0f) { + if (size != 0.0f) { return BLI_rctf_size_x(rf) / size; } return 1.0; @@ -514,7 +514,7 @@ static float clipy_rctf(rctf *rf, float y1, float y2) rf->ymin = rf->ymax; return 0.0; } - else if (size != 0.0f) { + if (size != 0.0f) { return BLI_rctf_size_y(rf) / size; } return 1.0; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index fa53ad522a6..0fc389ecd93 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -281,9 +281,8 @@ RenderLayer *RE_GetRenderLayer(RenderResult *rr, const char *name) if (rr == NULL) { return NULL; } - else { - return BLI_findstring(&rr->layers, name, offsetof(RenderLayer, name)); - } + + return BLI_findstring(&rr->layers, name, offsetof(RenderLayer, name)); } bool RE_HasSingleLayer(Render *re) @@ -1655,9 +1654,8 @@ static bool check_valid_compositing_camera(Scene *scene, Object *camera_override return true; } - else { - return (camera_override != NULL || scene->camera != NULL); - } + + return (camera_override != NULL || scene->camera != NULL); } static bool check_valid_camera_multiview(Scene *scene, Object *camera, ReportList *reports) @@ -1755,7 +1753,7 @@ static bool node_tree_has_composite_output(bNodeTree *ntree) if (ELEM(node->type, CMP_NODE_COMPOSITE, CMP_NODE_OUTPUT_FILE)) { return true; } - else if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) { + if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) { if (node->id) { if (node_tree_has_composite_output((bNodeTree *)node->id)) { return true; @@ -2506,9 +2504,8 @@ void RE_RenderAnim(Render *re, /* Skip this frame, but could update for physics and particles system. */ continue; } - else { - nfra += tfra; - } + + nfra += tfra; /* Touch/NoOverwrite options are only valid for image's */ if (is_movie == false) { @@ -2863,7 +2860,7 @@ RenderPass *RE_pass_find_by_name(volatile RenderLayer *rl, const char *name, con if (viewname == NULL || viewname[0] == '\0') { break; } - else if (STREQ(rp->view, viewname)) { + if (STREQ(rp->view, viewname)) { break; } } diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 4b74bfb3e5c..6299a86e25f 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -709,7 +709,7 @@ static int order_render_passes(const void *a, const void *b) if (passtype_a > passtype_b) { return 1; } - else if (passtype_a < passtype_b) { + if (passtype_a < passtype_b) { return 0; } } @@ -728,7 +728,7 @@ static int order_render_passes(const void *a, const void *b) if (STREQ(rpa->view, STEREO_LEFT_NAME)) { return 0; } - else if (STREQ(rpb->view, STEREO_LEFT_NAME)) { + if (STREQ(rpb->view, STEREO_LEFT_NAME)) { return 1; } @@ -736,7 +736,7 @@ static int order_render_passes(const void *a, const void *b) if (STREQ(rpa->view, STEREO_RIGHT_NAME)) { return 0; } - else if (STREQ(rpb->view, STEREO_RIGHT_NAME)) { + if (STREQ(rpb->view, STEREO_RIGHT_NAME)) { return 1; } @@ -930,9 +930,8 @@ bool RE_WriteRenderResult(ReportList *reports, if (!STREQ(view, viewname)) { continue; } - else { - viewname = ""; - } + + viewname = ""; } /* Skip compositing if only a single other layer is requested. */ @@ -993,9 +992,8 @@ bool RE_WriteRenderResult(ReportList *reports, if (!STREQ(view, viewname)) { continue; } - else { - viewname = ""; - } + + viewname = ""; } /* We only store RGBA passes as half float, for diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index b37eeed3681..e5c62dbd784 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -1381,20 +1381,19 @@ static int multitex_nodes_intern(Tex *tex, return rgbnor; } - else { - return multitex(tex, - texvec, - dxt, - dyt, - osatex, - texres, - thread, - which_output, - pool, - skip_load_image, - texnode_preview, - use_nodes); - } + + return multitex(tex, + texvec, + dxt, + dyt, + osatex, + texres, + thread, + which_output, + pool, + skip_load_image, + texnode_preview, + use_nodes); } /* this is called from the shader and texture nodes diff --git a/source/blender/simulation/intern/hair_volume.cpp b/source/blender/simulation/intern/hair_volume.cpp index c80ae69ce73..c24b7154d13 100644 --- a/source/blender/simulation/intern/hair_volume.cpp +++ b/source/blender/simulation/intern/hair_volume.cpp @@ -710,9 +710,8 @@ BLI_INLINE float hair_volume_density_divergence(float density, if (density > density_threshold && density > target_density) { return strength * logf(target_density / density); } - else { - return 0.0f; - } + + return 0.0f; } bool SIM_hair_volume_solve_divergence(HairGrid *grid, @@ -1030,14 +1029,13 @@ bool SIM_hair_volume_solve_divergence(HairGrid *grid, return true; } - else { - /* Clear result in case of error */ - for (i = 0, vert = grid->verts; i < num_cells; i++, vert++) { - zero_v3(vert->velocity_smooth); - } - return false; + /* Clear result in case of error */ + for (i = 0, vert = grid->verts; i < num_cells; i++, vert++) { + zero_v3(vert->velocity_smooth); } + + return false; } #if 0 /* XXX weighting is incorrect, disabled for now */ diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c index 856572aa3f5..1f6e67cb9ac 100644 --- a/source/blender/simulation/intern/implicit_blender.c +++ b/source/blender/simulation/intern/implicit_blender.c @@ -1711,9 +1711,8 @@ BLI_INLINE float fbstar(float length, float L, float kb, float cb) if (tempfb_fl < fbstar_fl) { return fbstar_fl; } - else { - return tempfb_fl; - } + + return tempfb_fl; } // function to calculae bending spring force (taken from Choi & Co) @@ -1725,9 +1724,8 @@ BLI_INLINE float fbstar_jacobi(float length, float L, float kb, float cb) if (tempfb_fl < fbstar_fl) { return -cb; } - else { - return -kb * fbderiv(length, L); - } + + return -kb * fbderiv(length, L); } /* calculate elonglation */ @@ -1864,9 +1862,8 @@ bool SIM_mass_spring_force_spring_bending( return true; } - else { - return false; - } + + return false; } BLI_INLINE void poly_avg(lfVector *data, const int *inds, int len, float r_avg[3]) @@ -2352,9 +2349,8 @@ bool SIM_mass_spring_force_spring_goal(Implicit_Data *data, return true; } - else { - return false; - } + + return false; } #endif /* IMPLICIT_SOLVER_BLENDER */ diff --git a/source/blender/simulation/intern/particle_function.cc b/source/blender/simulation/intern/particle_function.cc index 035e6d50e21..69977eb2054 100644 --- a/source/blender/simulation/intern/particle_function.cc +++ b/source/blender/simulation/intern/particle_function.cc @@ -102,9 +102,8 @@ fn::GVSpan ParticleFunctionEvaluator::get(int output_index, StringRef expected_n if (particle_fn_.output_is_global_[output_index]) { return fn::GVSpan::FromSingleWithMaxSize(type, buffer); } - else { - return fn::GVSpan(fn::GSpan(type, buffer, mask_.min_array_size())); - } + + return fn::GVSpan(fn::GSpan(type, buffer, mask_.min_array_size())); } void ParticleFunctionEvaluator::compute_globals() |