diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 4635ec340d..1e7e09794f 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -2918,6 +2918,7 @@ int32_t tcompressDebug(uint32_t cmprAlg, uint8_t *l1Alg, uint8_t *l2Alg, uint8_t } int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, uint8_t lvlDiabled, uint8_t lvlDefault, uint32_t *dst) { + int8_t update = 0; uint8_t ol1 = COMPRESS_L1_TYPE_U32(oldCmpr); uint8_t ol2 = COMPRESS_L2_TYPE_U32(oldCmpr); uint8_t olvl = COMPRESS_L2_TYPE_LEVEL_U32(oldCmpr); @@ -2927,8 +2928,11 @@ int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, u uint8_t nlvl = COMPRESS_L2_TYPE_LEVEL_U32(newCmpr); if (nl1 != 0 && ol1 != nl1) { SET_COMPRESS(nl1, ol2, olvl, *dst); - return 1; - } else if (nl2 != 0 && ol2 != nl2) { + update = 1; + ol1 = nl1; + } + + if (nl2 != 0 && ol2 != nl2) { if (nl2 == l2Disabled) { SET_COMPRESS(ol1, nl2, lvlDiabled, *dst); } else { @@ -2938,10 +2942,13 @@ int8_t tUpdateCompress(uint32_t oldCmpr, uint32_t newCmpr, uint8_t l2Disabled, u SET_COMPRESS(ol1, nl2, olvl, *dst); } } - return 1; - } else if (nlvl != 0 && olvl != nlvl) { - SET_COMPRESS(ol1, ol2, nlvl, *dst); - return 1; + update = 1; + ol2 = nl2; } - return 0; + + if (nlvl != 0 && olvl != nlvl) { + SET_COMPRESS(ol1, ol2, nlvl, *dst); + update = 1; + } + return update; }