Cleanup: redundant NULL checks

Also use unsigned shifting for values not in int range.
This commit is contained in:
Campbell Barton 2018-12-01 19:36:57 +11:00
parent 0f5b53ba4d
commit 40f45a7eac
8 changed files with 9 additions and 14 deletions

View File

@ -148,7 +148,7 @@ void BKE_rigidbody_free_world(Scene *scene)
void BKE_rigidbody_free_object(Object *ob, RigidBodyWorld *rbw) void BKE_rigidbody_free_object(Object *ob, RigidBodyWorld *rbw)
{ {
bool is_orig = (ob->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0; bool is_orig = (ob->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0;
RigidBodyOb *rbo = (ob) ? ob->rigidbody_object : NULL; RigidBodyOb *rbo = ob->rigidbody_object;
/* sanity check */ /* sanity check */
if (rbo == NULL) if (rbo == NULL)

View File

@ -195,7 +195,7 @@ enum {
UI_BUT_TEXTEDIT_UPDATE = (1 << 29), /* when widget is in textedit mode, update value on each char stroke */ UI_BUT_TEXTEDIT_UPDATE = (1 << 29), /* when widget is in textedit mode, update value on each char stroke */
UI_BUT_VALUE_CLEAR = (1 << 30), /* show 'x' icon to clear/unlink value of text or search button */ UI_BUT_VALUE_CLEAR = (1 << 30), /* show 'x' icon to clear/unlink value of text or search button */
UI_BUT_OVERRIDEN = (1 << 31), /* RNA property of the button is overridden from linked reference data. */ UI_BUT_OVERRIDEN = (1u << 31u), /* RNA property of the button is overridden from linked reference data. */
}; };
#define UI_PANEL_WIDTH 340 #define UI_PANEL_WIDTH 340

View File

@ -1354,7 +1354,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, rct
if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC; if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC;
/* exception for multiple overlapping regions on same spot */ /* exception for multiple overlapping regions on same spot */
if (ar->overlap & (alignment != RGN_ALIGN_FLOAT)) { if (ar->overlap && (alignment != RGN_ALIGN_FLOAT)) {
region_overlap_fix(sa, ar); region_overlap_fix(sa, ar);
} }

View File

@ -306,13 +306,13 @@ static bool view3d_ruler_item_mousemove(
RulerInfo *ruler_info, RulerItem *ruler_item, const int mval[2], RulerInfo *ruler_info, RulerItem *ruler_item, const int mval[2],
const bool do_thickness, const bool do_snap) const bool do_thickness, const bool do_snap)
{ {
RulerInteraction *inter = ruler_item->gz.interaction_data;
const float eps_bias = 0.0002f; const float eps_bias = 0.0002f;
float dist_px = MVAL_MAX_PX_DIST * U.pixelsize; /* snap dist */ float dist_px = MVAL_MAX_PX_DIST * U.pixelsize; /* snap dist */
ruler_info->snap_flag &= ~RULER_SNAP_OK; ruler_info->snap_flag &= ~RULER_SNAP_OK;
if (ruler_item) { if (ruler_item) {
RulerInteraction *inter = ruler_item->gz.interaction_data;
float *co = ruler_item->co[inter->co_index]; float *co = ruler_item->co[inter->co_index];
/* restore the initial depth */ /* restore the initial depth */
copy_v3_v3(co, inter->drag_start_co); copy_v3_v3(co, inter->drag_start_co);

View File

@ -1253,10 +1253,7 @@ static short snap_mesh_polygon(
normalize_v3(r_no); normalize_v3(r_no);
} }
if (r_index) { *r_index = nearest.index;
*r_index = nearest.index;
}
return elem; return elem;
} }
@ -1355,9 +1352,7 @@ static short snap_mesh_edge_verts_mixed(
normalize_v3(r_no); normalize_v3(r_no);
} }
if (r_index) { *r_index = nearest.index;
*r_index = nearest.index;
}
} }
return elem; return elem;

View File

@ -95,7 +95,7 @@ enum {
GPU_BATCH_OWNS_VBO = (1 << 0), GPU_BATCH_OWNS_VBO = (1 << 0),
/* each vbo index gets bit-shifted */ /* each vbo index gets bit-shifted */
GPU_BATCH_OWNS_INSTANCES = (1 << 30), GPU_BATCH_OWNS_INSTANCES = (1 << 30),
GPU_BATCH_OWNS_INDEX = (1 << 31), GPU_BATCH_OWNS_INDEX = (1u << 31u),
}; };
GPUBatch *GPU_batch_create_ex(GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag); GPUBatch *GPU_batch_create_ex(GPUPrimType, GPUVertBuf *, GPUIndexBuf *, uint owns_flag);

View File

@ -263,7 +263,7 @@ typedef enum eScenePassType {
SCE_PASS_SUBSURFACE_DIRECT = (1 << 28), SCE_PASS_SUBSURFACE_DIRECT = (1 << 28),
SCE_PASS_SUBSURFACE_INDIRECT = (1 << 29), SCE_PASS_SUBSURFACE_INDIRECT = (1 << 29),
SCE_PASS_SUBSURFACE_COLOR = (1 << 30), SCE_PASS_SUBSURFACE_COLOR = (1 << 30),
SCE_PASS_ROUGHNESS = (1 << 31), SCE_PASS_ROUGHNESS = (1u << 31u),
} eScenePassType; } eScenePassType;
#define RE_PASSNAME_COMBINED "Combined" #define RE_PASSNAME_COMBINED "Combined"

View File

@ -432,7 +432,7 @@ static TriTessFace *mesh_calc_tri_tessface(
me->totloop, me->totpoly, me->totloop, me->totpoly,
looptri); looptri);
const float *precomputed_normals = me ? CustomData_get_layer(&me->pdata, CD_NORMAL) : NULL; const float *precomputed_normals = CustomData_get_layer(&me->pdata, CD_NORMAL);
const bool calculate_normal = precomputed_normals ? false : true; const bool calculate_normal = precomputed_normals ? false : true;
for (i = 0; i < tottri; i++) { for (i = 0; i < tottri; i++) {