diff --git a/lib/common/cmp_error.c b/lib/common/cmp_error.c index 7e8caf562e8999d956010af61724d346ec494b3b..b29fb0ab4c5e0dd56405e74f0c1554625ba02358 100644 --- a/lib/common/cmp_error.c +++ b/lib/common/cmp_error.c @@ -74,7 +74,7 @@ const char* cmp_get_error_string(enum cmp_error code) return "No error detected"; case CMP_ERROR_GENERIC: return "Error (generic)"; - case CMP_ERROR_SMALL_BUF_: + case CMP_ERROR_SMALL_BUFFER: return "Destination buffer is too small to hold the whole compressed data"; case CMP_ERROR_DATA_VALUE_TOO_LARGE: return "Data value is larger than expected"; diff --git a/lib/common/cmp_error_list.h b/lib/common/cmp_error_list.h index 94476c9455701071c3c68feb01ab9a0aa912ae78..9a7a41f456fc0c2c564553c658f215fecffa66eb 100644 --- a/lib/common/cmp_error_list.h +++ b/lib/common/cmp_error_list.h @@ -28,7 +28,7 @@ enum cmp_error { CMP_ERROR_NO_ERROR = 0, CMP_ERROR_GENERIC = 1, - CMP_ERROR_SMALL_BUF_ = 2, + CMP_ERROR_SMALL_BUFFER = 2, CMP_ERROR_DATA_VALUE_TOO_LARGE = 3, /* compression parameter errors */ CMP_ERROR_PAR_GENERIC = 20, diff --git a/lib/icu_compress/cmp_icu.c b/lib/icu_compress/cmp_icu.c index d91c2e3ce15b7a41d92c1314e747d3f50b45e1f7..74a9fa27b943dd906744150271677b7a7d2c7843 100644 --- a/lib/icu_compress/cmp_icu.c +++ b/lib/icu_compress/cmp_icu.c @@ -167,7 +167,7 @@ static uint32_t put_n_bits32(uint32_t value, unsigned int n_bits, uint32_t bit_o /* Check if the bitstream buffer is large enough */ if (stream_len > max_stream_len) - return CMP_ERROR(SMALL_BUF_); + return CMP_ERROR(SMALL_BUFFER); local_adr = bitstream_adr + (bit_offset >> 5); @@ -1610,7 +1610,7 @@ static uint32_t compress_data_internal(const struct cmp_cfg *cfg, uint32_t strea + cfg->samples * (uint32_t)size_of_a_sample(cfg->data_type); /* TODO: move this check to the memcpy */ - RETURN_ERROR_IF(raw_stream_size > cfg->stream_size, SMALL_BUF_, ""); + RETURN_ERROR_IF(raw_stream_size > cfg->stream_size, SMALL_BUFFER, ""); } if (cfg->samples == 0) /* nothing to compress we are done */ @@ -1793,7 +1793,7 @@ static uint32_t cmp_collection(const uint8_t *col, */ if (dst) { RETURN_ERROR_IF(dst_size + COLLECTION_HDR_SIZE > dst_capacity, - SMALL_BUF_, ""); + SMALL_BUFFER, ""); memcpy((uint8_t *)dst + dst_size, col, COLLECTION_HDR_SIZE); } dst_size += COLLECTION_HDR_SIZE; @@ -1804,12 +1804,12 @@ static uint32_t cmp_collection(const uint8_t *col, if ((dst == NULL || dst_capacity >= dst_size + col_data_length) && cfg->cmp_mode != CMP_MODE_RAW) { /* we set the compressed buffer size to the data size -1 to provoke - * a CMP_ERROR_SMALL_BUF_ error if the data are not compressible + * a CMP_ERROR_SMALL_BUFFER error if the data are not compressible */ cfg->stream_size = dst_size + col_data_length - 1; dst_size_bits = compress_data_internal(cfg, dst_size << 3); - if (cmp_get_error_code(dst_size_bits) == CMP_ERROR_SMALL_BUF_ || + if (cmp_get_error_code(dst_size_bits) == CMP_ERROR_SMALL_BUFFER || (!dst && dst_size_bits > cmp_stream_size_to_bits(cfg->stream_size))) { /* if dst == NULL compress_data_internal will not return a CMP_ERROR_SMALL_BUF */ /* can not compress the data with the given parameters; * put them uncompressed (raw) into the dst buffer */ @@ -2149,7 +2149,7 @@ uint32_t compress_chunk(const void *chunk, uint32_t chunk_size, * header after the compression of the chunk */ cmp_size_byte = cmp_ent_build_chunk_header(NULL, chunk_size, &cfg, start_timestamp, 0); - RETURN_ERROR_IF(dst && dst_capacity < cmp_size_byte, SMALL_BUF_, + RETURN_ERROR_IF(dst && dst_capacity < cmp_size_byte, SMALL_BUFFER, "dst_capacity must be at least as large as the minimum size of the compression unit."); @@ -2338,7 +2338,7 @@ uint32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info) cmp_size_bit = compress_data_internal(&cfg, 0); if (info) { - if (cmp_get_error_code(cmp_size_bit) == CMP_ERROR_SMALL_BUF_) + if (cmp_get_error_code(cmp_size_bit) == CMP_ERROR_SMALL_BUFFER) info->cmp_err |= 1UL << 0;/* SMALL_BUFFER_ERR_BIT;*/ /* set small buffer error */ if (cmp_is_error(cmp_size_bit)) { info->cmp_size = 0; diff --git a/programs/cmp_tool.c b/programs/cmp_tool.c index 1bd900ea5352a8fab3e9aee8a22bbef583d2ff38..3cd3c8a91b73fc91dd578e6d04d22afade06723b 100644 --- a/programs/cmp_tool.c +++ b/programs/cmp_tool.c @@ -751,7 +751,7 @@ static int compression_for_rdcu(struct rdcu_cfg *rcfg) cmp_size = compress_like_rdcu(rcfg, &info); if (cmp_is_error(cmp_size)) { - if (cmp_get_error_code(cmp_size) == CMP_ERROR_SMALL_BUF_) + if (cmp_get_error_code(cmp_size) == CMP_ERROR_SMALL_BUFFER) fprintf(stderr, "Error: The buffer for the compressed data is too small to hold the compressed data. Try a larger buffer_length parameter.\n"); goto error_cleanup; } diff --git a/test/cmp_decmp/test_cmp_decmp.c b/test/cmp_decmp/test_cmp_decmp.c index 66fcce228d61329a8770e90c369b963b1e2e12b4..84b2cff8ca2422b5c2af34f806365ea81afbe1ce 100644 --- a/test/cmp_decmp/test_cmp_decmp.c +++ b/test/cmp_decmp/test_cmp_decmp.c @@ -1029,14 +1029,14 @@ void test_random_collection_round_trip(void) cmp_size = chunk_round_trip(data, (uint32_t)size, model, updated_model, cmp_data, cmp_data_capacity, &par, 1, model_mode_is_used(par.cmp_mode)); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); } cmp_data_capacity = cmp_size2 - cmp_rand_between(1, cmp_size2); cmp_size = chunk_round_trip(data, (uint32_t)size, model, updated_model, cmp_data, cmp_data_capacity, &par, 1, model_mode_is_used(par.cmp_mode)); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); } } } @@ -1111,7 +1111,7 @@ void test_cmp_collection_raw(void) /* error case: buffer for the compressed data is to small */ dst_capacity -= 1; - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(compress_chunk(col, col_size, NULL, NULL, dst, dst_capacity, &par))); free(col); @@ -1196,7 +1196,7 @@ void test_cmp_collection_diff(void) /* error cases dst buffer to small */ dst_capacity -= 1; - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(compress_chunk(col, col_size, NULL, NULL, dst, dst_capacity, &par))); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(compress_chunk(col, col_size, NULL, NULL, dst, dst_capacity, &par))); free(col); free(dst); @@ -1473,7 +1473,7 @@ void test_cmp_decmp_chunk_raw(void) dst_capacity -= 1; cmp_size = compress_chunk(chunk, chunk_size, NULL, NULL, dst, dst_capacity, &par); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); } free(dst); @@ -1586,7 +1586,7 @@ void test_cmp_decmp_chunk_worst_case(void) /* error case: buffer to small for compressed data */ cmp_size_byte = compress_chunk(chunk, chunk_size, NULL, NULL, dst, chunk_size, &par); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size_byte)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size_byte)); free(chunk); } diff --git a/test/cmp_icu/test_cmp_icu.c b/test/cmp_icu/test_cmp_icu.c index 4bccc3a98de1b8e0297a6b37e4fa6ba17a03df51..2d8322639201e831a5a4630af0532b4b21eaf8cf 100644 --- a/test/cmp_icu/test_cmp_icu.c +++ b/test/cmp_icu/test_cmp_icu.c @@ -532,7 +532,7 @@ void test_put_n_bits32(void) v = 0x1; n = 1; o = 96; rval = put_n_bits32(v, n, o, testarray0, l); TEST_ASSERT_TRUE(cmp_is_error(rval)); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(rval)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(rval)); TEST_ASSERT(testarray0[0] == 0); TEST_ASSERT(testarray0[1] == 0); TEST_ASSERT(testarray0[2] == 0); @@ -545,7 +545,7 @@ void test_put_n_bits32(void) v = 0x0; n = 32; o = INT32_MAX; rval = put_n_bits32(v, n, o, testarray1, l); TEST_ASSERT_TRUE(cmp_is_error(rval)); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(rval)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(rval)); TEST_ASSERT(testarray1[0] == 0xffffffff); TEST_ASSERT(testarray1[1] == 0xffffffff); TEST_ASSERT(testarray1[2] == 0xffffffff); @@ -854,7 +854,7 @@ void test_encode_value_zero(void) data = 23; model = 26; stream_len = encode_value_zero(data, model, stream_len, &setup); TEST_ASSERT_TRUE(cmp_is_error(stream_len)); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(stream_len)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(stream_len)); /* reset bitstream to all bits set */ bitstream[0] = ~0U; @@ -906,7 +906,7 @@ void test_encode_value_zero(void) data = 31; model = 0; stream_len = encode_value_zero(data, model, stream_len, &setup); TEST_ASSERT_TRUE(cmp_is_error(stream_len)); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(stream_len)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(stream_len)); TEST_ASSERT_EQUAL_HEX(0, be32_to_cpu(bitstream[0])); TEST_ASSERT_EQUAL_HEX(0, be32_to_cpu(bitstream[1])); TEST_ASSERT_EQUAL_HEX(0, be32_to_cpu(bitstream[2])); @@ -989,7 +989,7 @@ void test_encode_value_multi(void) /* small buffer error */ data = 0; model = 38; stream_len = encode_value_multi(data, model, stream_len, &setup); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(stream_len)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(stream_len)); /* small buffer error when creating the multi escape symbol*/ bitstream[0] = 0; @@ -999,7 +999,7 @@ void test_encode_value_multi(void) stream_len = 32; data = 31; model = 0; stream_len = encode_value_multi(data, model, stream_len, &setup); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(stream_len)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(stream_len)); TEST_ASSERT_EQUAL_HEX(0, bitstream[0]); TEST_ASSERT_EQUAL_HEX(0, bitstream[1]); } @@ -1087,7 +1087,7 @@ void test_encode_value(void) /* small buffer error bitstream can not hold more data*/ cmp_size = encode_value(data, model, cmp_size, &setup); - TEST_ASSERT_EQUAL_UINT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_UINT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); /* reset bitstream */ bitstream[0] = 0; @@ -1226,7 +1226,7 @@ void test_compress_imagette_diff(void) rcfg.ap2_spill = 8; rcfg.buffer_length = 3; cmp_size = compress_like_rdcu(&rcfg, &info); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); TEST_ASSERT_EQUAL_HEX(0xDF6002AB, be32_to_cpu(output_buf[0])); TEST_ASSERT_EQUAL_HEX(0xFEB70000, be32_to_cpu(output_buf[1])); TEST_ASSERT_EQUAL_HEX(0x00000000, be32_to_cpu(output_buf[2])); @@ -1371,7 +1371,7 @@ void test_compress_imagette_raw(void) cmp_size = compress_like_rdcu(&rcfg, NULL); TEST_ASSERT_TRUE(cmp_is_error(cmp_size)); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); free(output_buf); } @@ -1410,7 +1410,7 @@ void test_compress_imagette_error_cases(void) rcfg.buffer_length = 4; cmp_size = compress_like_rdcu(&rcfg, NULL); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); /* compressed data buffer to small test part 2 */ rcfg.cmp_mode = CMP_MODE_DIFF_ZERO; @@ -1422,7 +1422,7 @@ void test_compress_imagette_error_cases(void) rcfg.buffer_length = 1; cmp_size = compress_like_rdcu(&rcfg, NULL); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); /* test unknown cmp_mode */ @@ -1522,7 +1522,7 @@ void test_pad_bitstream(void) cmp_size = 64; cmp_size = put_n_bits32(0, 1, cmp_size, cfg.dst, MAX_BIT_LEN); cmp_size_return = pad_bitstream(&cfg, cmp_size); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size_return)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size_return)); } @@ -1651,7 +1651,7 @@ void test_compress_chunk_raw_singel_col(void) dst = malloc(dst_capacity); TEST_ASSERT_NOT_NULL(dst); cmp_size = compress_chunk(chunk, CHUNK_SIZE, NULL, NULL, dst, dst_capacity, &cmp_par); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); free(dst); } @@ -1771,7 +1771,7 @@ void test_compress_chunk_raw_two_col(void) dst = malloc(dst_capacity); TEST_ASSERT_NOT_NULL(dst); cmp_size = compress_chunk(chunk, CHUNK_SIZE, NULL, NULL, dst, dst_capacity, &cmp_par); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); free(dst); } @@ -1897,7 +1897,7 @@ void test_collection_zero_data_length(void) dst_capacity -= 1; cmp_size = compress_chunk(chunk, CHUNK_SIZE, NULL, NULL, dst, dst_capacity, &cmp_par); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); free(dst); } @@ -2082,7 +2082,7 @@ void test_compress_chunk_error_cases(void) /* error: dst buffer smaller than entity header */ cmp_size = compress_chunk(chunk, CHUNK_SIZE, chunk_model, updated_chunk_model, dst, 5, &cmp_par); - TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size)); + TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUFFER, cmp_get_error_code(cmp_size)); /* error: invalid collection type */ TEST_ASSERT_FALSE(cmp_col_set_subservice((struct collection_hdr *)chunk, 42)); diff --git a/test/fuzz/fuzz_compression.c b/test/fuzz/fuzz_compression.c index d42d4ddd15c9c2d07ccca6a8194cbfcacf3ca6d4..2817129848143929800c02ef13381733585152af 100644 --- a/test/fuzz/fuzz_compression.c +++ b/test/fuzz/fuzz_compression.c @@ -94,7 +94,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size) switch (cmp_get_error_code(return_value)) { case CMP_ERROR_NO_ERROR: case CMP_ERROR_GENERIC: - case CMP_ERROR_SMALL_BUF_: + case CMP_ERROR_SMALL_BUFFER: /* compression parameter errors */ case CMP_ERROR_PAR_GENERIC: case CMP_ERROR_PAR_SPECIFIC: diff --git a/test/fuzz/fuzz_round_trip.c b/test/fuzz/fuzz_round_trip.c index 8dea441126549d2feb21083c00b790b12b07a73f..c8a1ff1397354318ca267c04cfa3e1bc74a662c1 100644 --- a/test/fuzz/fuzz_round_trip.c +++ b/test/fuzz/fuzz_round_trip.c @@ -82,7 +82,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size) switch (cmp_get_error_code(return_value)) { case CMP_ERROR_NO_ERROR: case CMP_ERROR_GENERIC: - case CMP_ERROR_SMALL_BUF_: + case CMP_ERROR_SMALL_BUFFER: /* compression parameter errors */ case CMP_ERROR_PAR_GENERIC: case CMP_ERROR_PAR_SPECIFIC: diff --git a/test/test_common/chunk_round_trip.c b/test/test_common/chunk_round_trip.c index f23fcea1575426da7500d1e5c12d3e89ac84c0fe..82a936c74f20587c82c8717959dee19824e11b1f 100644 --- a/test/test_common/chunk_round_trip.c +++ b/test/test_common/chunk_round_trip.c @@ -97,7 +97,7 @@ uint32_t chunk_round_trip(const void *chunk, uint32_t chunk_size, } cmp_size2 = compress_chunk(chunk, chunk_size, chunk_model, updated_chunk_model, NULL, dst_capacity, cmp_par); - if (cmp_get_error_code(cmp_size) == CMP_ERROR_SMALL_BUF_) { + if (cmp_get_error_code(cmp_size) == CMP_ERROR_SMALL_BUFFER) { TEST_ASSERT(!cmp_is_error(cmp_size)); } else { TEST_ASSERT(cmp_size == cmp_size2);