Skip to content
Snippets Groups Projects
Commit 26613dd5 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

Remove compiler warnings

parent eb5acd39
Branches
Tags
1 merge request!12increase code coverage, general code refactoring
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment