Skip to content
Snippets Groups Projects
Commit 6f405478 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

Add new error code if the max_used_bits parameters are invalid

parent 9dc35e6d
No related branches found
No related tags found
1 merge request!30Enhanced Error Handling in Chunk Compression Functions
...@@ -86,6 +86,8 @@ const char* cmp_get_error_string(enum cmp_error code) ...@@ -86,6 +86,8 @@ const char* cmp_get_error_string(enum cmp_error code)
return "Specific compression parameters or combination is unsupported"; return "Specific compression parameters or combination is unsupported";
case CMP_ERROR_PAR_BUFFERS: case CMP_ERROR_PAR_BUFFERS:
return "Buffer related parameter is not valid"; return "Buffer related parameter is not valid";
case CMP_ERROR_PAR_MAX_USED_BITS:
return "Maximum used bits parameters are not valid";
case CMP_ERROR_CHUNK_NULL: case CMP_ERROR_CHUNK_NULL:
return "Pointer to the chunk is NULL. No data, no compression"; return "Pointer to the chunk is NULL. No data, no compression";
......
...@@ -34,6 +34,7 @@ enum cmp_error { ...@@ -34,6 +34,7 @@ enum cmp_error {
CMP_ERROR_PAR_GENERIC = 20, CMP_ERROR_PAR_GENERIC = 20,
CMP_ERROR_PAR_SPECIFIC = 21, CMP_ERROR_PAR_SPECIFIC = 21,
CMP_ERROR_PAR_BUFFERS = 22, CMP_ERROR_PAR_BUFFERS = 22,
CMP_ERROR_PAR_MAX_USED_BITS = 23,
/* chunk errors */ /* chunk errors */
CMP_ERROR_CHUNK_NULL = 40, CMP_ERROR_CHUNK_NULL = 40,
CMP_ERROR_CHUNK_TOO_LARGE = 41, CMP_ERROR_CHUNK_TOO_LARGE = 41,
......
...@@ -2031,7 +2031,7 @@ static uint32_t cmp_cfg_icu_is_invalid_error_code(const struct cmp_cfg *cfg) ...@@ -2031,7 +2031,7 @@ static uint32_t cmp_cfg_icu_is_invalid_error_code(const struct cmp_cfg *cfg)
RETURN_ERROR_IF(cmp_cfg_icu_buffers_is_invalid(cfg), PAR_BUFFERS, ""); RETURN_ERROR_IF(cmp_cfg_icu_buffers_is_invalid(cfg), PAR_BUFFERS, "");
if (cfg->cmp_mode != CMP_MODE_RAW) if (cfg->cmp_mode != CMP_MODE_RAW)
RETURN_ERROR_IF(cmp_cfg_icu_max_used_bits_out_of_limit(cfg->max_used_bits), GENERIC, ""); RETURN_ERROR_IF(cmp_cfg_icu_max_used_bits_out_of_limit(cfg->max_used_bits), PAR_MAX_USED_BITS, "");
if (cmp_imagette_data_type_is_used(cfg->data_type)) { if (cmp_imagette_data_type_is_used(cfg->data_type)) {
RETURN_ERROR_IF(cmp_cfg_imagette_is_invalid(cfg, ICU_CHECK), PAR_SPECIFIC, ""); RETURN_ERROR_IF(cmp_cfg_imagette_is_invalid(cfg, ICU_CHECK), PAR_SPECIFIC, "");
...@@ -2777,7 +2777,7 @@ uint32_t compress_chunk_cmp_size_bound(const void *chunk, size_t chunk_size) ...@@ -2777,7 +2777,7 @@ uint32_t compress_chunk_cmp_size_bound(const void *chunk, size_t chunk_size)
/* count the number of collections in the chunk */ /* count the number of collections in the chunk */
for (read_bytes = 0; for (read_bytes = 0;
read_bytes <= (int32_t)chunk_size-COLLECTION_HDR_SIZE; read_bytes <= (int32_t)(chunk_size-COLLECTION_HDR_SIZE);
read_bytes += cmp_col_get_size((const struct collection_hdr *)((const uint8_t *)chunk + read_bytes))) read_bytes += cmp_col_get_size((const struct collection_hdr *)((const uint8_t *)chunk + read_bytes)))
num_col++; num_col++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment