add compiler hints that failing to create a bmesh face is unlikely.

This commit is contained in:
2012-10-01 11:12:49 +00:00
parent b6bf0e4952
commit c9c76a9a68
9 changed files with 15 additions and 11 deletions

View File

@@ -129,8 +129,9 @@ void DM_to_bmesh_ex(DerivedMesh *dm, BMesh *bm)
f = BM_face_create_ngon(bm, verts[0], verts[1], edges, mp->totloop, FALSE); f = BM_face_create_ngon(bm, verts[0], verts[1], edges, mp->totloop, FALSE);
if (!f) if (UNLIKELY(f == NULL)) {
continue; continue;
}
f->head.hflag = BM_face_flag_from_mflag(mp->flag); f->head.hflag = BM_face_flag_from_mflag(mp->flag);
f->mat_nr = mp->mat_nr; f->mat_nr = mp->mat_nr;

View File

@@ -902,8 +902,9 @@ BMesh *BM_mesh_copy(BMesh *bm_old)
} }
f2 = BM_face_create_ngon(bm_new, v, v2, edges, f->len, FALSE); f2 = BM_face_create_ngon(bm_new, v, v2, edges, f->len, FALSE);
if (!f2) if (UNLIKELY(f2 == NULL)) {
continue; continue;
}
/* use totface in case adding some faces fails */ /* use totface in case adding some faces fails */
BM_elem_index_set(f2, (bm_new->totface - 1)); /* set_inline */ BM_elem_index_set(f2, (bm_new->totface - 1)); /* set_inline */

View File

@@ -1021,7 +1021,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del
/* create region face */ /* create region face */
newf = BM_face_create_ngon(bm, v1, v2, edges, tote, FALSE); newf = BM_face_create_ngon(bm, v1, v2, edges, tote, FALSE);
if (!newf || BMO_error_occurred(bm)) { if (UNLIKELY(!newf || BMO_error_occurred(bm))) {
if (!BMO_error_occurred(bm)) if (!BMO_error_occurred(bm))
err = "Invalid boundary region to join faces"; err = "Invalid boundary region to join faces";
goto error; goto error;

View File

@@ -314,7 +314,7 @@ void BM_mesh_bm_from_me(BMesh *bm, Mesh *me, int set_key, int act_key_nr)
f = BM_face_create(bm, verts, fedges, mpoly->totloop, FALSE); f = BM_face_create(bm, verts, fedges, mpoly->totloop, FALSE);
if (!f) { if (UNLIKELY(f == NULL)) {
printf("%s: Warning! Bad face in mesh" printf("%s: Warning! Bad face in mesh"
" \"%s\" at index %d!, skipping\n", " \"%s\" at index %d!, skipping\n",
__func__, me->id.name + 2, i); __func__, me->id.name + 2, i);

View File

@@ -475,7 +475,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
BLI_array_append(edges, e); BLI_array_append(edges, e);
f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), FALSE); f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), FALSE);
if (!f) { if (UNLIKELY(f == NULL)) {
printf("%s: could not make face!\n", __func__); printf("%s: could not make face!\n", __func__);
continue; continue;
} }
@@ -592,7 +592,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
*d3 = (d1 + d2) * 0.5f; *d3 = (d1 + d2) * 0.5f;
} }
if (!f) { if (UNLIKELY(f == NULL)) {
fprintf(stderr, "%s: face index out of range! (bmesh internal error)\n", __func__); fprintf(stderr, "%s: face index out of range! (bmesh internal error)\n", __func__);
continue; continue;
} }
@@ -771,7 +771,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
continue; continue;
f = BM_face_create_ngon(bm, lastv, vstart, edges, BLI_array_count(edges), FALSE); f = BM_face_create_ngon(bm, lastv, vstart, edges, BLI_array_count(edges), FALSE);
if (!f) { if (UNLIKELY(f == NULL)) {
fprintf(stderr, "%s: in bevel vert fill! (bmesh internal error)\n", __func__); fprintf(stderr, "%s: in bevel vert fill! (bmesh internal error)\n", __func__);
} }
else { else {

View File

@@ -506,7 +506,7 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op)
vv2[i2next], vv2[i2next],
vv1[i1next], vv1[i1next],
f_example, TRUE); f_example, TRUE);
if (!f || f->len != 4) { if (UNLIKELY((f == NULL) || (f->len != 4))) {
fprintf(stderr, "%s: in bridge! (bmesh internal error)\n", __func__); fprintf(stderr, "%s: in bridge! (bmesh internal error)\n", __func__);
} }
else { else {

View File

@@ -275,8 +275,9 @@ static int UNUSED_FUNCTION(rotsys_fill_faces)(BMesh *bm, EdgeData *edata, VertDa
continue; continue;
f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), TRUE); f = BM_face_create_ngon(bm, verts[0], verts[1], edges, BLI_array_count(edges), TRUE);
if (!f) if (UNLIKELY(f == NULL)) {
continue; continue;
}
} }
} }

View File

@@ -87,7 +87,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op)
BMO_elem_flag_enable(bm, f, EXT_DEL); BMO_elem_flag_enable(bm, f, EXT_DEL);
f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, FALSE); f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, FALSE);
if (!f2) { if (UNLIKELY(f2 == NULL)) {
BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed; could not create face"); BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed; could not create face");
BLI_array_free(edges); BLI_array_free(edges);
return; return;
@@ -104,6 +104,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op)
l4 = l2->next; l4 = l2->next;
f3 = BM_face_create_quad_tri(bm, l3->v, l4->v, l2->v, l->v, f, FALSE); f3 = BM_face_create_quad_tri(bm, l3->v, l4->v, l2->v, l->v, f, FALSE);
/* XXX, no error check here, why? - Campbell */
l_tmp = BM_FACE_FIRST_LOOP(f3); l_tmp = BM_FACE_FIRST_LOOP(f3);

View File

@@ -1808,7 +1808,7 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
f_new = BM_face_create(bm, vert_array, edge_array, vert_seq_len, FALSE); f_new = BM_face_create(bm, vert_array, edge_array, vert_seq_len, FALSE);
if (f_new == NULL) { if (UNLIKELY(f_new == NULL)) {
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"faces.new(verts): couldn't create the new face, internal error"); "faces.new(verts): couldn't create the new face, internal error");
goto cleanup; goto cleanup;