diff --git a/cmp_tool.c b/cmp_tool.c index a3067612e2e2024e08020c6c2f7dd4a15d6e975c..19213b8c4ad394671a07eba4ddbeea18532432b2 100644 --- a/cmp_tool.c +++ b/cmp_tool.c @@ -55,7 +55,7 @@ static int compression(struct cmp_cfg *cfg, struct cmp_info *info); static int decompression(struct cmp_entity *ent, uint16_t *input_model_buf); /* create a default configuration for a compression data type */ -static enum cfg_default_opt {DIFF_CFG, MODEL_CFG}; +enum cfg_default_opt {DIFF_CFG, MODEL_CFG}; static int cmp_cfg_create_default(struct cmp_cfg *cfg, enum cmp_data_type data_type, enum cfg_default_opt mode); diff --git a/lib/rmap.c b/lib/rmap.c index 3164a834415bb771430b130db41eb8a5cc715f97..113ad1ebdab3ac700bc57532d6dafb26a5e226a6 100644 --- a/lib/rmap.c +++ b/lib/rmap.c @@ -582,12 +582,14 @@ struct rmap_pkt *rmap_pkt_from_buffer(uint8_t *buf, uint32_t len) pkt->hdr_crc = buf[RMAP_HEADER_CRC]; 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: %" PRIu32 " bytes vs RMAP: %lu bytes needed\n", - len, RMAP_DATA_START + n + pkt->data_len); + size_t pkt_size = RMAP_DATA_START + n + pkt->data_len + 1; /* +1 for data CRC */ + + if (len < pkt_size) { + printf("buffer len is smaller than the contained RMAP packet; buf len: %" PRIu32 " bytes vs RMAP: %zu bytes needed\n", + len, pkt_size); goto error; } - if (len > RMAP_DATA_START + n + pkt->data_len + 1) /* +1 for data CRC */ + if (len > pkt_size) printf("warning: the buffer is larger than the included RMAP packet\n"); pkt->data = (uint8_t *) malloc(pkt->data_len); diff --git a/test/cmp_entity/test_cmp_entity.c b/test/cmp_entity/test_cmp_entity.c index c127a88210e56d350274a4d1721ca626d1377a9d..439222d3464c18d77ef107801d1bc1ff79d80c24 100644 --- a/test/cmp_entity/test_cmp_entity.c +++ b/test/cmp_entity/test_cmp_entity.c @@ -17,11 +17,11 @@ */ +#include <stdlib.h> #include <string.h> #if defined __has_include # if __has_include(<time.h>) # include <time.h> -# include <stdlib.h> # define HAS_TIME_H 1 # endif #endif diff --git a/test/cmp_icu/test_decmp.c b/test/cmp_icu/test_decmp.c index f620b29e27ec5f46879a20d27f6da431a3601ce3..b00c09c6e2f2c192d324d6a93eecc4d95177cce2 100644 --- a/test/cmp_icu/test_decmp.c +++ b/test/cmp_icu/test_decmp.c @@ -20,6 +20,14 @@ #include <string.h> #include <stdlib.h> +#if defined __has_include +# if __has_include(<time.h>) +# include <time.h> +# include <unistd.h> +# define HAS_TIME_H 1 +# endif +#endif + #include "unity.h" #include "compiler.h" @@ -202,7 +210,7 @@ void test_rice_decoder(void) uint32_t code_word; unsigned int m = ~0; /* we don't need this value */ unsigned int log2_m; - unsigned int decoded_cw; + uint32_t decoded_cw; /* test log_2 to big */ code_word = 0xE0000000; @@ -271,7 +279,7 @@ void test_decode_normal(void) uint32_t decoded_value = ~0; int stream_pos, sample; /* compressed data from 0 to 6; */ - uint32_t cmp_data[] = {0x5BBDF7E0}; + uint32_t cmp_data[1] = {0x5BBDF7E0}; struct decoder_setup setup = {0}; cpu_to_be32s(cmp_data); @@ -535,7 +543,7 @@ int my_random(unsigned int min, unsigned int max) void test_imagette_random(void) { - unsigned int seed = time(NULL) * getpid(); + unsigned int seed; size_t i, s, cmp_data_size; int error; struct cmp_cfg cfg; @@ -549,6 +557,11 @@ void test_imagette_random(void) uint16_t *data, *model = NULL, *up_model = NULL, *de_up_model = NULL; /* Seeds the pseudo-random number generator used by rand() */ +#if HAS_TIME_H + seed = time(NULL) * getpid(); +#else + seed = 1; +#endif srand(seed); printf("seed: %u\n", seed);