From d2be679c41dc07f6ff3fc6e7bb3e203d3d607c4b Mon Sep 17 00:00:00 2001 From: Dominik Loidolt <dominik.loidolt@univie.ac.at> Date: Mon, 11 Nov 2024 17:12:49 +0100 Subject: [PATCH] Improve code quality and fix issues with the SPARC compiler setup --- lib/icu_compress/cmp_icu.c | 4 +++- test/cmp_decmp/test_cmp_decmp.c | 13 ++++++++----- test/cmp_entity/test_cmp_entity.c | 11 +++++++---- test/cmp_icu/test_cmp_icu.c | 15 ++++++++++----- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/icu_compress/cmp_icu.c b/lib/icu_compress/cmp_icu.c index 6c8830a..f350213 100644 --- a/lib/icu_compress/cmp_icu.c +++ b/lib/icu_compress/cmp_icu.c @@ -2280,9 +2280,11 @@ uint32_t compress_chunk_set_model_id_and_counter(void *dst, uint32_t dst_size, uint32_t compress_like_rdcu(const struct rdcu_cfg *rcfg, struct cmp_info *info) { - struct cmp_cfg cfg = {0}; + struct cmp_cfg cfg; uint32_t cmp_size_bit; + memset(&cfg, 0, sizeof(cfg)); + if (info) memset(info, 0, sizeof(*info)); diff --git a/test/cmp_decmp/test_cmp_decmp.c b/test/cmp_decmp/test_cmp_decmp.c index c4ce8d9..53e1a00 100644 --- a/test/cmp_decmp/test_cmp_decmp.c +++ b/test/cmp_decmp/test_cmp_decmp.c @@ -23,6 +23,7 @@ #include <string.h> #include <stdlib.h> #include <stdio.h> +#include <math.h> #include <unity.h> #include "../test_common/test_common.h" @@ -40,11 +41,13 @@ #include <cmp_max_used_bits.h> #include <cmp_cal_up_model.h> -#if defined __has_include -# if __has_include(<time.h>) -# include <time.h> -# include <unistd.h> -# define HAS_TIME_H 1 +#ifndef ICU_ASW +# if defined __has_include +# if __has_include(<time.h>) && !defined(__sparc__) +# include <time.h> +# include <unistd.h> +# define HAS_TIME_H 1 +# endif # endif #endif diff --git a/test/cmp_entity/test_cmp_entity.c b/test/cmp_entity/test_cmp_entity.c index 2fd053c..d7dc03a 100644 --- a/test/cmp_entity/test_cmp_entity.c +++ b/test/cmp_entity/test_cmp_entity.c @@ -19,10 +19,13 @@ #include <stdlib.h> #include <string.h> -#if defined __has_include -# if __has_include(<time.h>) -# include <time.h> -# define HAS_TIME_H 1 + +#ifndef ICU_ASW +# if defined __has_include +# if __has_include(<time.h>) +# include <time.h> +# define HAS_TIME_H 1 +# endif # endif #endif diff --git a/test/cmp_icu/test_cmp_icu.c b/test/cmp_icu/test_cmp_icu.c index 4152406..7b8b5c9 100644 --- a/test/cmp_icu/test_cmp_icu.c +++ b/test/cmp_icu/test_cmp_icu.c @@ -20,11 +20,13 @@ #include <stdlib.h> #include <leon_inttypes.h> -#if defined __has_include -# if __has_include(<time.h>) -# include <time.h> -# include <unistd.h> -# define HAS_TIME_H 1 +#ifndef ICU_ASW +# if defined __has_include +# if __has_include(<time.h>) +# include <time.h> +# include <unistd.h> +# define HAS_TIME_H 1 +# endif # endif #endif @@ -2429,6 +2431,7 @@ void test_compress_chunk_cmp_size_bound(void) TEST_ASSERT_TRUE(cmp_is_error(bound)); TEST_ASSERT_EQUAL_INT(CMP_ERROR_CHUNK_SIZE_INCONSISTENT, cmp_get_error_code(bound)); +#ifndef __sparc__ { /* containing only zero data size collections */ size_t i; uint8_t *chunk_big; @@ -2436,6 +2439,7 @@ void test_compress_chunk_cmp_size_bound(void) - NON_IMAGETTE_HEADER_SIZE - CMP_COLLECTION_FILD_SIZE; chunk_big = malloc(max_chunk_size); + TEST_ASSERT_NOT_NULL(chunk_big); for (i = 0; i < max_chunk_size-COLLECTION_HDR_SIZE; i = i+COLLECTION_HDR_SIZE) TEST_ASSERT_FALSE(cmp_col_set_data_length((struct collection_hdr *)&chunk_big[i], 0)); @@ -2443,6 +2447,7 @@ void test_compress_chunk_cmp_size_bound(void) TEST_ASSERT_EQUAL_INT(CMP_ERROR_CHUNK_TOO_LARGE, cmp_get_error_code(bound)); free(chunk_big); } +#endif } -- GitLab