Cleanup: remove redundant NULL checks

This commit is contained in:
Campbell Barton 2019-10-28 00:36:23 +11:00
parent f1824e6ec4
commit 9b6aa740be
Notes: blender-bot 2023-02-14 05:12:59 +01:00
Referenced by issue #71184, Animating values for particles doesn't work
Referenced by issue #71162, Odd artifact in Eevee rendering
4 changed files with 46 additions and 68 deletions

View File

@ -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)) {

View File

@ -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);

View File

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

View File

@ -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);