From ccb88d358d773ca14f3af080978a816a60ca38ee Mon Sep 17 00:00:00 2001 From: Dominik Loidolt <dominik.loidolt@univie.ac.at> Date: Tue, 7 Nov 2023 18:27:44 +0100 Subject: [PATCH] Add const qualifier when possible --- cmp_tool.c | 4 +- include/cmp_entity.h | 76 ++++++++++++++++++------------------ include/cmp_icu.h | 2 +- include/cmp_io.h | 2 +- include/cmp_support.h | 2 +- include/rdcu_ctrl.h | 8 ++-- lib/cmp_entity.c | 90 +++++++++++++++++++++---------------------- lib/cmp_io.c | 7 ++-- lib/cmp_rdcu.c | 2 +- lib/rdcu_ctrl.c | 8 ++-- 10 files changed, 101 insertions(+), 100 deletions(-) diff --git a/cmp_tool.c b/cmp_tool.c index 9d26d09..fe49055 100644 --- a/cmp_tool.c +++ b/cmp_tool.c @@ -299,7 +299,7 @@ int main(int argc, char **argv) } { - char str[] = "### PLATO Compression/Decompression Tool Version " CMP_TOOL_VERSION " ###\n"; + const char str[] = "### PLATO Compression/Decompression Tool Version " CMP_TOOL_VERSION " ###\n"; size_t str_len = strlen(str) - 1; /* -1 for \n */ size_t i; for (i = 0; i < str_len; ++i) @@ -622,7 +622,7 @@ static int guess_cmp_pars(struct cmp_cfg *cfg, const char *guess_cmp_mode, * @brief generate packets to setup an RDCU compression */ -static int gen_rdcu_write_pkts(struct cmp_cfg *cfg) +static int gen_rdcu_write_pkts(const struct cmp_cfg *cfg) { int error; diff --git a/include/cmp_entity.h b/include/cmp_entity.h index 42442f3..8efff24 100644 --- a/include/cmp_entity.h +++ b/include/cmp_entity.h @@ -157,7 +157,7 @@ uint32_t cmp_ent_create(struct cmp_entity *ent, enum cmp_data_type data_type, /* create a compression entity and set the header fields */ uint32_t cmp_ent_build(struct cmp_entity *ent, uint32_t version_id, uint64_t start_time, uint64_t end_time, uint16_t model_id, - uint8_t model_counter, struct cmp_cfg *cfg, int cmp_size_bits); + uint8_t model_counter, const struct cmp_cfg *cfg, int cmp_size_bits); /* * write the compression parameters from a compression configuration into the @@ -239,71 +239,71 @@ int cmp_ent_set_non_ima_cmp_par6(struct cmp_entity *ent, uint32_t cmp_par_6_used /* get functions for generic compression entity header */ -uint32_t cmp_ent_get_version_id(struct cmp_entity *ent); -uint32_t cmp_ent_get_size(struct cmp_entity *ent); -uint32_t cmp_ent_get_original_size(struct cmp_entity *ent); +uint32_t cmp_ent_get_version_id(const struct cmp_entity *ent); +uint32_t cmp_ent_get_size(const struct cmp_entity *ent); +uint32_t cmp_ent_get_original_size(const struct cmp_entity *ent); -uint64_t cmp_ent_get_start_timestamp(struct cmp_entity *ent); -uint32_t cmp_ent_get_coarse_start_time(struct cmp_entity *ent); -uint16_t cmp_ent_get_fine_start_time(struct cmp_entity *ent); +uint64_t cmp_ent_get_start_timestamp(const struct cmp_entity *ent); +uint32_t cmp_ent_get_coarse_start_time(const struct cmp_entity *ent); +uint16_t cmp_ent_get_fine_start_time(const struct cmp_entity *ent); -uint64_t cmp_ent_get_end_timestamp(struct cmp_entity *ent); -uint32_t cmp_ent_get_coarse_end_time(struct cmp_entity *ent); -uint16_t cmp_ent_get_fine_end_time(struct cmp_entity *ent); +uint64_t cmp_ent_get_end_timestamp(const struct cmp_entity *ent); +uint32_t cmp_ent_get_coarse_end_time(const struct cmp_entity *ent); +uint16_t cmp_ent_get_fine_end_time(const struct cmp_entity *ent); -enum cmp_data_type cmp_ent_get_data_type(struct cmp_entity *ent); -int cmp_ent_get_data_type_raw_bit(struct cmp_entity *ent); -uint8_t cmp_ent_get_cmp_mode(struct cmp_entity *ent); -uint8_t cmp_ent_get_model_value(struct cmp_entity *ent); +enum cmp_data_type cmp_ent_get_data_type(const struct cmp_entity *ent); +int cmp_ent_get_data_type_raw_bit(const struct cmp_entity *ent); +uint8_t cmp_ent_get_cmp_mode(const struct cmp_entity *ent); +uint8_t cmp_ent_get_model_value(const struct cmp_entity *ent); -uint16_t cmp_ent_get_model_id(struct cmp_entity *ent); -uint8_t cmp_ent_get_model_counter(struct cmp_entity *ent); -uint8_t cmp_ent_get_max_used_bits_version(struct cmp_entity *ent); -uint16_t cmp_ent_get_lossy_cmp_par(struct cmp_entity *ent); +uint16_t cmp_ent_get_model_id(const struct cmp_entity *ent); +uint8_t cmp_ent_get_model_counter(const struct cmp_entity *ent); +uint8_t cmp_ent_get_max_used_bits_version(const struct cmp_entity *ent); +uint16_t cmp_ent_get_lossy_cmp_par(const struct cmp_entity *ent); /* * get functions for specific entity header for imagette and adaptive imagette * data product types */ -uint16_t cmp_ent_get_ima_spill(struct cmp_entity *ent); -uint8_t cmp_ent_get_ima_golomb_par(struct cmp_entity *ent); +uint16_t cmp_ent_get_ima_spill(const struct cmp_entity *ent); +uint8_t cmp_ent_get_ima_golomb_par(const struct cmp_entity *ent); /* * get functions for specific entity header for adaptive imagette data product * types */ -uint16_t cmp_ent_get_ima_ap1_spill(struct cmp_entity *ent); -uint8_t cmp_ent_get_ima_ap1_golomb_par(struct cmp_entity *ent); +uint16_t cmp_ent_get_ima_ap1_spill(const struct cmp_entity *ent); +uint8_t cmp_ent_get_ima_ap1_golomb_par(const struct cmp_entity *ent); -uint16_t cmp_ent_get_ima_ap2_spill(struct cmp_entity *ent); -uint8_t cmp_ent_get_ima_ap2_golomb_par(struct cmp_entity *ent); +uint16_t cmp_ent_get_ima_ap2_spill(const struct cmp_entity *ent); +uint8_t cmp_ent_get_ima_ap2_golomb_par(const struct cmp_entity *ent); /* get functions for specific entity header for non-imagette data product types */ -uint32_t cmp_ent_get_non_ima_spill1(struct cmp_entity *ent); -uint16_t cmp_ent_get_non_ima_cmp_par1(struct cmp_entity *ent); +uint32_t cmp_ent_get_non_ima_spill1(const struct cmp_entity *ent); +uint16_t cmp_ent_get_non_ima_cmp_par1(const struct cmp_entity *ent); -uint32_t cmp_ent_get_non_ima_spill2(struct cmp_entity *ent); -uint16_t cmp_ent_get_non_ima_cmp_par2(struct cmp_entity *ent); +uint32_t cmp_ent_get_non_ima_spill2(const struct cmp_entity *ent); +uint16_t cmp_ent_get_non_ima_cmp_par2(const struct cmp_entity *ent); -uint32_t cmp_ent_get_non_ima_spill3(struct cmp_entity *ent); -uint16_t cmp_ent_get_non_ima_cmp_par3(struct cmp_entity *ent); +uint32_t cmp_ent_get_non_ima_spill3(const struct cmp_entity *ent); +uint16_t cmp_ent_get_non_ima_cmp_par3(const struct cmp_entity *ent); -uint32_t cmp_ent_get_non_ima_spill4(struct cmp_entity *ent); -uint16_t cmp_ent_get_non_ima_cmp_par4(struct cmp_entity *ent); +uint32_t cmp_ent_get_non_ima_spill4(const struct cmp_entity *ent); +uint16_t cmp_ent_get_non_ima_cmp_par4(const struct cmp_entity *ent); -uint32_t cmp_ent_get_non_ima_spill5(struct cmp_entity *ent); -uint16_t cmp_ent_get_non_ima_cmp_par5(struct cmp_entity *ent); +uint32_t cmp_ent_get_non_ima_spill5(const struct cmp_entity *ent); +uint16_t cmp_ent_get_non_ima_cmp_par5(const struct cmp_entity *ent); -uint32_t cmp_ent_get_non_ima_spill6(struct cmp_entity *ent); -uint16_t cmp_ent_get_non_ima_cmp_par6(struct cmp_entity *ent); +uint32_t cmp_ent_get_non_ima_spill6(const struct cmp_entity *ent); +uint16_t cmp_ent_get_non_ima_cmp_par6(const struct cmp_entity *ent); /* get function for the compressed data buffer in the entity */ void *cmp_ent_get_data_buf(struct cmp_entity *ent); -uint32_t cmp_ent_get_cmp_data_size(struct cmp_entity *ent); +uint32_t cmp_ent_get_cmp_data_size(const struct cmp_entity *ent); int32_t cmp_ent_get_cmp_data(struct cmp_entity *ent, uint32_t *data_buf, uint32_t data_buf_size); @@ -321,7 +321,7 @@ uint64_t cmp_ent_create_timestamp(const struct timespec *ts); #endif /* print and parse functions */ -void cmp_ent_print_header(struct cmp_entity *ent); +void cmp_ent_print_header(const struct cmp_entity *ent); void cmp_ent_print_data(struct cmp_entity *ent); void cmp_ent_print(struct cmp_entity *ent); diff --git a/include/cmp_icu.h b/include/cmp_icu.h index f536bec..9fc0f42 100644 --- a/include/cmp_icu.h +++ b/include/cmp_icu.h @@ -54,7 +54,7 @@ int cmp_cfg_aux(struct cmp_cfg *cfg, uint32_t cmp_par_pixels_error, uint32_t spillover_pixels_error); /* set up the max_used_bits used for the compression */ -int cmp_cfg_icu_max_used_bits(struct cmp_cfg *cfg, const struct cmp_max_used_bits *max_used_bits_repo); +int cmp_cfg_icu_max_used_bits(struct cmp_cfg *cfg, const struct cmp_max_used_bits *max_used_bits); /* start the compression */ int icu_compress_data(const struct cmp_cfg *cfg); diff --git a/include/cmp_io.h b/include/cmp_io.h index c5aa5b8..60c3910 100644 --- a/include/cmp_io.h +++ b/include/cmp_io.h @@ -52,7 +52,7 @@ uint32_t cmp_tool_gen_version_id(const char *version); int write_data_to_file(const void *buf, uint32_t buf_size, const char *output_prefix, const char *name_extension, int flags); -int write_input_data_to_file(void *data, uint32_t data_size, enum cmp_data_type data_type, +int write_input_data_to_file(const void *data, uint32_t data_size, enum cmp_data_type data_type, const char *output_prefix, const char *name_extension, int flags); int cmp_info_to_file(const struct cmp_info *info, const char *output_prefix, int rdcu_cfg); int cmp_cfg_fo_file(const struct cmp_cfg *cfg, const char *output_prefix, int verbose); diff --git a/include/cmp_support.h b/include/cmp_support.h index 254c980..3212703 100644 --- a/include/cmp_support.h +++ b/include/cmp_support.h @@ -274,7 +274,7 @@ unsigned int cmp_bit_to_4byte(unsigned int cmp_size_bit); int cmp_cfg_icu_is_invalid(const struct cmp_cfg *cfg); int cmp_cfg_gen_par_is_invalid(const struct cmp_cfg *cfg, enum check_opt opt); int cmp_cfg_icu_buffers_is_invalid(const struct cmp_cfg *cfg); -int cmp_cfg_icu_max_used_bits_out_of_limit(const struct cmp_max_used_bits *max_used_bits_repo); +int cmp_cfg_icu_max_used_bits_out_of_limit(const struct cmp_max_used_bits *max_used_bits); int cmp_cfg_imagette_is_invalid(const struct cmp_cfg *cfg, enum check_opt opt); int cmp_cfg_fx_cob_is_invalid(const struct cmp_cfg *cfg); int cmp_cfg_aux_is_invalid(const struct cmp_cfg *cfg); diff --git a/include/rdcu_ctrl.h b/include/rdcu_ctrl.h index 1274250..b3cfa66 100644 --- a/include/rdcu_ctrl.h +++ b/include/rdcu_ctrl.h @@ -282,10 +282,10 @@ uint8_t rdcu_edac_get_scrub_info(void); /* SRAM */ int rdcu_read_sram(void *buf, uint32_t addr, uint32_t size); -int rdcu_write_sram(void *buf, uint32_t addr, uint32_t size); -int rdcu_write_sram_8(uint8_t *buf, uint32_t addr, uint32_t size); -int rdcu_write_sram_16(uint16_t *buf, uint32_t addr, uint32_t size); -int rdcu_write_sram_32(uint32_t *buf, uint32_t addr, uint32_t size); +int rdcu_write_sram(const void *buf, uint32_t addr, uint32_t size); +int rdcu_write_sram_8(const uint8_t *buf, uint32_t addr, uint32_t size); +int rdcu_write_sram_16(const uint16_t *buf, uint32_t addr, uint32_t size); +int rdcu_write_sram_32(const uint32_t *buf, uint32_t addr, uint32_t size); int rdcu_ctrl_init(void); diff --git a/lib/cmp_entity.c b/lib/cmp_entity.c index 4ca1180..a443b23 100644 --- a/lib/cmp_entity.c +++ b/lib/cmp_entity.c @@ -962,7 +962,7 @@ int cmp_ent_set_non_ima_cmp_par6(struct cmp_entity *ent, uint32_t cmp_par_6_used * @returns the ASW version identifier on success, 0 on error */ -uint32_t cmp_ent_get_version_id(struct cmp_entity *ent) +uint32_t cmp_ent_get_version_id(const struct cmp_entity *ent) { if (!ent) return 0; @@ -979,7 +979,7 @@ uint32_t cmp_ent_get_version_id(struct cmp_entity *ent) * @returns the size of the compression entity in bytes on success, 0 on error */ -uint32_t cmp_ent_get_size(struct cmp_entity *ent) +uint32_t cmp_ent_get_size(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1000,7 +1000,7 @@ uint32_t cmp_ent_get_size(struct cmp_entity *ent) * @returns the original size of the compressed data in bytes on success, 0 on error */ -uint32_t cmp_ent_get_original_size(struct cmp_entity *ent) +uint32_t cmp_ent_get_original_size(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1021,7 +1021,7 @@ uint32_t cmp_ent_get_original_size(struct cmp_entity *ent) * @returns the compression start timestamp on success, 0 on error */ -uint64_t cmp_ent_get_start_timestamp(struct cmp_entity *ent) +uint64_t cmp_ent_get_start_timestamp(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1042,7 +1042,7 @@ uint64_t cmp_ent_get_start_timestamp(struct cmp_entity *ent) * error */ -uint32_t cmp_ent_get_coarse_start_time(struct cmp_entity *ent) +uint32_t cmp_ent_get_coarse_start_time(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1059,7 +1059,7 @@ uint32_t cmp_ent_get_coarse_start_time(struct cmp_entity *ent) * error */ -uint16_t cmp_ent_get_fine_start_time(struct cmp_entity *ent) +uint16_t cmp_ent_get_fine_start_time(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1076,7 +1076,7 @@ uint16_t cmp_ent_get_fine_start_time(struct cmp_entity *ent) * @returns the compression end timestamp on success, 0 on error */ -uint64_t cmp_ent_get_end_timestamp(struct cmp_entity *ent) +uint64_t cmp_ent_get_end_timestamp(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1097,7 +1097,7 @@ uint64_t cmp_ent_get_end_timestamp(struct cmp_entity *ent) * error */ -uint32_t cmp_ent_get_coarse_end_time(struct cmp_entity *ent) +uint32_t cmp_ent_get_coarse_end_time(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1114,7 +1114,7 @@ uint32_t cmp_ent_get_coarse_end_time(struct cmp_entity *ent) * error */ -uint16_t cmp_ent_get_fine_end_time(struct cmp_entity *ent) +uint16_t cmp_ent_get_fine_end_time(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1132,7 +1132,7 @@ uint16_t cmp_ent_get_fine_end_time(struct cmp_entity *ent) * DATA_TYPE_UNKNOWN on error */ -enum cmp_data_type cmp_ent_get_data_type(struct cmp_entity *ent) +enum cmp_data_type cmp_ent_get_data_type(const struct cmp_entity *ent) { enum cmp_data_type data_type; @@ -1157,7 +1157,7 @@ enum cmp_data_type cmp_ent_get_data_type(struct cmp_entity *ent) * @returns the data_type raw bit on success, 0 on error */ -int cmp_ent_get_data_type_raw_bit(struct cmp_entity *ent) +int cmp_ent_get_data_type_raw_bit(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1174,7 +1174,7 @@ int cmp_ent_get_data_type_raw_bit(struct cmp_entity *ent) * @returns the used compression mode on success, 0 on error */ -uint8_t cmp_ent_get_cmp_mode(struct cmp_entity *ent) +uint8_t cmp_ent_get_cmp_mode(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1191,7 +1191,7 @@ uint8_t cmp_ent_get_cmp_mode(struct cmp_entity *ent) * @returns the used model value used on success, 0 on error */ -uint8_t cmp_ent_get_model_value(struct cmp_entity *ent) +uint8_t cmp_ent_get_model_value(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1209,7 +1209,7 @@ uint8_t cmp_ent_get_model_value(struct cmp_entity *ent) * @returns the model identifier on success, 0 on error */ -uint16_t cmp_ent_get_model_id(struct cmp_entity *ent) +uint16_t cmp_ent_get_model_id(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1226,7 +1226,7 @@ uint16_t cmp_ent_get_model_id(struct cmp_entity *ent) * @returns the model counter on success, 0 on error */ -uint8_t cmp_ent_get_model_counter(struct cmp_entity *ent) +uint8_t cmp_ent_get_model_counter(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1245,7 +1245,7 @@ uint8_t cmp_ent_get_model_counter(struct cmp_entity *ent) * 0 on error */ -uint8_t cmp_ent_get_max_used_bits_version(struct cmp_entity *ent) +uint8_t cmp_ent_get_max_used_bits_version(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1262,7 +1262,7 @@ uint8_t cmp_ent_get_max_used_bits_version(struct cmp_entity *ent) * @returns the used lossy compression/round parameter on success, 0 on error */ -uint16_t cmp_ent_get_lossy_cmp_par(struct cmp_entity *ent) +uint16_t cmp_ent_get_lossy_cmp_par(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1280,7 +1280,7 @@ uint16_t cmp_ent_get_lossy_cmp_par(struct cmp_entity *ent) * @returns the used spillover threshold on success, 0 on error */ -uint16_t cmp_ent_get_ima_spill(struct cmp_entity *ent) +uint16_t cmp_ent_get_ima_spill(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1298,7 +1298,7 @@ uint16_t cmp_ent_get_ima_spill(struct cmp_entity *ent) * @returns the used Golomb parameter on success, 0 on error */ -uint8_t cmp_ent_get_ima_golomb_par(struct cmp_entity *ent) +uint8_t cmp_ent_get_ima_golomb_par(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1316,7 +1316,7 @@ uint8_t cmp_ent_get_ima_golomb_par(struct cmp_entity *ent) * @returns the used adaptive 1 spillover threshold on success, 0 on error */ -uint16_t cmp_ent_get_ima_ap1_spill(struct cmp_entity *ent) +uint16_t cmp_ent_get_ima_ap1_spill(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1334,7 +1334,7 @@ uint16_t cmp_ent_get_ima_ap1_spill(struct cmp_entity *ent) * @returns the used adaptive 1 Golomb parameter on success, 0 on error */ -uint8_t cmp_ent_get_ima_ap1_golomb_par(struct cmp_entity *ent) +uint8_t cmp_ent_get_ima_ap1_golomb_par(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1352,7 +1352,7 @@ uint8_t cmp_ent_get_ima_ap1_golomb_par(struct cmp_entity *ent) * @returns the used adaptive 2 spillover threshold on success, 0 on error */ -uint16_t cmp_ent_get_ima_ap2_spill(struct cmp_entity *ent) +uint16_t cmp_ent_get_ima_ap2_spill(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1370,7 +1370,7 @@ uint16_t cmp_ent_get_ima_ap2_spill(struct cmp_entity *ent) * @returns the used adaptive 2 Golomb parameter on success, 0 on error */ -uint8_t cmp_ent_get_ima_ap2_golomb_par(struct cmp_entity *ent) +uint8_t cmp_ent_get_ima_ap2_golomb_par(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1388,7 +1388,7 @@ uint8_t cmp_ent_get_ima_ap2_golomb_par(struct cmp_entity *ent) * @returns the used spillover threshold 1 parameter on success, 0 on error */ -uint32_t cmp_ent_get_non_ima_spill1(struct cmp_entity *ent) +uint32_t cmp_ent_get_non_ima_spill1(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1410,7 +1410,7 @@ uint32_t cmp_ent_get_non_ima_spill1(struct cmp_entity *ent) * @returns the used compression parameter 1 on success, 0 on error */ -uint16_t cmp_ent_get_non_ima_cmp_par1(struct cmp_entity *ent) +uint16_t cmp_ent_get_non_ima_cmp_par1(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1428,7 +1428,7 @@ uint16_t cmp_ent_get_non_ima_cmp_par1(struct cmp_entity *ent) * @returns the used spillover threshold 2 parameter on success, 0 on error */ -uint32_t cmp_ent_get_non_ima_spill2(struct cmp_entity *ent) +uint32_t cmp_ent_get_non_ima_spill2(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1450,7 +1450,7 @@ uint32_t cmp_ent_get_non_ima_spill2(struct cmp_entity *ent) * @returns the used compression parameter 2 on success, 0 on error */ -uint16_t cmp_ent_get_non_ima_cmp_par2(struct cmp_entity *ent) +uint16_t cmp_ent_get_non_ima_cmp_par2(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1468,7 +1468,7 @@ uint16_t cmp_ent_get_non_ima_cmp_par2(struct cmp_entity *ent) * @returns the used spillover threshold 3 parameter on success, 0 on error */ -uint32_t cmp_ent_get_non_ima_spill3(struct cmp_entity *ent) +uint32_t cmp_ent_get_non_ima_spill3(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1490,7 +1490,7 @@ uint32_t cmp_ent_get_non_ima_spill3(struct cmp_entity *ent) * @returns the used compression parameter 3 on success, 0 on error */ -uint16_t cmp_ent_get_non_ima_cmp_par3(struct cmp_entity *ent) +uint16_t cmp_ent_get_non_ima_cmp_par3(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1508,7 +1508,7 @@ uint16_t cmp_ent_get_non_ima_cmp_par3(struct cmp_entity *ent) * @returns the used spillover threshold 4 parameter on success, 0 on error */ -uint32_t cmp_ent_get_non_ima_spill4(struct cmp_entity *ent) +uint32_t cmp_ent_get_non_ima_spill4(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1530,7 +1530,7 @@ uint32_t cmp_ent_get_non_ima_spill4(struct cmp_entity *ent) * @returns the used compression parameter 4 on success, 0 on error */ -uint16_t cmp_ent_get_non_ima_cmp_par4(struct cmp_entity *ent) +uint16_t cmp_ent_get_non_ima_cmp_par4(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1548,7 +1548,7 @@ uint16_t cmp_ent_get_non_ima_cmp_par4(struct cmp_entity *ent) * @returns the used spillover threshold 5 parameter on success, 0 on error */ -uint32_t cmp_ent_get_non_ima_spill5(struct cmp_entity *ent) +uint32_t cmp_ent_get_non_ima_spill5(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1570,7 +1570,7 @@ uint32_t cmp_ent_get_non_ima_spill5(struct cmp_entity *ent) * @returns the used compression parameter 5 on success, 0 on error */ -uint16_t cmp_ent_get_non_ima_cmp_par5(struct cmp_entity *ent) +uint16_t cmp_ent_get_non_ima_cmp_par5(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1588,7 +1588,7 @@ uint16_t cmp_ent_get_non_ima_cmp_par5(struct cmp_entity *ent) * @returns the used spillover threshold 6 parameter on success, 0 on error */ -uint32_t cmp_ent_get_non_ima_spill6(struct cmp_entity *ent) +uint32_t cmp_ent_get_non_ima_spill6(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1610,7 +1610,7 @@ uint32_t cmp_ent_get_non_ima_spill6(struct cmp_entity *ent) * @returns the used compression parameter 6 on success, 0 on error */ -uint16_t cmp_ent_get_non_ima_cmp_par6(struct cmp_entity *ent) +uint16_t cmp_ent_get_non_ima_cmp_par6(const struct cmp_entity *ent) { if (!ent) return 0; @@ -1747,7 +1747,7 @@ int32_t cmp_ent_get_cmp_data(struct cmp_entity *ent, uint32_t *data_buf, * @returns the size of the entity header in bytes on success, 0 on error */ -static uint32_t cmp_ent_get_hdr_size(struct cmp_entity *ent) +static uint32_t cmp_ent_get_hdr_size(const struct cmp_entity *ent) { return cmp_ent_cal_hdr_size(cmp_ent_get_data_type(ent), cmp_ent_get_data_type_raw_bit(ent)); @@ -1763,7 +1763,7 @@ static uint32_t cmp_ent_get_hdr_size(struct cmp_entity *ent) * @returns the size of the compressed data in bytes on success, 0 on error */ -uint32_t cmp_ent_get_cmp_data_size(struct cmp_entity *ent) +uint32_t cmp_ent_get_cmp_data_size(const struct cmp_entity *ent) { uint32_t cmp_ent_size, header_size; @@ -2102,7 +2102,7 @@ uint32_t cmp_ent_create(struct cmp_entity *ent, enum cmp_data_type data_type, uint32_t cmp_ent_build(struct cmp_entity *ent, uint32_t version_id, uint64_t start_time, uint64_t end_time, uint16_t model_id, - uint8_t model_counter, struct cmp_cfg *cfg, int cmp_size_bits) + uint8_t model_counter, const struct cmp_cfg *cfg, int cmp_size_bits) { uint32_t cmp_size_bytes = cmp_bit_to_4byte((unsigned int)cmp_size_bits); /* TODO: do we need to round up to 4 bytes? */ uint32_t hdr_size; @@ -2231,9 +2231,9 @@ uint64_t cmp_ent_create_timestamp(const struct timespec *ts) * @param ent pointer to a compression entity */ -void cmp_ent_print_header(struct cmp_entity *ent) +void cmp_ent_print_header(const struct cmp_entity *ent) { - uint8_t *p = (uint8_t *)ent; + const uint8_t *p = (const uint8_t *)ent; uint32_t hdr_size = cmp_ent_get_hdr_size(ent); size_t i; @@ -2254,7 +2254,7 @@ void cmp_ent_print_header(struct cmp_entity *ent) void cmp_ent_print_data(struct cmp_entity *ent) { - uint8_t *p = cmp_ent_get_data_buf(ent); + const uint8_t *p = cmp_ent_get_data_buf(ent); size_t data_size = cmp_ent_get_cmp_data_size(ent); size_t i; @@ -2291,7 +2291,7 @@ void cmp_ent_print(struct cmp_entity *ent) * @param ent pointer to a compression entity */ -static void cmp_ent_parse_generic_header(struct cmp_entity *ent) +static void cmp_ent_parse_generic_header(const struct cmp_entity *ent) { uint32_t version_id, cmp_ent_size, original_size, cmp_mode_used, model_value_used, model_id, model_counter, max_used_bits_version, @@ -2370,7 +2370,7 @@ static void cmp_ent_parse_generic_header(struct cmp_entity *ent) * @param ent pointer to a compression entity */ -static void cmp_ent_parese_imagette_header(struct cmp_entity *ent) +static void cmp_ent_parese_imagette_header(const struct cmp_entity *ent) { uint32_t spill_used, golomb_par_used; @@ -2388,7 +2388,7 @@ static void cmp_ent_parese_imagette_header(struct cmp_entity *ent) * @param ent pointer to a compression entity */ -static void cmp_ent_parese_adaptive_imagette_header(struct cmp_entity *ent) +static void cmp_ent_parese_adaptive_imagette_header(const struct cmp_entity *ent) { uint32_t spill_used, golomb_par_used, ap1_spill_used, ap1_golomb_par_used, ap2_spill_used, ap2_golomb_par_used; @@ -2419,7 +2419,7 @@ static void cmp_ent_parese_adaptive_imagette_header(struct cmp_entity *ent) * @param ent pointer to a compression entity */ -static void cmp_ent_parese_specific_header(struct cmp_entity *ent) +static void cmp_ent_parese_specific_header(const struct cmp_entity *ent) { enum cmp_data_type data_type = cmp_ent_get_data_type(ent); diff --git a/lib/cmp_io.c b/lib/cmp_io.c index 5e6f914..4fadaa6 100644 --- a/lib/cmp_io.c +++ b/lib/cmp_io.c @@ -165,7 +165,7 @@ static FILE *open_file(const char *dirname, const char *filename) * @returns 0 on success, error otherwise */ -int write_input_data_to_file(void *data, uint32_t data_size, enum cmp_data_type data_type, +int write_input_data_to_file(const void *data, uint32_t data_size, enum cmp_data_type data_type, const char *output_prefix, const char *name_extension, int flags) { size_t sample_size = size_of_a_sample(data_type); @@ -474,7 +474,6 @@ const char *data_type2string(enum cmp_data_type data_type) int cmp_mode_parse(const char *cmp_mode_str, enum cmp_mode *cmp_mode) { - size_t j; static const struct { uint32_t cmp_mode; const char *str; @@ -497,6 +496,8 @@ int cmp_mode_parse(const char *cmp_mode_str, enum cmp_mode *cmp_mode) return -1; if (isalpha(cmp_mode_str[0])) { /* check if mode is given as text */ + size_t j; + for (j = 0; j < ARRAY_SIZE(conversion); j++) { if (!strcmp(cmp_mode_str, conversion[j].str)) { *cmp_mode = conversion[j].cmp_mode; @@ -1577,7 +1578,7 @@ static void write_cfg_internal(FILE *fp, const struct cmp_cfg *cfg) fprintf(fp, "# 3: model mode with multi escape symbol mechanism\n"); fprintf(fp, "# 4: 1d differencing mode without input model multi escape symbol mechanism\n"); fprintf(fp, "\n"); - fprintf(fp, "cmp_mode = %u\n", cfg->cmp_mode); + fprintf(fp, "cmp_mode = %d\n", cfg->cmp_mode); fprintf(fp, "\n"); fprintf(fp, "#-------------------------------------------------------------------------------\n"); fprintf(fp, "# Number of samples to compress, length of the data and model buffer\n"); diff --git a/lib/cmp_rdcu.c b/lib/cmp_rdcu.c index adb0921..2b99391 100644 --- a/lib/cmp_rdcu.c +++ b/lib/cmp_rdcu.c @@ -501,7 +501,7 @@ void rdcu_disable_interrput_signal(void) * @param addr SRAM address to inject edac error */ -int rdcu_inject_edac_error(struct cmp_cfg *cfg, uint32_t addr) +int rdcu_inject_edac_error(const struct cmp_cfg *cfg, uint32_t addr) { uint32_t sub_chip_die_addr; uint8_t buf[4] = {0}; diff --git a/lib/rdcu_ctrl.c b/lib/rdcu_ctrl.c index 77c7a53..722fcd4 100644 --- a/lib/rdcu_ctrl.c +++ b/lib/rdcu_ctrl.c @@ -1585,7 +1585,7 @@ int rdcu_read_sram(void *buf, uint32_t addr, uint32_t size) * @returns the number of bytes written, < 0 on error */ -int rdcu_write_sram(void *buf, uint32_t addr, uint32_t size) +int rdcu_write_sram(const void *buf, uint32_t addr, uint32_t size) { if (!buf) return 0; @@ -1618,7 +1618,7 @@ int rdcu_write_sram(void *buf, uint32_t addr, uint32_t size) * @returns the number of bytes written, < 0 on error */ -int rdcu_write_sram_8(uint8_t *buf, uint32_t addr, uint32_t size) +int rdcu_write_sram_8(const uint8_t *buf, uint32_t addr, uint32_t size) { return rdcu_write_sram(buf, addr, size); } @@ -1636,7 +1636,7 @@ int rdcu_write_sram_8(uint8_t *buf, uint32_t addr, uint32_t size) * @returns the number of bytes written, < 0 on error */ -int rdcu_write_sram_16(uint16_t *buf, uint32_t addr, uint32_t size) +int rdcu_write_sram_16(const uint16_t *buf, uint32_t addr, uint32_t size) { if (!buf) return 0; @@ -1680,7 +1680,7 @@ int rdcu_write_sram_16(uint16_t *buf, uint32_t addr, uint32_t size) * @returns the number of bytes written, < 0 on error */ -int rdcu_write_sram_32(uint32_t *buf, uint32_t addr, uint32_t size) +int rdcu_write_sram_32(const uint32_t *buf, uint32_t addr, uint32_t size) { if (!buf) return 0; -- GitLab