diff --git a/source/util/src/tdecompress.c b/source/util/src/tdecompress.c index 63014d07b8..470e43c957 100644 --- a/source/util/src/tdecompress.c +++ b/source/util/src/tdecompress.c @@ -399,19 +399,15 @@ int32_t tsDecompressTimestampAvx2(const char *const input, const int32_t nelemen int8_t nbytes1 = flags & INT8MASK(4); // range of nbytes starts from 0 to 7 int8_t nbytes2 = (flags >> 4) & INT8MASK(4); - __m128i data1; - if (nbytes1 == 0) { - data1 = _mm_setzero_si128(); - } else { + __m128i data1 = _mm_setzero_si128(); + if (nbytes1 > 0) { int64_t dd = 0; memcpy(&dd, (const void*) (input + ipos), nbytes1); data1 = _mm_loadu_si64(&dd); } - __m128i data2; - if (nbytes2 == 0) { - data2 = _mm_setzero_si128(); - } else { + __m128i data2 = _mm_setzero_si128(); + if (nbytes2 > 0) { int64_t dd = 0; memcpy(&dd, (const void*) (input + ipos + nbytes1), nbytes2); data2 = _mm_loadu_si64(&dd); diff --git a/source/util/test/decompressTest.cpp b/source/util/test/decompressTest.cpp index b3cf46fea6..dfcd682255 100644 --- a/source/util/test/decompressTest.cpp +++ b/source/util/test/decompressTest.cpp @@ -38,13 +38,13 @@ TEST(utilTest, decompress_ts_test) { } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - int64_t tsList[4] = {1286, 1124, 2681, 2823}; + tsList[0] = 1286; tsList[1] = 1124; tsList[2]=2681; tsList[3] = 2823; - char* pOutput[4 * sizeof(int64_t)] = {0}; - int32_t len = tsCompressTimestamp(tsList, sizeof(tsList), sizeof(tsList) / sizeof(tsList[0]), pOutput, 4, +// char* pOutput[4 * sizeof(int64_t)] = {0}; + len = tsCompressTimestamp(tsList, sizeof(tsList), sizeof(tsList) / sizeof(tsList[0]), pOutput, 4, ONE_STAGE_COMP, NULL, 0); - char* decompOutput[4 * 8] = {0}; + decompOutput[4 * 8] = {0}; tsDecompressTimestamp(pOutput, len, 4, decompOutput, sizeof(int64_t) * 4, ONE_STAGE_COMP, NULL, 0); for (int32_t i = 0; i < 4; ++i) {