commit de8b9b1775584fcb44483e141e59d8778dda0777 parent ada0040c36b0e3f0f3351875fd4531ff1e157c5f Author: Christophe Coustet <christophe.coustet@meso-star.com> Date: Tue, 5 Nov 2019 10:15:12 +0100 Fix enum VS int when playing with bits. Diffstat:
| M | src/senc2d_internal_types.h | | | 5 | +++-- |
| M | src/senc2d_scene_analyze.c | | | 4 | ++-- |
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/senc2d_internal_types.h b/src/senc2d_internal_types.h @@ -117,9 +117,10 @@ SEGSIDE_2_SIDEFLAG(side_id_t s) { return (s & 1) ? FLAG_BACK : FLAG_FRONT; } -static FINLINE enum side_flag +static FINLINE unsigned char SIDE_CANCELED_FLAG(enum side_flag f) { - return ((unsigned char)f) << 4; + ASSERT((((unsigned)f) << 4) <= UCHAR_MAX); + return (((unsigned char)f) << 4); } static FINLINE side_id_t diff --git a/src/senc2d_scene_analyze.c b/src/senc2d_scene_analyze.c @@ -336,7 +336,7 @@ extract_connex_components medium_id_t nbour_med_idx = (neighbour->medium == SENC2D_UNDEFINED_MEDIUM) ? scn->next_medium_idx : neighbour->medium; if(neighbour->medium < m - || (*nbour_used & (unsigned char)SIDE_CANCELED_FLAG(nbour_side_id))) + || (*nbour_used & SIDE_CANCELED_FLAG(nbour_side_id))) { /* 1) Not the same medium. * Neighbour's medium id is less than current medium: the whole @@ -361,7 +361,7 @@ extract_connex_components ASSERT(*used & (unsigned char)used_side_flag); /* Set the used flag for sides in cancelled component as leading * to further cancellations */ - *used |= (unsigned char)SIDE_CANCELED_FLAG(used_side_flag); + *used |= SIDE_CANCELED_FLAG(used_side_flag); } goto canceled;