commit f9e6b6913056e48f3c70d9b7154556949cbc4a12 parent 69a0937bb6ce7863e4587082bb96d9e999cda09d Author: Christophe Coustet <christophe.coustet@meso-star.com> Date: Tue, 15 Oct 2019 12:18:32 +0200 Fix enum VS int when playing with bits. Diffstat:
| M | src/senc_internal_types.h | | | 5 | +++-- |
| M | src/senc_scene_analyze.c | | | 4 | ++-- |
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/senc_internal_types.h b/src/senc_internal_types.h @@ -123,9 +123,10 @@ TRGSIDE_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((f << 4) <= UCHAR_MAX); + return (unsigned char)(f << 4); } static FINLINE side_id_t diff --git a/src/senc_scene_analyze.c b/src/senc_scene_analyze.c @@ -338,7 +338,7 @@ extract_connex_components medium_id_t nbour_med_idx = (neighbour->medium == SENC_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 @@ -363,7 +363,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;