From 09f7b5cfe5b863792516f2edd11898d3ce7eb20e Mon Sep 17 00:00:00 2001 From: Dominik Loidolt <dominik.loidolt@univie.ac.at> Date: Wed, 4 Oct 2023 16:59:13 +0200 Subject: [PATCH] make non puplic static; remove unused code; add const qualifier for strings --- include/rdcu_ctrl.h | 1 + lib/cmp_io.c | 35 ----------------------- lib/cmp_max_used_bits_list.c | 2 +- lib/cmp_support.c | 4 +-- lib/decmp.c | 2 +- test/cmp_data_types/test_cmp_data_types.c | 3 +- test/cmp_decmp/test_cmp_decmp.c | 22 -------------- 7 files changed, 7 insertions(+), 62 deletions(-) diff --git a/include/rdcu_ctrl.h b/include/rdcu_ctrl.h index 4caa127..6182dbf 100644 --- a/include/rdcu_ctrl.h +++ b/include/rdcu_ctrl.h @@ -139,6 +139,7 @@ uint16_t rdcu_get_fpga_version(void); uint32_t rdcu_get_rdcu_status_board_serial_number(void); uint32_t rdcu_get_rdcu_status_fpga_core_power_good(void); +uint32_t rdcu_get_rdcu_status_core_power_good(void); uint32_t rdcu_get_rdcu_status_io_power_good(void); uint32_t rdcu_get_rdcu_status_reset_by_register(void); uint32_t rdcu_get_rdcu_status_power_on_reset(void); diff --git a/lib/cmp_io.c b/lib/cmp_io.c index 9cb0a7e..485fc4e 100644 --- a/lib/cmp_io.c +++ b/lib/cmp_io.c @@ -1495,41 +1495,6 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent, } -/** - * @brief reads hex-encoded uint32_t samples from a file into a buffer - * - * @param file_name data/model file name - * @param buf buffer to write the file content (can be NULL) - * @param buf_size size of the buf buffer in bytes - * @param verbose_en print verbose output if not zero - * - * @returns the size in bytes to store the file content; negative on error - */ - -ssize_t read_file32(const char *file_name, uint32_t *buf, uint32_t buf_size, - int verbose_en) -{ - ssize_t size = read_file8(file_name, (uint8_t *)buf, buf_size, verbose_en); - - if (size < 0) - return -1; - - if (size & 0x3) { - fprintf(stderr, "%s: %s: Error: The data are not correct formatted. Expected multiple of 4 hex words.\n", - PROGRAM_NAME, file_name); - return -1; - } - - if (buf) { - size_t i; - for (i = 0; i < buf_size/sizeof(uint32_t); i++) - be32_to_cpus(&buf[i]); - } - - return size; -} - - /* * @brief generate from the cmp_tool version string a version_id for the * compression entity header diff --git a/lib/cmp_max_used_bits_list.c b/lib/cmp_max_used_bits_list.c index b5aa3da..f302bb6 100644 --- a/lib/cmp_max_used_bits_list.c +++ b/lib/cmp_max_used_bits_list.c @@ -31,7 +31,7 @@ struct list_item { struct cmp_max_used_bits data; }; -LIST_HEAD(max_used_bits_list); +static LIST_HEAD(max_used_bits_list); /** diff --git a/lib/cmp_support.c b/lib/cmp_support.c index 90b9f81..e1dcfe5 100644 --- a/lib/cmp_support.c +++ b/lib/cmp_support.c @@ -402,7 +402,7 @@ int cmp_cfg_gen_par_is_invalid(const struct cmp_cfg *cfg, enum check_opt opt) int unsupported_cmp_mode = 1; int check_model_value = 1; uint32_t max_round_value = 0; - char *str = ""; + const char *str = ""; if (!cfg) return 1; @@ -611,7 +611,7 @@ int cmp_cfg_icu_max_used_bits_out_of_limit(const struct cmp_max_used_bits *max_u */ static int cmp_pars_are_invalid(uint32_t cmp_par, uint32_t spill, enum cmp_mode cmp_mode, - enum cmp_data_type data_type, char *par_name) + enum cmp_data_type data_type, const char *par_name) { int cfg_invalid = 0; uint32_t min_golomb_par; diff --git a/lib/decmp.c b/lib/decmp.c index f2b10d7..b3a2561 100644 --- a/lib/decmp.c +++ b/lib/decmp.c @@ -42,7 +42,7 @@ #define MAX_CW_LEN_ICU 32 /* maximum ICU Golomb code word bit length */ -const char *please_check_str = "Please check that the compression parameters match those used to compress the data and that the compressed data are not corrupted.\n"; +static const char *please_check_str = "Please check that the compression parameters match those used to compress the data and that the compressed data are not corrupted.\n"; /** diff --git a/test/cmp_data_types/test_cmp_data_types.c b/test/cmp_data_types/test_cmp_data_types.c index eefa11a..b3461dd 100644 --- a/test/cmp_data_types/test_cmp_data_types.c +++ b/test/cmp_data_types/test_cmp_data_types.c @@ -149,7 +149,8 @@ void test_cmp_input_size_to_samples(void) TEST_ASSERT_EQUAL(-1, samples_get); } -void check_endianness(void* data, size_t size, enum cmp_data_type data_type) + +static void check_endianness(void* data, size_t size, enum cmp_data_type data_type) { int error; uint8_t *p_8 = data; diff --git a/test/cmp_decmp/test_cmp_decmp.c b/test/cmp_decmp/test_cmp_decmp.c index 89a3eb8..5f06a70 100644 --- a/test/cmp_decmp/test_cmp_decmp.c +++ b/test/cmp_decmp/test_cmp_decmp.c @@ -43,8 +43,6 @@ #define IMAX_BITS(m) ((m)/((m)%255+1) / 255%255*8 + 7-86/((m)%255+12)) #define RAND_MAX_WIDTH IMAX_BITS(RAND_MAX) -#define set_n_bits(n) (n != 32 ? ~(~0UL << (n)):0xFFFFFFFF) - /** * @brief Seeds the pseudo-random number generator used by rand() @@ -69,26 +67,6 @@ void setUp(void) } -/** - * @brief generate a uint32_t random number - * - * @return a "random" uint32_t value - * @see https://stackoverflow.com/a/33021408 - */ - -uint32_t rand32(void) -{ - int i; - uint32_t r = 0; - - for (i = 0; i < 32; i += RAND_MAX_WIDTH) { - r <<= RAND_MAX_WIDTH; - r ^= (unsigned int) rand(); - } - return r; -} - - static void gen_ima_data(uint16_t *data, uint32_t samples, const struct cmp_max_used_bits *max_used_bits) { uint32_t i; -- GitLab