Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisRosenhauer committed Oct 28, 2023
1 parent be7cc28 commit 62b9baf
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_C_FLAGS={{ matrix.c_compiler == 'gcc' && '-Wall -Werror' || '' }}
-S ${{ github.workspace }}
- name: Build
Expand Down
9 changes: 6 additions & 3 deletions include/libaec.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@
extern "C"{
#endif

#if BUILDING_LIBAEC && HAVE_VISIBILITY
# define LIBAEC_DLL_EXPORTED __attribute__((__visibility__("default")))
#else
#ifdef BUILDING_LIBAEC
# if HAVE_VISIBILITY
# define LIBAEC_DLL_EXPORTED __attribute__((visibility("default")))
# endif
#endif
#ifndef LIBAEC_DLL_EXPORTED
# define LIBAEC_DLL_EXPORTED
#endif

Expand Down
3 changes: 1 addition & 2 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ static uint32_t assess_splitting_option(struct aec_stream *strm)
struct internal_state *state = strm->state;

/* Block size of current block */
int this_bs = strm->block_size - state->ref;
uint64_t this_bs = strm->block_size - state->ref;

/* CDS length minimum so far */
uint64_t len_min = UINT64_MAX;
Expand Down Expand Up @@ -890,7 +890,6 @@ int aec_encode_init(struct aec_stream *strm)
*state->cds = 0;
state->bits = 8;
state->mode = m_get_block;
struct vector_t *offsets = NULL;
state->ready_to_capture_rsi = 0;
return AEC_OK;
}
Expand Down
4 changes: 2 additions & 2 deletions src/sz_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static int bits_to_bytes(int bit_length)
}

static void interleave_buffer(void *dest, const void *src,
size_t n, int wordsize)
size_t n, size_t wordsize)
{
const unsigned char *src8 = (unsigned char *)src;
unsigned char *dest8 = (unsigned char *)dest;
Expand All @@ -82,7 +82,7 @@ static void interleave_buffer(void *dest, const void *src,
}

static void deinterleave_buffer(void *dest, const void *src,
size_t n, int wordsize)
size_t n, size_t wordsize)
{
const unsigned char *src8 = (unsigned char *)src;
unsigned char *dest8 = (unsigned char *)dest;
Expand Down
32 changes: 3 additions & 29 deletions tests/check_rsi_block_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,6 @@ static void data_generator_incr(struct aec_context *ctx)
}
}

static void ctx_init(struct aec_context *ctx)
{
ctx->nvalues = 0;
ctx->flags = 0;
ctx->rsi = 0;
ctx->block_size = 0;
ctx->bits_per_sample = 0;
ctx->obuf = NULL;
ctx->ebuf = NULL;
ctx->dbuf = NULL;
ctx->obuf_len = 0;
ctx->ebuf_len = 0;
ctx->dbuf_len = 0;
ctx->ebuf_total = 0;
}

#define PREPARE_ENCODE(strm_e, ctx, flags) \
{ \
(strm_e)->flags = flags; \
Expand Down Expand Up @@ -239,7 +223,6 @@ static int test_rsi_at(struct aec_context *ctx)
{
int status = AEC_OK;
int flags = ctx->flags;
unsigned short *obuf = (unsigned short*) ctx->obuf;

struct aec_stream strm_encode;
PREPARE_ENCODE(&strm_encode, ctx, flags);
Expand All @@ -256,7 +239,7 @@ static int test_rsi_at(struct aec_context *ctx)
exit(1);
}

for (int i = 0; i < offsets_count; ++i) {
for (size_t i = 0; i < offsets_count; ++i) {
struct aec_stream strm_at;
strm_at.flags = flags;
strm_at.rsi = ctx->rsi;
Expand All @@ -270,8 +253,8 @@ static int test_rsi_at(struct aec_context *ctx)
if ((status = aec_rsi_at(&strm_at, offsets, offsets_count, i)) != AEC_OK) {
return status;
}
for (int j = 0; j < strm_at.total_out; j++) {
if (j == ctx->rsi * ctx->block_size * ctx->bytes_per_sample + j > ctx->obuf_len) {
for (size_t j = 0; j < strm_at.total_out; j++) {
if (j == (ctx->rsi * ctx->block_size * ctx->bytes_per_sample + j > ctx->obuf_len)) {
break;
}
if (rsi_buf[j] != ctx->obuf[i * ctx->block_size * ctx->rsi * ctx->bytes_per_sample + j]) {
Expand All @@ -297,11 +280,6 @@ int test_read(struct aec_context *ctx)
size_t *offsets = NULL;
size_t offsets_size = 0;
PREPARE_DECODE_WITH_OFFSETS(&strm_decode, ctx, flags, offsets, &offsets_size);

size_t rsi_len = ctx->rsi * ctx->block_size * ctx->bytes_per_sample;
unsigned rsi_n = ctx->obuf_len / (ctx->rsi * ctx->block_size); // Number of full rsi blocks
unsigned rsi_r = ctx->obuf_len % (ctx->rsi * ctx->block_size); // Remainder

// Edge case: Imposible to get wanted number of slices
size_t wanted_num_slices = 3;
if (wanted_num_slices > ctx->obuf_len) {
Expand Down Expand Up @@ -340,7 +318,6 @@ int test_read(struct aec_context *ctx)

if ((status = aec_decode_init(&strm_read)) != AEC_OK)
return status;
struct internal_state *state = strm_read.state;

// Test 1: Stream data
for (size_t i = 0; i < num_slices; ++i) {
Expand All @@ -360,7 +337,6 @@ int test_read(struct aec_context *ctx)

// Test 2: Read slices
for (size_t i = 0; i < num_slices; ++i) {
struct internal_state *state = strm_read.state;
size_t buf_size = slice_sizes[i];;
unsigned char *buf = malloc(buf_size);
if (buf == NULL) {
Expand Down Expand Up @@ -413,8 +389,6 @@ int test_offsets(struct aec_context *ctx)
return 102;
}

size_t size = decode_offsets_size > 10 ? 10 : decode_offsets_size;

for (size_t i = 0; i < encode_offsets_size; ++i) {
if (encode_offsets_ptr[i] != decode_offsets_ptr[i]) {
fprintf(stderr, "Error: encode_offsets_ptr[%zu] = %zu, decode_offsets_ptr[%zu] = %zu\n", i, encode_offsets_ptr[i], i, decode_offsets_ptr[i]);
Expand Down
2 changes: 1 addition & 1 deletion tests/check_seeking.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void shift_cdata(struct test_state *state, unsigned char *cbuf_unshifted,
unsigned char *dst = state->cbuf + byte_offset;

memset(state->cbuf, 0, state->buf_len);
for (int i = 0; i < strm->avail_in; i++) {
for (size_t i = 0; i < strm->avail_in; i++) {
dst[i] |= cbuf_unshifted[i] >> bit_offset;
dst[i + 1] |= cbuf_unshifted[i] << (8 - bit_offset);
}
Expand Down

0 comments on commit 62b9baf

Please sign in to comment.