diff --git a/include/cmp_data_types.h b/include/cmp_data_types.h
index 02bb840d3d23eca55baf987971b2782dbcf3a808..9c8a470da9861d493b4f227cfe9076c8b7009324 100644
--- a/include/cmp_data_types.h
+++ b/include/cmp_data_types.h
@@ -36,8 +36,8 @@
 
 #include <stdint.h>
 
-#include "compiler.h"
-#include "cmp_support.h"
+#include <compiler.h>
+#include <cmp_support.h>
 
 #define MAX_USED_NC_IMAGETTE_BITS		16
 #define MAX_USED_SATURATED_IMAGETTE_BITS	16 /* TBC */
@@ -135,6 +135,7 @@ extern struct cmp_max_used_bits max_used_bits;
 #define MULTI_ENTRY_HDR_SIZE 12
 compile_time_assert(MULTI_ENTRY_HDR_SIZE % sizeof(uint32_t) == 0, N_DPU_ICU_MULTI_ENTRY_HDR_NOT_4_BYTE_ALLIED);
 
+__extension__
 struct multi_entry_hdr {
 	uint32_t timestamp_coarse;
 	uint16_t timestamp_fine;
@@ -206,6 +207,7 @@ struct f_fx_efx_ncob_ecob {
 } __attribute__((packed));
 
 
+__extension__
 struct l_fx {
 	uint32_t exp_flags:24; /* selected exposure flags (24 flags) */
 	uint32_t fx;
@@ -213,6 +215,7 @@ struct l_fx {
 } __attribute__((packed));
 
 
+__extension__
 struct l_fx_efx {
 	uint32_t exp_flags:24; /* selected exposure flags (24 flags) */
 	uint32_t fx;
@@ -221,6 +224,7 @@ struct l_fx_efx {
 } __attribute__((packed));
 
 
+__extension__
 struct l_fx_ncob {
 	uint32_t exp_flags:24; /* selected exposure flags (24 flags) */
 	uint32_t fx;
@@ -232,6 +236,7 @@ struct l_fx_ncob {
 } __attribute__((packed));
 
 
+__extension__
 struct l_fx_efx_ncob_ecob {
 	uint32_t exp_flags:24; /* selected exposure flags (24 flags) */
 	uint32_t fx;
diff --git a/include/cmp_entity.h b/include/cmp_entity.h
index a06715ff1001edd4e1c41e7aa373cbcfdc094ab5..0c9a6062b81efb94ca9ad0ecccb7577b0dcaa7c9 100644
--- a/include/cmp_entity.h
+++ b/include/cmp_entity.h
@@ -29,8 +29,8 @@
 
 #include <stdint.h>
 
-#include "compiler.h"
-#include "cmp_support.h"
+#include <compiler.h>
+#include <cmp_support.h>
 
 
 #define GENERIC_HEADER_SIZE 32
@@ -285,11 +285,13 @@ ssize_t cmp_ent_get_cmp_data(struct cmp_entity *ent, uint32_t *data_buf,
 uint32_t cmp_ent_cal_hdr_size(enum cmp_data_type data_type, int raw_mode);
 
 
-#if __has_include(<time.h>)
-#include <time.h>
+#if defined __has_include
+#  if __has_include(<time.h>)
+#    include <time.h>
 /* create a timestamp for the compression header */
 extern const struct tm EPOCH_DATE;
 uint64_t cmp_ent_create_timestamp(const struct timespec *ts);
+#  endif
 #endif
 
 /* print and parse functions */
diff --git a/include/cmp_guess.h b/include/cmp_guess.h
index 9d3ac4294437dcaec425914a9634adbe58ed41c1..4b26e9cae965aa0aceea4e12fce0cf0549607939 100644
--- a/include/cmp_guess.h
+++ b/include/cmp_guess.h
@@ -20,8 +20,7 @@
 #ifndef CMP_GUESS_H
 #define CMP_GUESS_H
 
-#include "cmp_support.h"
-
+#include <cmp_support.h>
 
 
 #define DEFAULT_GUESS_LEVEL 2
diff --git a/include/cmp_icu.h b/include/cmp_icu.h
index 81a1160fedf19e711e0f2aa390244905814e25e0..01e528c1c887e534066349860cc96f7ae4fbc971 100644
--- a/include/cmp_icu.h
+++ b/include/cmp_icu.h
@@ -20,7 +20,7 @@
 #ifndef _CMP_ICU_H_
 #define _CMP_ICU_H_
 
-#include "cmp_support.h"
+#include <cmp_support.h>
 
 
 /* return code if the bitstream buffer is too small to store the whole bitstream */
diff --git a/include/cmp_io.h b/include/cmp_io.h
index f807825e2c3253786ec8cdbfeb1b80aa7caad2d9..6de2222d8ba50322e79afaa55e564b510c007647 100644
--- a/include/cmp_io.h
+++ b/include/cmp_io.h
@@ -17,8 +17,8 @@
 
 #include <string.h>
 
-#include "cmp_support.h"
-#include "cmp_entity.h"
+#include <cmp_support.h>
+#include <cmp_entity.h>
 
 #define MAX_CONFIG_LINE 256
 
diff --git a/include/cmp_rdcu.h b/include/cmp_rdcu.h
index 14e0af937fa945d3cd3afee7985fc862695c96cc..6273549953b55fabe1f94099b4fb204174133921 100644
--- a/include/cmp_rdcu.h
+++ b/include/cmp_rdcu.h
@@ -21,7 +21,7 @@
 #ifndef _CMP_RDCU_H_
 #define _CMP_RDCU_H_
 
-#include "cmp_support.h"
+#include <cmp_support.h>
 
 
 /* Compression Error Register bits definition, see RDCU-FRS-FN-0952 */
diff --git a/include/cmp_rdcu_extended.h b/include/cmp_rdcu_extended.h
index a4f33e030549419ca1e120bcc4a2a77b2d092532..7ab229b5fd1df7519651916d55f1192cae877788 100644
--- a/include/cmp_rdcu_extended.h
+++ b/include/cmp_rdcu_extended.h
@@ -18,7 +18,7 @@
 #ifndef _CMP_RDCU_EXTENDED_H_
 #define _CMP_RDCU_EXTENDED_H_
 
-#include "../include/cmp_rdcu.h"
+#include <cmp_rdcu.h>
 
 int rdcu_start_compression(void);
 
diff --git a/include/cmp_support.h b/include/cmp_support.h
index 850f0a7792274a9f3cb00c3e04165f3d87f929f8..f5e0b38e5cf0fb533c53dd88bbce46480648c00d 100644
--- a/include/cmp_support.h
+++ b/include/cmp_support.h
@@ -109,7 +109,7 @@ enum cmp_data_type {
 	DATA_TYPE_F_CAM_IMAGETTE,
 	DATA_TYPE_F_CAM_IMAGETTE_ADAPTIVE,
 	DATA_TYPE_F_CAM_OFFSET,
-	DATA_TYPE_F_CAM_BACKGROUND,
+	DATA_TYPE_F_CAM_BACKGROUND
 };
 
 
diff --git a/include/decmp.h b/include/decmp.h
index 2f8478cfb9cf0824876add977f896a8afa2ab38a..404679835d475a344da5de98f4b512d700cc4bd4 100644
--- a/include/decmp.h
+++ b/include/decmp.h
@@ -19,10 +19,8 @@
 #ifndef DECMP_H_
 #define DECMP_H_
 
-#include "cmp_entity.h"
-#include "cmp_support.h"
-
-void *malloc_decompressed_data(const struct cmp_info *info);
+#include <cmp_entity.h>
+#include <cmp_support.h>
 
 int decompress_data(uint32_t *compressed_data, void *de_model_buf,
 		    const struct cmp_info *info, void *decompressed_data);
@@ -30,6 +28,4 @@ int decompress_data(uint32_t *compressed_data, void *de_model_buf,
 int decompress_cmp_entiy(struct cmp_entity *ent, void *model_buf,
 			 void *up_model_buf, void *decompressed_data);
 
-double get_compression_ratio(const struct cmp_info *info);
-
 #endif /* DECMP_H_ */
diff --git a/include/rdcu_ctrl.h b/include/rdcu_ctrl.h
index ec5b9a2c919621c318fc3550a4a444c2155f63a8..ac3f03f9b0788e3f63977b017beaf946c803378c 100644
--- a/include/rdcu_ctrl.h
+++ b/include/rdcu_ctrl.h
@@ -245,11 +245,14 @@ uint32_t rdcu_get_golomb_param(void);
 
 uint32_t rdcu_get_compr_data_start_addr(void);
 
-uint32_t rdcu_get_compr_data_size(void);
+uint32_t rdcu_get_compr_data_size_bit(void);
+uint32_t rdcu_get_compr_data_size_byte(void);
 
-uint32_t rdcu_get_compr_data_adaptive_1_size(void);
+uint32_t rdcu_get_compr_data_adaptive_1_size_bit(void);
+uint32_t rdcu_get_compr_data_adaptive_1_size_byte(void);
 
-uint32_t rdcu_get_compr_data_adaptive_2_size(void);
+uint32_t rdcu_get_compr_data_adaptive_2_size_bit(void);
+uint32_t rdcu_get_compr_data_adaptive_2_size_byte(void);
 
 uint16_t rdcu_get_compr_error(void);
 
diff --git a/include/rdcu_pkt_to_file.h b/include/rdcu_pkt_to_file.h
index 87c3d4b72fbf0189e2fb5ee193eca092ffcfb8b9..1c350c8c885d57d03d1e279154584bc40fc2ee77 100644
--- a/include/rdcu_pkt_to_file.h
+++ b/include/rdcu_pkt_to_file.h
@@ -18,7 +18,7 @@
 #ifndef _RDCU_PKT_TO_FILE_H_
 #define _RDCU_PKT_TO_FILE_H_
 
-#include "cmp_support.h"
+#include <cmp_support.h>
 
 /* directory where the tc files are stored, when --rdcu_pkt option is set */
 #define TC_DIR "TC_FILES"
diff --git a/include/rmap.h b/include/rmap.h
index 5156679c0c37bd7c805eec3fb9fa0e3eb82dbb6e..c5815750e7f5e99eb219ea0efe391ce0e92fd1a0 100644
--- a/include/rmap.h
+++ b/include/rmap.h
@@ -20,6 +20,7 @@
 #define RMAP_H
 
 #include <stdint.h>
+#include <compiler.h>
 
 /**
  * valid RMAP command codes, see Table 5-1 of ECSS‐E‐ST‐50‐52C
@@ -149,11 +150,9 @@ struct rmap_instruction {
 #else
 #error "Unknown byte order"
 #endif
-}__attribute__((packed));
-#if 0
-compile_time_assert((sizeof(struct rmap_instruction) == sizeof(uint8_t),
-		    RMAP_INSTRUCTION_STRUCT_WRONG_SIZE));
-#endif
+} __attribute__((packed));
+
+compile_time_assert(sizeof(struct rmap_instruction) == sizeof(uint8_t), RMAP_INSTRUCTION_STRUCT_WRONG_SIZE);
 
 
 /**
diff --git a/lib/cmp_data_types.c b/lib/cmp_data_types.c
index 749964d1a1850079ed2f1441966fcabec8f046fd..8dd5792cde451945a866338a797111b8d88f69a1 100644
--- a/lib/cmp_data_types.c
+++ b/lib/cmp_data_types.c
@@ -17,9 +17,9 @@
  */
 
 
-#include "cmp_data_types.h"
-#include "cmp_debug.h"
-#include "byteorder.h"
+#include <cmp_data_types.h>
+#include <cmp_debug.h>
+#include <byteorder.h>
 
 
 /* the maximum length of the different data products types in bits */
diff --git a/lib/cmp_entity.c b/lib/cmp_entity.c
index d058b17182fc872e854678d8d4ccc175dd10e1ec..029689425df59f2e864df68007b1fad06c9ba1f3 100644
--- a/lib/cmp_entity.c
+++ b/lib/cmp_entity.c
@@ -30,11 +30,11 @@
 #  endif
 #endif
 
-#include "byteorder.h"
-#include "cmp_debug.h"
-#include "cmp_support.h"
-#include "cmp_data_types.h"
-#include "cmp_entity.h"
+#include <byteorder.h>
+#include <cmp_debug.h>
+#include <cmp_support.h>
+#include <cmp_data_types.h>
+#include <cmp_entity.h>
 
 
 #ifdef HAS_TIME_H
diff --git a/lib/cmp_guess.c b/lib/cmp_guess.c
index c1738142727497ff850770f7e9d6e06943a0c32c..3107aaf00795d74614e8f30dd331c1c90245c224 100644
--- a/lib/cmp_guess.c
+++ b/lib/cmp_guess.c
@@ -15,6 +15,7 @@
  *
  * @brief helps the user to find a good compression parameters for a given
  *	dataset
+ * @warning this part of the software is not intended to run on-board on the ICU.
  */
 
 #include <limits.h>
diff --git a/lib/cmp_icu.c b/lib/cmp_icu.c
index 057ee642f1254caa5e1c3c7e06bdd61acbe35a91..2d11006bfa117ac36c1e507e628e9be23ff1f4b9 100644
--- a/lib/cmp_icu.c
+++ b/lib/cmp_icu.c
@@ -32,11 +32,11 @@
 #include <string.h>
 #include <limits.h>
 
-#include "byteorder.h"
-#include "cmp_debug.h"
-#include "cmp_data_types.h"
-#include "cmp_support.h"
-#include "cmp_icu.h"
+#include <byteorder.h>
+#include <cmp_debug.h>
+#include <cmp_data_types.h>
+#include <cmp_support.h>
+#include <cmp_icu.h>
 
 
 /* pointer to a code word generation function */
@@ -75,7 +75,9 @@ struct cmp_cfg cmp_cfg_icu_create(enum cmp_data_type data_type, enum cmp_mode cm
 				  uint32_t model_value, uint32_t lossy_par)
 {
 	int cfg_valid;
-	struct cmp_cfg cfg = {0};
+	struct cmp_cfg cfg;
+
+	memset(&cfg, 0, sizeof(cfg));
 
 	cfg.data_type = data_type;
 	cfg.cmp_mode = cmp_mode;
diff --git a/lib/cmp_io.c b/lib/cmp_io.c
index 99e80c63aee9e167a615bc33a694ed1dc74f77a0..0e74c0d8cd283248548bfc340e8c41a2a5717b2f 100644
--- a/lib/cmp_io.c
+++ b/lib/cmp_io.c
@@ -15,6 +15,7 @@
  * more details.
  *
  * @brief compression tool Input/Output library
+ * @warning this part of the software is not intended to run on-board on the ICU.
  */
 
 #include <stdio.h>
@@ -24,12 +25,12 @@
 #include <ctype.h>
 #include <sys/stat.h>
 
-#include "cmp_tool-config.h"
-#include "cmp_io.h"
-#include "cmp_support.h"
-#include "rdcu_cmd.h"
-#include "byteorder.h"
-#include "cmp_data_types.h"
+#include <cmp_tool-config.h>
+#include <cmp_io.h>
+#include <cmp_support.h>
+#include <rdcu_cmd.h>
+#include <byteorder.h>
+#include <cmp_data_types.h>
 
 
 /* directory to convert from data_type to string */
diff --git a/lib/cmp_rdcu.c b/lib/cmp_rdcu.c
index 2a8f2144d1f14f5301c0b2ba2ae1d0d4670e2fa7..336fc87224293e8144aaee9bb93aa4347729227a 100644
--- a/lib/cmp_rdcu.c
+++ b/lib/cmp_rdcu.c
@@ -28,13 +28,14 @@
 
 #include <stdint.h>
 #include <stdio.h>
+#include <string.h>
 
-#include "rdcu_cmd.h"
-#include "cmp_support.h"
-#include "cmp_data_types.h"
-#include "rdcu_ctrl.h"
-#include "rdcu_rmap.h"
-#include "cmp_debug.h"
+#include <rdcu_cmd.h>
+#include <cmp_debug.h>
+#include <cmp_support.h>
+#include <cmp_data_types.h>
+#include <rdcu_ctrl.h>
+#include <rdcu_rmap.h>
 
 
 #define IMA_SAM2BYT                                                            \
@@ -144,7 +145,9 @@ static int rdcu_cfg_gen_par_is_invalid(const struct cmp_cfg *cfg)
 struct cmp_cfg rdcu_cfg_create(enum cmp_data_type data_type, enum cmp_mode cmp_mode,
 			       uint32_t model_value, uint32_t lossy_par)
 {
-	struct cmp_cfg cfg = {0};
+	struct cmp_cfg cfg;
+
+	memset(&cfg, 0, sizeof(cfg));
 
 	cfg.data_type = data_type;
 	cfg.cmp_mode = cmp_mode;
@@ -157,6 +160,7 @@ struct cmp_cfg rdcu_cfg_create(enum cmp_data_type data_type, enum cmp_mode cmp_m
 	return cfg;
 }
 
+
 /**
  * @brief check if a buffer is in inside the RDCU SRAM
  *
@@ -801,9 +805,9 @@ int rdcu_read_cmp_info(struct cmp_info *info)
 		info->rdcu_new_model_adr_used = rdcu_get_new_model_addr_used();
 		info->samples_used = rdcu_get_samples_used();
 		info->rdcu_cmp_adr_used = rdcu_get_compr_data_start_addr();
-		info->cmp_size = rdcu_get_compr_data_size();
-		info->ap1_cmp_size = rdcu_get_compr_data_adaptive_1_size();
-		info->ap2_cmp_size = rdcu_get_compr_data_adaptive_2_size();
+		info->cmp_size = rdcu_get_compr_data_size_bit();
+		info->ap1_cmp_size = rdcu_get_compr_data_adaptive_1_size_bit();
+		info->ap2_cmp_size = rdcu_get_compr_data_adaptive_2_size_bit();
 		info->cmp_err = rdcu_get_compr_error();
 	}
 	return 0;
diff --git a/lib/cmp_support.c b/lib/cmp_support.c
index a02e8979ee1c6829c2deda5cf533aef78ff8dc4b..666ce966a121108f1174154ef4b07671645ae185 100644
--- a/lib/cmp_support.c
+++ b/lib/cmp_support.c
@@ -18,8 +18,8 @@
  */
 
 
-#include "cmp_support.h"
-#include "cmp_debug.h"
+#include <cmp_support.h>
+#include <cmp_debug.h>
 
 
 /**
@@ -378,13 +378,15 @@ unsigned int cmp_up_model(unsigned int data, unsigned int model,
 			  unsigned int model_value, unsigned int round)
 
 {
+	uint64_t weighted_model, weighted_data;
+
 	/* round and round back input because for decompression the accurate
 	 * data values are not available
 	 */
 	data = round_inv(round_fwd(data, round), round);
 	/* cast uint64_t to prevent overflow in the multiplication */
-	uint64_t weighted_model = (uint64_t)model * model_value;
-	uint64_t weighted_data = (uint64_t)data * (MAX_MODEL_VALUE - model_value);
+	weighted_model = (uint64_t)model * model_value;
+	weighted_data = (uint64_t)data * (MAX_MODEL_VALUE - model_value);
 	/* truncation is intended */
 	return (unsigned int)((weighted_model + weighted_data) / MAX_MODEL_VALUE);
 }
diff --git a/lib/rdcu_ctrl.c b/lib/rdcu_ctrl.c
index a1e3b0ffdf92197ebba433c04a4291b71c22df1a..6f743c68c09bc656bef11a941845d1d9cb7847ea 100644
--- a/lib/rdcu_ctrl.c
+++ b/lib/rdcu_ctrl.c
@@ -1305,44 +1305,97 @@ uint32_t rdcu_get_compr_data_start_addr(void)
 
 
 /**
- * @brief get compressed data size
+ * @brief get the need bytes for the given bits
+ *
+ * @param cmp_size_bit compressed data size, measured in bits
+ *
+ * @returns the size in bytes to store the compressed data
+ */
+
+static uint32_t rdcu_bit_to_byte(unsigned int cmp_size_bit)
+{
+	return ((cmp_size_bit + 7) / 8);
+}
+
+
+/**
+ * @brief get compressed data size in bits
  * @see RDCU-FRS-FN-0922
  *
  * @returns the compressed data size in bits
  */
 
-uint32_t rdcu_get_compr_data_size(void)
+uint32_t rdcu_get_compr_data_size_bit(void)
 {
 	return rdcu->compr_data_size;
 }
 
 
 /**
- * @brief get compressed data adaptive 1 size
+ * @brief get compressed data size in bytes
+ * @see RDCU-FRS-FN-0922
+ *
+ * @returns the compressed data size in bytes
+ */
+
+uint32_t rdcu_get_compr_data_size_byte(void)
+{
+	return rdcu_bit_to_byte(rdcu_get_compr_data_size_bit());
+}
+
+
+/**
+ * @brief get compressed data adaptive 1 size in bits
  * @see RDCU-FRS-FN-0932
  *
  * @returns the adaptive 1 compressed data size in bits
  */
 
-uint32_t rdcu_get_compr_data_adaptive_1_size(void)
+uint32_t rdcu_get_compr_data_adaptive_1_size_bit(void)
 {
 	return rdcu->compr_data_adaptive_1_size;
 }
 
 
 /**
- * @brief get compressed data adaptive 2 size
+ * @brief get compressed data adaptive 1 size in bytes
+ * @see RDCU-FRS-FN-0932
+ *
+ * @returns the adaptive 1 compressed data size in bytes
+ */
+
+uint32_t rdcu_get_compr_data_adaptive_1_size_byte(void)
+{
+	return rdcu_bit_to_byte(rdcu_get_compr_data_adaptive_1_size_bit());
+}
+
+
+/**
+ * @brief get compressed data adaptive 2 size in bits
  * @see RDCU-FRS-FN-0942
  *
  * @returns the adaptive 2 compressed data size in bits
  */
 
-uint32_t rdcu_get_compr_data_adaptive_2_size(void)
+uint32_t rdcu_get_compr_data_adaptive_2_size_bit(void)
 {
 	return rdcu->compr_data_adaptive_2_size;
 }
 
 
+/**
+ * @brief get compressed data adaptive 2 size in bytes
+ * @see RDCU-FRS-FN-0942
+ *
+ * @returns the adaptive 2 compressed data size in bytes
+ */
+
+uint32_t rdcu_get_compr_data_adaptive_2_size_byte(void)
+{
+	return rdcu_bit_to_byte(rdcu_get_compr_data_adaptive_2_size_bit());
+}
+
+
 /**
  * @brief get compression error code
  * @see RDCU-FRS-FN-0954
@@ -1606,7 +1659,7 @@ int rdcu_write_sram_16(uint16_t *buf, uint32_t addr, uint32_t size)
 	{
 		uint32_t i;
 
-		for (i = 0; i < size/sizeof(uint16_t); i++){
+		for (i = 0; i < size/sizeof(uint16_t); i++) {
 			uint16_t *sram_buf = (uint16_t *)&rdcu->sram[addr];
 
 			sram_buf[i] = cpu_to_be16(buf[i]);
@@ -1652,9 +1705,9 @@ int rdcu_write_sram_32(uint32_t *buf, uint32_t addr, uint32_t size)
 	{
 		uint32_t i;
 
-	for (i = 0; i < size/sizeof(uint32_t); i++){
-		uint32_t *sram_buf = (uint32_t *)&rdcu->sram[addr];
-	
+		for (i = 0; i < size/sizeof(uint32_t); i++) {
+			uint32_t *sram_buf = (uint32_t *)&rdcu->sram[addr];
+
 			sram_buf[i] = cpu_to_be32(buf[i]);
 		}
 	}
@@ -2466,14 +2519,12 @@ int rdcu_sync_sram_mirror_parallel(uint32_t rx_addr, uint32_t rx_size,
 
 int rdcu_ctrl_init(void)
 {
-	rdcu = (struct rdcu_mirror *) malloc(sizeof(struct rdcu_mirror));
-	if (!rdcu){
+	rdcu = (struct rdcu_mirror *) calloc(1, sizeof(struct rdcu_mirror));
+	if (!rdcu) {
 		printf("Error allocating memory for the RDCU mirror\n");
 		return -1;
 	}
 
-	memset(rdcu, 0, sizeof(struct rdcu_mirror));
-
 #if (__sparc__)
 	rdcu->sram =  (uint8_t *) 0x60000000;
 #else /* assume PC */
@@ -2485,7 +2536,7 @@ int rdcu_ctrl_init(void)
 	}
 #endif
 
-	memset(rdcu->sram, 0, RDCU_SRAM_SIZE);
-	
+	memset(rdcu->sram, 0, RDCU_SRAM_SIZE);  /* clear sram buffer */
+
 	return 0;
 }
diff --git a/lib/rdcu_pkt_to_file.c b/lib/rdcu_pkt_to_file.c
index 0c71c8eeebb5d674035c1021f8c81b823c97f5d6..ed10778c11ef793b47826f54870b0df50948f9f5 100644
--- a/lib/rdcu_pkt_to_file.c
+++ b/lib/rdcu_pkt_to_file.c
@@ -17,7 +17,7 @@
  *
  * This library provided a rmap_rx and rmap_tx function for the rdcu_rmap
  * library to write generated packets into text files.
- *
+ * @warning this part of the software is not intended to run on-board on the ICU.
  */
 
 #include <stdint.h>
@@ -28,11 +28,11 @@
 #include <errno.h>
 #include <sys/stat.h>
 
-#include "rdcu_pkt_to_file.h"
-#include "cmp_rdcu_extended.h"
-#include "rdcu_rmap.h"
-#include "rdcu_ctrl.h"
-#include "rdcu_cmd.h"
+#include <rdcu_pkt_to_file.h>
+#include <cmp_rdcu_extended.h>
+#include <rdcu_rmap.h>
+#include <rdcu_ctrl.h>
+#include <rdcu_cmd.h>
 
 /* Name of directory were the RMAP packages are stored */
 static char tc_folder_dir[MAX_TC_FOLDER_DIR_LEN] = "TC_FILES";
diff --git a/lib/rdcu_rmap.c b/lib/rdcu_rmap.c
index f6035cb519815fc287e234dde2039d7c850088df..b314b470801f5464d0ac801e545e563c23ed7ac8 100644
--- a/lib/rdcu_rmap.c
+++ b/lib/rdcu_rmap.c
@@ -70,7 +70,7 @@
 #include <rmap.h>
 #include <rdcu_rmap.h>
 
-
+#define RDCU_CONFIG_DEBUG 0
 
 static uint8_t rdcu_addr;
 static uint8_t icu_addr;
@@ -116,8 +116,8 @@ static size_t data_mtu;	/* maximum data transfer size per unit */
  * Every time a slot is retrieved, the "pending" counter is incremented to
  * have a fast indicator of the synchronisation status, i.e. if "pending"
  * is not set, the synchronisation procedure is complete and the local data may
- * be read, or the remote data has been written and further commands may may
- * be issued.
+ * be read, or the remote data has been written and further commands may be
+ * issued.
  *
  * The local (mirror) start address of the requested remote address is stored
  * into the same slot in the "local_addr" array, so we'll know where to put the
@@ -261,7 +261,7 @@ static int rdcu_process_rx(void)
 
 		cnt++;
 
-		if ((0))
+		if (RDCU_CONFIG_DEBUG)
 			rmap_parse_pkt(spw_pckt);
 
 		/* convert format */
@@ -276,25 +276,20 @@ static int rdcu_process_rx(void)
 		local_addr = trans_log_get_addr(rp->tr_id);
 
 		if (!local_addr) {
-			printf("warning: response packet received not in "
-			       "transaction log\n");
+			printf("Warning: response packet received not in transaction log\n");
 			rmap_erase_packet(rp);
 			continue;
 		}
 
-
 		if (rp->data_len & 0x3) {
-			printf("Error: response packet data size is not a "
-			       "multiple of 4, transaction dropped\n");
+			printf("Error: response packet data size is not a multiple of 4, transaction dropped\n");
 
 			trans_log_release_slot(rp->tr_id);
 			rmap_erase_packet(rp);
 			return -1;
 		}
 
-
 		if (rp->data_len) {
-
 			uint8_t crc8;
 
 			/* convert endianess if needed */
@@ -308,13 +303,9 @@ static int rdcu_process_rx(void)
 			}
 #endif /* __BYTE_ORDER__ */
 
-
 			crc8 = rmap_crc8(rp->data, rp->data_len);
-
 			if (crc8 != rp->data_crc) {
-
-				printf("Error: data CRC8 mismatch, data invalid or "
-				       "packet truncated. Transaction dropped\n");
+				printf("Error: data CRC8 mismatch, data invalid or packet truncated. Transaction dropped\n");
 
 				trans_log_release_slot(rp->tr_id);
 				rmap_erase_packet(rp);
@@ -353,7 +344,7 @@ int rdcu_submit_tx(const uint8_t *cmd,  int cmd_size,
 	if (!rmap_tx)
 		return -1;
 
-	if ((0))
+	if (RDCU_CONFIG_DEBUG)
 		printf("Transmitting RMAP command\n");
 
 	if (rmap_tx(cmd, cmd_size, dpath_len, data, data_size)) {
@@ -413,7 +404,7 @@ int rdcu_gen_cmd(uint16_t trans_id, uint8_t *cmd,
 		return n;
 	}
 
-	memset(cmd, 0, n);
+	memset(cmd, 0, n);  /* clear command buffer */
 
 	n = rmap_build_hdr(pkt, cmd);
 
@@ -476,8 +467,7 @@ int rdcu_sync(int (*fn)(uint16_t trans_id, uint8_t *cmd),
 
 	/* convert endianess if needed */
 #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
-	if (data_len)
-	{
+	if (data_len) {
 		int i;
 		uint32_t *tmp_buf = alloca(data_len);
 		uint32_t *p = (uint32_t *) addr;
@@ -530,7 +520,7 @@ int rdcu_sync_data(int (*fn)(uint16_t trans_id, uint8_t *cmd,
 
 	slot = trans_log_grab_slot(data);
 	if (slot < 0) {
-		if ((0))
+		if (RDCU_CONFIG_DEBUG)
 			printf("Error: all slots busy!\n");
 		return 1;
 	}
@@ -782,7 +772,7 @@ int rdcu_rmap_sync_status(void)
 
 void rdcu_rmap_reset_log(void)
 {
-	memset(trans_log.in_use, 0, TRANS_LOG_SIZE);
+	memset(trans_log.in_use, 0, sizeof(trans_log.in_use));  /* clear in_use buffer */
 	trans_log.pending = 0;
 }
 
diff --git a/lib/rmap.c b/lib/rmap.c
index f8b6eb0c4a38226bc4f5cd270332033b97e1eb6f..703add595bb907340be3399759178229afa6db89 100644
--- a/lib/rmap.c
+++ b/lib/rmap.c
@@ -178,7 +178,7 @@ struct rmap_pkt *rmap_create_packet(void)
 	struct rmap_pkt *pkt;
 
 
-	pkt = (struct rmap_pkt *) calloc(sizeof(struct rmap_pkt), 1);
+	pkt = (struct rmap_pkt *) calloc(1, sizeof(struct rmap_pkt));
 	if (pkt)
 		pkt->proto_id = RMAP_PROTOCOL_ID;
 
@@ -206,7 +206,7 @@ void rmap_destroy_packet(struct rmap_pkt *pkt)
  * @param pkt a struct rmap_pkt
  *
  * @note this will attempt to deallocate any pointer references assigned by the
- * 	 user
+ *	 user
  * @warning use with care
  */
 
@@ -563,7 +563,7 @@ struct rmap_pkt *rmap_pkt_from_buffer(uint8_t *buf, uint32_t len)
 
 	pkt->src   = buf[RMAP_SRC_ADDR + n];
 	pkt->tr_id = ((uint16_t) buf[RMAP_TRANS_ID_BYTE0 + n] << 8) |
-	              (uint16_t) buf[RMAP_TRANS_ID_BYTE1 + n];
+		      (uint16_t) buf[RMAP_TRANS_ID_BYTE1 + n];
 
 	/* commands have a data address */
 	if (pkt->ri.cmd_resp) {
@@ -576,10 +576,9 @@ struct rmap_pkt *rmap_pkt_from_buffer(uint8_t *buf, uint32_t len)
 
 	/* all headers have data length unless they are a write reply */
 	if (!(!pkt->ri.cmd_resp && (pkt->ri.cmd & (RMAP_CMD_BIT_WRITE)))) {
-
 		pkt->data_len = ((uint32_t) buf[RMAP_DATALEN_BYTE0 + n] << 16) |
 				((uint32_t) buf[RMAP_DATALEN_BYTE1 + n] <<  8) |
-			         (uint32_t) buf[RMAP_DATALEN_BYTE2 + n];
+				 (uint32_t) buf[RMAP_DATALEN_BYTE2 + n];
 	}
 
 	pkt->hdr_crc  = buf[RMAP_HEADER_CRC];
@@ -587,7 +586,7 @@ struct rmap_pkt *rmap_pkt_from_buffer(uint8_t *buf, uint32_t len)
 	if (pkt->data_len) {
 		if (len < RMAP_DATA_START + n + pkt->data_len + 1) {  /* +1 for data CRC */
 			printf("buffer len is smaller than the contained RMAP packet; buf len: %u bytes vs RMAP: %zu bytes needed\n",
-				len , RMAP_DATA_START + n + pkt->data_len);
+				len, RMAP_DATA_START + n + pkt->data_len);
 			goto error;
 		}
 		if (len > RMAP_DATA_START + n + pkt->data_len + 1)  /* +1 for data CRC */
@@ -702,7 +701,7 @@ static void rmap_process_read_reply(uint8_t *pkt)
 	for (i = 0; i < len; i++)
 		printf("%02x:", pkt[RMAP_DATA_START + i]);
 
-	printf("\b \n");
+	printf("\b\n");
 }