diff --git a/lib/cmp_icu.h b/lib/cmp_icu.h
index 966caf36d5afb7e01b1d28b99ac0cac2292d31ea..4df2cff7ee24b6504a174961fc2fd0f02616269f 100644
--- a/lib/cmp_icu.h
+++ b/lib/cmp_icu.h
@@ -22,6 +22,6 @@
 
 #include "common/cmp_support.h"
 
-int32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info);
+uint32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info);
 
 #endif /* CMP_ICU_H */
diff --git a/lib/common/cmp_support.h b/lib/common/cmp_support.h
index 14c77a89dc6c51bb04817871e1c4fd15cf1ec054..ea2acf20d2881d7ffdea1acb07ce94a4901a6dd0 100644
--- a/lib/common/cmp_support.h
+++ b/lib/common/cmp_support.h
@@ -27,13 +27,7 @@
 #define CMP_COLLECTION_FILD_SIZE 2
 
 
-/* return code if the bitstream buffer is too small to store the whole bitstream */
-#define CMP_ERROR_SMALL_BUF -2
 
-/* return code if the value or the model is bigger than the max_used_bits
- * parameter allows
- */
-#define CMP_ERROR_HIGH_VALUE -3
 
 #define CMP_LOSSLESS	0
 #define CMP_PAR_UNUNSED	0
diff --git a/lib/icu_compress/cmp_icu.c b/lib/icu_compress/cmp_icu.c
index 2bb34647160b68b5b91bebcffa4e80de7fbaf6c8..d91c2e3ce15b7a41d92c1314e747d3f50b45e1f7 100644
--- a/lib/icu_compress/cmp_icu.c
+++ b/lib/icu_compress/cmp_icu.c
@@ -2273,14 +2273,13 @@ uint32_t compress_chunk_set_model_id_and_counter(void *dst, uint32_t dst_size,
  * @param info	pointer to a compression information structure contains the
  *		metadata of a compression (can be NULL)
  *
- * @returns the bit length of the bitstream on success; negative on error,
- *	CMP_ERROR_SMALL_BUF (-2) if the compressed data buffer is too small to
- *	hold the whole compressed data
+ * @returns the bit length of the bitstream on success or an error code if it
+ *	fails (which can be tested with cmp_is_error())
  *
  * @warning only the small buffer error in the info.cmp_err field is implemented
  */
 
-int32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info)
+uint32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info)
 {
 	struct cmp_cfg cfg = {0};
 	uint32_t cmp_size_bit;
@@ -2289,7 +2288,7 @@ int32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info)
 		memset(info, 0, sizeof(*info));
 
 	if (!rcfg)
-		return (int32_t)compress_data_internal(NULL, 0);
+		return compress_data_internal(NULL, 0);
 
 	cfg.data_type = DATA_TYPE_IMAGETTE;
 
@@ -2334,8 +2333,7 @@ int32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info)
 	cfg.updated_model_buf = rcfg->icu_new_model_buf;
 	cfg.dst = rcfg->icu_output_buf;
 
-	if (cmp_is_error(cmp_cfg_icu_is_invalid_error_code(&cfg)))
-		return (int32_t)cmp_cfg_icu_is_invalid_error_code(&cfg);
+	FORWARD_IF_ERROR(cmp_cfg_icu_is_invalid_error_code(&cfg), "");
 
 	cmp_size_bit = compress_data_internal(&cfg, 0);
 
@@ -2351,5 +2349,5 @@ int32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info)
 		}
 	}
 
-	return (int32_t)cmp_size_bit;
+	return cmp_size_bit;
 }
diff --git a/programs/cmp_guess.c b/programs/cmp_guess.c
index 6b1b3a2140bc1967364e272597d879206156523f..cada7823c60210fd71a7c5277f23c500219e5165 100644
--- a/programs/cmp_guess.c
+++ b/programs/cmp_guess.c
@@ -24,6 +24,7 @@
 
 #include <cmp_data_types.h>
 #include <cmp_icu.h>
+#include <cmp_chunk.h>
 #include <cmp_guess.h>
 #include <leon_inttypes.h>
 
@@ -121,7 +122,7 @@ uint32_t cmp_rdcu_get_good_spill(unsigned int golomb_par, enum cmp_mode cmp_mode
 static uint32_t pre_cal_method(struct rdcu_cfg *rcfg)
 {
 	uint32_t g;
-	int cmp_size, cmp_size_best = INT_MAX;
+	uint32_t cmp_size, cmp_size_best = INT_MAX;
 	uint32_t golomb_par_best = 0;
 	uint32_t spill_best = 0;
 
@@ -131,7 +132,7 @@ static uint32_t pre_cal_method(struct rdcu_cfg *rcfg)
 		rcfg->golomb_par = g;
 		rcfg->spill = s;
 		cmp_size = compress_like_rdcu(rcfg, NULL);
-		if (cmp_size <= 0) {
+		if (cmp_is_error(cmp_size)) {
 			return 0;
 		} else if (cmp_size < cmp_size_best) {
 			cmp_size_best = cmp_size;
@@ -160,7 +161,7 @@ static uint32_t brute_force(struct rdcu_cfg *rcfg)
 	uint32_t g, s;
 	uint32_t n_cal_steps = 0, last = 0;
 	const uint32_t max_cal_steps = CMP_GUESS_MAX_CAL_STEPS;
-	int cmp_size, cmp_size_best = INT_MAX;
+	uint32_t cmp_size, cmp_size_best = INT_MAX;
 	uint32_t golomb_par_best = 0;
 	uint32_t spill_best = 0;
 	uint32_t percent;
@@ -178,7 +179,7 @@ static uint32_t brute_force(struct rdcu_cfg *rcfg)
 			rcfg->spill = s;
 
 			cmp_size = compress_like_rdcu(rcfg, NULL);
-			if (cmp_size <= 0) {
+			if (cmp_is_error(cmp_size)) {
 				return 0;
 			} else if (cmp_size < cmp_size_best) {
 				cmp_size_best = cmp_size;
diff --git a/programs/cmp_tool.c b/programs/cmp_tool.c
index 4cb5531a9625c1af060990947e56f5152921557b..1bd900ea5352a8fab3e9aee8a22bbef583d2ff38 100644
--- a/programs/cmp_tool.c
+++ b/programs/cmp_tool.c
@@ -709,7 +709,7 @@ static int compression_for_rdcu(struct rdcu_cfg *rcfg)
 	uint64_t start_time = cmp_ent_create_timestamp(NULL);
 	enum cmp_data_type data_type = add_rdcu_pars ?
 		DATA_TYPE_IMAGETTE_ADAPTIVE : DATA_TYPE_IMAGETTE;
-	int32_t cmp_size;
+	uint32_t cmp_size;
 	int error;
 	uint32_t cmp_size_byte, out_buf_size;
 	size_t s;
@@ -750,8 +750,8 @@ static int compression_for_rdcu(struct rdcu_cfg *rcfg)
 	rcfg->icu_output_buf = cmp_ent_get_data_buf(cmp_entity);
 
 	cmp_size = compress_like_rdcu(rcfg, &info);
-	if (cmp_size < 0) {
-		if (cmp_size == CMP_ERROR_SMALL_BUF)
+	if (cmp_is_error(cmp_size)) {
+		if (cmp_get_error_code(cmp_size) == CMP_ERROR_SMALL_BUF_)
 			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;
 	}
@@ -759,7 +759,7 @@ static int compression_for_rdcu(struct rdcu_cfg *rcfg)
 	if (!model_counter && model_mode_is_used(rcfg->cmp_mode))
 		model_counter++;
 
-	s = cmp_ent_create(cmp_entity, data_type, rcfg->cmp_mode == CMP_MODE_RAW, cmp_bit_to_byte((unsigned int)cmp_size));
+	s = cmp_ent_create(cmp_entity, data_type, rcfg->cmp_mode == CMP_MODE_RAW, cmp_bit_to_byte(cmp_size));
 	if (!s) {
 		fprintf(stderr, "%s: error occurred while creating the compression entity header.\n", PROGRAM_NAME);
 		goto error_cleanup;
diff --git a/test/cmp_decmp/test_cmp_decmp.c b/test/cmp_decmp/test_cmp_decmp.c
index 461f0cf1d22f73802f2419f58665ebc5dd199002..66fcce228d61329a8770e90c369b963b1e2e12b4 100644
--- a/test/cmp_decmp/test_cmp_decmp.c
+++ b/test/cmp_decmp/test_cmp_decmp.c
@@ -709,8 +709,8 @@ void generate_random_cmp_par(struct cmp_par *par)
 
 void compression_decompression_like_rdcu(struct rdcu_cfg *rcfg)
 {
-	int cmp_size_bits, s, error;
-	uint32_t data_size, cmp_data_size, cmp_ent_size;
+	int s, error;
+	uint32_t cmp_size_bits, data_size, cmp_data_size, cmp_ent_size;
 	struct cmp_entity *ent;
 	void *decompressed_data;
 	static void *model_of_data;
@@ -745,11 +745,11 @@ void compression_decompression_like_rdcu(struct rdcu_cfg *rcfg)
 
 	/* now compress the data */
 	cmp_size_bits = compress_like_rdcu(rcfg, &info);
-	TEST_ASSERT(cmp_size_bits > 0);
+	TEST_ASSERT(!cmp_is_error(cmp_size_bits));
 
 	/* put the compression parameters in the entity header */
 	cmp_ent_size = cmp_ent_create(ent, DATA_TYPE_IMAGETTE, rcfg->cmp_mode == CMP_MODE_RAW,
-				      cmp_bit_to_byte((unsigned int)cmp_size_bits));
+				      cmp_bit_to_byte(cmp_size_bits));
 	TEST_ASSERT_NOT_EQUAL_UINT(0, cmp_ent_size);
 	error = cmp_ent_write_rdcu_cmp_pars(ent, &info, rcfg);
 	TEST_ASSERT_FALSE(error);
@@ -889,7 +889,7 @@ void test_random_compression_decompress_rdcu_data(void)
 	struct rdcu_cfg rcfg;
 	struct cmp_info info = {0};
 	int error, s, i;
-	int32_t cmp_size_bits;
+	uint32_t cmp_size_bits;
 	void *compressed_data;
 	uint16_t *decompressed_data;
 	enum {N_SAMPLES = 5};
@@ -908,7 +908,7 @@ void test_random_compression_decompress_rdcu_data(void)
 	rcfg.buffer_length = CMP_BUFFER_FAKTOR*N_SAMPLES;
 
 	cmp_size_bits = compress_like_rdcu(&rcfg, &info);
-	TEST_ASSERT(cmp_size_bits > 0);
+	TEST_ASSERT(!cmp_is_error(cmp_size_bits));
 
 	s = decompress_rdcu_data(compressed_data, &info, NULL, NULL, NULL);
 	TEST_ASSERT_EQUAL(sizeof(data), s);
diff --git a/test/cmp_icu/test_cmp_icu.c b/test/cmp_icu/test_cmp_icu.c
index 82cc9179425a5e37166deb46d744d6c861e6fd86..4bccc3a98de1b8e0297a6b37e4fa6ba17a03df51 100644
--- a/test/cmp_icu/test_cmp_icu.c
+++ b/test/cmp_icu/test_cmp_icu.c
@@ -1152,7 +1152,7 @@ void test_compress_imagette_diff(void)
 	uint32_t output_buf[3] = {0xFFFF, 0xFFFF, 0xFFFF};
 	struct rdcu_cfg rcfg = {0};
 	int error;
-	int32_t cmp_size;
+	uint32_t cmp_size;
 	struct cmp_info info;
 
 	uint32_t golomb_par = 1;
@@ -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(-2, cmp_size);
+	TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, 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]));
@@ -1266,7 +1266,7 @@ void test_compress_imagette_model(void)
 	uint32_t buffer_length = 8;
 	uint32_t golomb_par = 3;
 	uint32_t spill = 8;
-	int32_t cmp_size;
+	uint32_t cmp_size;
 	int error;
 
 	error = rdcu_cfg_create(&rcfg, CMP_MODE_MODEL_MULTI, model_value, CMP_LOSSLESS);
@@ -1299,8 +1299,8 @@ void test_compress_imagette_model(void)
 	/* error case: model mode without model data */
 	rcfg.model_buf = NULL; /* this is the error */
 	cmp_size = compress_like_rdcu(&rcfg, NULL);
-	TEST_ASSERT_TRUE(cmp_is_error((uint32_t)cmp_size));
-	TEST_ASSERT_EQUAL(CMP_ERROR_PAR_NO_MODEL, cmp_get_error_code((uint32_t)cmp_size));
+	TEST_ASSERT_TRUE(cmp_is_error(cmp_size));
+	TEST_ASSERT_EQUAL(CMP_ERROR_PAR_NO_MODEL, cmp_get_error_code(cmp_size));
 }
 
 
@@ -1314,7 +1314,7 @@ void test_compress_imagette_raw(void)
 	void *output_buf = malloc(7*sizeof(uint16_t));
 	uint16_t cmp_data[7];
 	struct rdcu_cfg rcfg = {0};
-	int32_t cmp_size;
+	uint32_t cmp_size;
 
 	rcfg.cmp_mode = CMP_MODE_RAW;
 	rcfg.model_buf = NULL;
@@ -1347,8 +1347,8 @@ void test_compress_imagette_raw(void)
 
 	/* error case: cfg = NULL */
 	cmp_size = compress_like_rdcu(NULL, NULL);
-	TEST_ASSERT_TRUE(cmp_is_error((uint32_t)cmp_size));
-	TEST_ASSERT_EQUAL_INT(CMP_ERROR_GENERIC, cmp_get_error_code((uint32_t)cmp_size));
+	TEST_ASSERT_TRUE(cmp_is_error(cmp_size));
+	TEST_ASSERT_EQUAL_INT(CMP_ERROR_GENERIC, cmp_get_error_code(cmp_size));
 
 	/* error case: input_buf = NULL */
 	memset(&rcfg, 0, sizeof(rcfg));
@@ -1358,8 +1358,8 @@ void test_compress_imagette_raw(void)
 	rcfg.buffer_length = 7;
 
 	cmp_size = compress_like_rdcu(&rcfg, NULL);
-	TEST_ASSERT_TRUE(cmp_is_error((uint32_t)cmp_size));
-	TEST_ASSERT_EQUAL_INT(CMP_ERROR_CHUNK_NULL, cmp_get_error_code((uint32_t)cmp_size));
+	TEST_ASSERT_TRUE(cmp_is_error(cmp_size));
+	TEST_ASSERT_EQUAL_INT(CMP_ERROR_CHUNK_NULL, cmp_get_error_code(cmp_size));
 
 
 	/* error case: compressed data buffer to small */
@@ -1370,8 +1370,8 @@ void test_compress_imagette_raw(void)
 	rcfg.buffer_length = 6; /* the buffer is to small */
 
 	cmp_size = compress_like_rdcu(&rcfg, NULL);
-	TEST_ASSERT_TRUE(cmp_is_error((uint32_t)cmp_size));
-	TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code((uint32_t)cmp_size));
+	TEST_ASSERT_TRUE(cmp_is_error(cmp_size));
+	TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size));
 
 	free(output_buf);
 }
@@ -1386,7 +1386,7 @@ void test_compress_imagette_error_cases(void)
 	uint16_t data[] = {0xFFFF, 1, 0, 42, 0x8000, 0x7FFF, 0xFFFF};
 	uint32_t output_buf[2] = {0xFFFF, 0xFFFF};
 	struct rdcu_cfg rcfg = {0};
-	int32_t cmp_size;
+	uint32_t cmp_size;
 
 	rcfg.cmp_mode = CMP_MODE_DIFF_ZERO;
 	rcfg.input_buf = data;
@@ -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_size);
+	TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, 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_size);
+	TEST_ASSERT_EQUAL_INT(CMP_ERROR_SMALL_BUF_, cmp_get_error_code(cmp_size));
 
 
 	/* test unknown cmp_mode */
@@ -1435,8 +1435,8 @@ void test_compress_imagette_error_cases(void)
 	rcfg.buffer_length = 4;
 
 	cmp_size = compress_like_rdcu(&rcfg, NULL);
-	TEST_ASSERT_TRUE(cmp_is_error((uint32_t)cmp_size));
-	TEST_ASSERT_EQUAL_INT(CMP_ERROR_PAR_GENERIC, cmp_get_error_code((uint32_t)cmp_size));
+	TEST_ASSERT_TRUE(cmp_is_error(cmp_size));
+	TEST_ASSERT_EQUAL_INT(CMP_ERROR_PAR_GENERIC, cmp_get_error_code(cmp_size));
 
 	/* test golomb_par = 0 */
 	rcfg.cmp_mode = CMP_MODE_DIFF_ZERO;
@@ -1448,8 +1448,8 @@ void test_compress_imagette_error_cases(void)
 	rcfg.buffer_length = 4;
 
 	cmp_size = compress_like_rdcu(&rcfg, NULL);
-	TEST_ASSERT_TRUE(cmp_is_error((uint32_t)cmp_size));
-	TEST_ASSERT_EQUAL_INT(CMP_ERROR_PAR_SPECIFIC, cmp_get_error_code((uint32_t)cmp_size));
+	TEST_ASSERT_TRUE(cmp_is_error(cmp_size));
+	TEST_ASSERT_EQUAL_INT(CMP_ERROR_PAR_SPECIFIC, cmp_get_error_code(cmp_size));
 }
 
 
diff --git a/test/decmp/test_decmp.c b/test/decmp/test_decmp.c
index c8d379b3f9848fde1e1908f0f2d1a32713508bfd..44048ea215e2ac86ede3ed55e3af6539b5226f7c 100644
--- a/test/decmp/test_decmp.c
+++ b/test/decmp/test_decmp.c
@@ -952,7 +952,8 @@ void test_re_map_to_pos(void)
 
 void test_cmp_decmp_rdcu_raw(void)
 {
-	int cmp_size, decmp_size;
+	uint32_t cmp_size;
+	int decmp_size;
 	size_t s, i;
 	struct rdcu_cfg rcfg = {0};
 	struct cmp_info info;
@@ -971,19 +972,19 @@ void test_cmp_decmp_rdcu_raw(void)
 	rcfg.icu_output_buf = compressed_data;
 
 	cmp_size = compress_like_rdcu(&rcfg, &info);
-	TEST_ASSERT_EQUAL_INT(sizeof(data)*CHAR_BIT, cmp_size);
+	TEST_ASSERT_EQUAL_UINT(sizeof(data)*CHAR_BIT, cmp_size);
 
 	s = cmp_ent_create(NULL, DATA_TYPE_IMAGETTE , rcfg.cmp_mode == CMP_MODE_RAW,
-			   cmp_bit_to_byte((unsigned int)cmp_size));
+			   cmp_bit_to_byte(cmp_size));
 	TEST_ASSERT_TRUE(s);
 	ent = malloc(s);
 	TEST_ASSERT_TRUE(ent);
 	s = cmp_ent_create(ent, DATA_TYPE_IMAGETTE , rcfg.cmp_mode == CMP_MODE_RAW,
-			   cmp_bit_to_byte((unsigned int)cmp_size));
+			   cmp_bit_to_byte(cmp_size));
 	TEST_ASSERT_TRUE(s);
 	TEST_ASSERT_FALSE(cmp_ent_write_rdcu_cmp_pars(ent, &info, NULL));
 
-	memcpy(cmp_ent_get_data_buf(ent), compressed_data, ((unsigned int)cmp_size+7)/8);
+	memcpy(cmp_ent_get_data_buf(ent), compressed_data, (cmp_size+7)/8);
 
 	decmp_size = decompress_cmp_entiy(ent, NULL, NULL, NULL);
 	TEST_ASSERT_EQUAL_INT(sizeof(data), decmp_size);