diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-10-27 16:36:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-10-27 16:40:51 +0300 |
commit | 9b6aa740be31b395fc62b4e6e491cba8c8f977e3 (patch) | |
tree | 20f84c6298b8fdb62a06a954050078127ab335d6 /source/blender | |
parent | f1824e6ec45fa0d7c0a01d50ace45ec28595d07d (diff) |
Cleanup: remove redundant NULL checks
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_remesh.c | 6 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 98 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 12 |
4 files changed, 49 insertions, 71 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 54fd91e5361..ff6b65ffbfc 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2624,10 +2624,10 @@ void ui_but_string_get_ex(uiBut *but, BLI_assert(0); } - if (!buf) { + if (buf == NULL) { str[0] = '\0'; } - else if (buf && buf != str) { + else if (buf != str) { BLI_assert(maxlen <= buf_len + 1); /* string was too long, we have to truncate */ if (UI_but_is_utf8(but)) { diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c index 35762c5861e..d3dca03548f 100644 --- a/source/blender/editors/object/object_remesh.c +++ b/source/blender/editors/object/object_remesh.c @@ -407,7 +407,7 @@ static void quadriflow_start_job(void *customdata, short *stop, short *do_update BKE_id_free(qj->bmain, bisect_mesh); - if (!new_mesh) { + if (new_mesh == NULL) { *do_update = true; *stop = 0; if (qj->success == 1) { @@ -418,9 +418,7 @@ static void quadriflow_start_job(void *customdata, short *stop, short *do_update } /* Mirror the Quadriflow result to build the final mesh */ - if (new_mesh) { - new_mesh = remesh_symmetry_mirror(qj->owner, new_mesh, qj->symmetry_axes); - } + new_mesh = remesh_symmetry_mirror(qj->owner, new_mesh, qj->symmetry_axes); if (ob->mode == OB_MODE_SCULPT) { ED_sculpt_undo_geometry_begin(ob); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index d703cdfecb3..e8e0569f15e 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -783,79 +783,63 @@ static void vgroup_operator_subset_select_props(wmOperatorType *ot, bool use_act static void ED_vgroup_nr_vert_add( Object *ob, const int def_nr, const int vertnum, const float weight, const int assignmode) { - /* add the vert to the deform group with the - * specified number - */ + /* Add the vert to the deform group with the specified number. */ MDeformVert *dvert = NULL; int tot; - /* get the vert */ + /* Get the vert. */ BKE_object_defgroup_array_get(ob->data, &dvert, &tot); if (dvert == NULL) { return; } - /* check that vertnum is valid before trying to get the relevant dvert */ + /* Check that vertnum is valid before trying to get the relevant dvert. */ if ((vertnum < 0) || (vertnum >= tot)) { return; } - if (dvert) { - MDeformVert *dv = &dvert[vertnum]; - MDeformWeight *dw; - - /* Lets first check to see if this vert is - * already in the weight group -- if so - * lets update it - */ + MDeformVert *dv = &dvert[vertnum]; + MDeformWeight *dw; - dw = defvert_find_index(dv, def_nr); + /* Lets first check to see if this vert is already in the weight group - if so lets update it. */ + dw = defvert_find_index(dv, def_nr); - if (dw) { - switch (assignmode) { - case WEIGHT_REPLACE: - dw->weight = weight; - break; - case WEIGHT_ADD: - dw->weight += weight; - if (dw->weight >= 1.0f) { - dw->weight = 1.0f; - } - break; - case WEIGHT_SUBTRACT: - dw->weight -= weight; - /* if the weight is zero or less than - * remove the vert from the deform group - */ - if (dw->weight <= 0.0f) { - defvert_remove_group(dv, dw); - } - break; - } + if (dw) { + switch (assignmode) { + case WEIGHT_REPLACE: + dw->weight = weight; + break; + case WEIGHT_ADD: + dw->weight += weight; + if (dw->weight >= 1.0f) { + dw->weight = 1.0f; + } + break; + case WEIGHT_SUBTRACT: + dw->weight -= weight; + /* If the weight is zero or less than remove the vert from the deform group. */ + if (dw->weight <= 0.0f) { + defvert_remove_group(dv, dw); + } + break; } - else { - /* if the vert wasn't in the deform group then - * we must take a different form of action ... - */ - - switch (assignmode) { - case WEIGHT_SUBTRACT: - /* if we are subtracting then we don't - * need to do anything - */ - return; - - case WEIGHT_REPLACE: - case WEIGHT_ADD: - /* if we are doing an additive assignment, then - * we need to create the deform weight - */ - - /* we checked if the vertex was added before so no need to test again, simply add */ - defvert_add_index_notest(dv, def_nr, weight); - break; - } + } + else { + /* If the vert wasn't in the deform group then we must take a different form of action. */ + + switch (assignmode) { + case WEIGHT_SUBTRACT: + /* If we are subtracting then we don't need to do anything. */ + return; + + case WEIGHT_REPLACE: + case WEIGHT_ADD: + /* If we are doing an additive assignment, then we need to create the deform weight. */ + + /* We checked if the vertex was added before so no need to test again, simply add. */ + defvert_add_index_notest(dv, def_nr, weight); + break; } } } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index fc22e9e6c74..55aa529a30e 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -3694,15 +3694,13 @@ PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, ContainerRNA *cont = cont_; PropertyRNA *prop; - if (!items) { + if (items == NULL) { CLOG_ERROR(&LOG, "items not allowed to be NULL."); return NULL; } prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE); - if (items) { - RNA_def_property_enum_items(prop, items); - } + RNA_def_property_enum_items(prop, items); RNA_def_property_enum_default(prop, default_value); RNA_def_property_ui_text(prop, ui_name, ui_description); @@ -3720,16 +3718,14 @@ PropertyRNA *RNA_def_enum_flag(StructOrFunctionRNA *cont_, ContainerRNA *cont = cont_; PropertyRNA *prop; - if (!items) { + if (items == NULL) { CLOG_ERROR(&LOG, "items not allowed to be NULL."); return NULL; } prop = RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE); RNA_def_property_flag(prop, PROP_ENUM_FLAG); /* important to run before default set */ - if (items) { - RNA_def_property_enum_items(prop, items); - } + RNA_def_property_enum_items(prop, items); RNA_def_property_enum_default(prop, default_value); RNA_def_property_ui_text(prop, ui_name, ui_description); |