Skip to content

Commit

Permalink
addressed compiler warnings in libmysofa
Browse files Browse the repository at this point in the history
  • Loading branch information
leomccormack committed Nov 21, 2023
1 parent 7217b7f commit 0d2aba5
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
18 changes: 9 additions & 9 deletions framework/modules/saf_sofa_reader/libmysofa/hdf/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ int treeRead(struct READER *reader, struct DATAOBJECT *data) {
elements *= data->datalayout_chunk[j];
dy = data->datalayout_chunk[1];
dz = data->datalayout_chunk[2];
sx = data->ds.dimension_size[0];
sy = data->ds.dimension_size[1];
sz = data->ds.dimension_size[2];
sx = (int)data->ds.dimension_size[0];
sy = (int)data->ds.dimension_size[1];
sz = (int)data->ds.dimension_size[2];
dzy = dz * dy;
szy = sz * sy;
size = data->datalayout_chunk[data->ds.dimensionality];
Expand Down Expand Up @@ -327,7 +327,7 @@ int treeRead(struct READER *reader, struct DATAOBJECT *data) {
case 1:
for (i = 0; i < olen; i++) {
b = i / elements;
x = i % elements + start[0];
x = i % elements + (int)start[0];
if (x < sx) {

j = x * size + b;
Expand All @@ -341,8 +341,8 @@ int treeRead(struct READER *reader, struct DATAOBJECT *data) {
for (i = 0; i < olen; i++) {
b = i / elements;
x = i % elements;
y = x % dy + start[1];
x = x / dy + start[0];
y = x % dy + (int)start[1];
x = x / dy + (int)start[0];
if (y < sy && x < sx) {
j = ((x * sy + y) * size) + b;
if (j >= 0 && j < data->data_len) {
Expand All @@ -355,9 +355,9 @@ int treeRead(struct READER *reader, struct DATAOBJECT *data) {
for (i = 0; i < olen; i++) {
b = i / elements;
x = i % elements;
z = x % dz + start[2];
y = (x / dz) % dy + start[1];
x = (x / dzy) + start[0];
z = x % dz + (int)start[2];
y = (x / dz) % dy + (int)start[1];
x = (x / dzy) + (int)start[0];
if (z < sz && y < sy && x < sx) {
j = (x * szy + y * sz + z) * size + b;
if (j >= 0 && j < data->data_len) {
Expand Down
10 changes: 5 additions & 5 deletions framework/modules/saf_sofa_reader/libmysofa/hdf/dataobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static int readOHDRHeaderMessageDatatype(struct READER *reader,
if (mysofa_seek(reader, (7 - j) & 7, SEEK_CUR))
return MYSOFA_READ_ERROR; // LCOV_EXCL_LINE

c = readValue(reader, 4);
c = (int)readValue(reader, 4);
int dimension = mysofa_getc(reader);
if (dimension != 0) {
mylog("COMPOUND v1 with dimension not supported");
Expand Down Expand Up @@ -506,7 +506,7 @@ static int readOHDRHeaderMessageDataLayout(struct READER *reader,
}
if (data_size > 0x10000000)
return MYSOFA_INVALID_FORMAT;
data->data_len = data_size;
data->data_len = (int)data_size;
data->data = calloc(1, data_size);
if (!data->data)
return MYSOFA_NO_MEMORY; // LCOV_EXCL_LINE
Expand All @@ -532,7 +532,7 @@ static int readOHDRHeaderMessageDataLayout(struct READER *reader,
data_address = readValue(reader, reader->superblock.size_of_offsets);
mylog(" CHUNK %" PRIX64 "\n", data_address);
for (i = 0; i < dimensionality; i++) {
data->datalayout_chunk[i] = readValue(reader, 4);
data->datalayout_chunk[i] = (int)readValue(reader, 4);
mylog(" %d\n", data->datalayout_chunk[i]);
}
/* TODO last entry? error in spec: ?*/
Expand Down Expand Up @@ -706,7 +706,7 @@ static int readOHDRHeaderMessageFilterPipelineV2(struct READER *reader,
return MYSOFA_UNSUPPORTED_FORMAT; // LCOV_EXCL_LINE
/* no name here */
for (j = 0; j < number_client_data_values; j++) {
client_data = readValue(reader, 4);
client_data = (uint32_t)readValue(reader, 4);
}
}

Expand Down Expand Up @@ -802,7 +802,7 @@ int readDataVar(struct READER *reader, struct DATAOBJECT *data,
readValue(reader, 4); /* TODO unclear reference */
reference = readValue(reader, dt->size - 4);
mylog(" REFERENCE size %d %" PRIX64 "\n", dt->size, reference);
if (!!(err = gcolRead(reader, gcol, reference, &dataobject))) {
if (!!(err = (int)gcolRead(reader, gcol, (int)reference, &dataobject))) {
return MYSOFA_OK; /* ignore error. TODO: why?
return err; */
}
Expand Down
8 changes: 4 additions & 4 deletions framework/modules/saf_sofa_reader/libmysofa/hdf/fractalhead.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,12 @@ static int indirectblockRead(struct READER *reader,

/* The number of rows of blocks, nrows, in an indirect block of size
* iblock_size is given by the following expression: */
nrows = (log2i(iblock_size) - log2i(fractalheap->starting_block_size)) + 1;
nrows = (log2i((int)iblock_size) - log2i((int)fractalheap->starting_block_size)) + 1;

/* The maximum number of rows of direct blocks, max_dblock_rows, in any
* indirect block of a fractal heap is given by the following expression: */
max_dblock_rows = (log2i(fractalheap->maximum_direct_block_size) -
log2i(fractalheap->starting_block_size)) +
max_dblock_rows = (log2i((int)fractalheap->maximum_direct_block_size) -
log2i((int)fractalheap->starting_block_size)) +
2;

/* Using the computed values for nrows and max_dblock_rows, along with the
Expand All @@ -475,7 +475,7 @@ static int indirectblockRead(struct READER *reader,
child_direct_block = readValue(reader, reader->superblock.size_of_offsets);
if (fractalheap->encoded_length > 0) {
size_filtered = readValue(reader, reader->superblock.size_of_lengths);
filter_mask = readValue(reader, 4);
filter_mask = (uint32_t)readValue(reader, 4);
}
mylog(">> %d %" PRIX64 " %d\n", k, child_direct_block, size);
if (validAddress(reader, child_direct_block)) {
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/saf_sofa_reader/libmysofa/hdf/gcol.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static int readGCOL(struct READER *reader) {
free(gcol);
return MYSOFA_UNSUPPORTED_FORMAT;
}
gcol->value = readValue(reader, gcol->object_size);
gcol->value = readValue(reader, (int)gcol->object_size);
gcol->address = address;
mylog(" GCOL object %d size %" PRIu64 " value %08" PRIX64 "\n",
gcol->heap_object_index, gcol->object_size, gcol->value);
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/saf_sofa_reader/libmysofa/hdf/gunzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int gunzip(int inlen, char *in, int *outlen, char *out) {
return err;

err = inflate(&stream, Z_SYNC_FLUSH);
*outlen = stream.total_out;
*outlen = (int)stream.total_out;
inflateEnd(&stream);
if (err && err != Z_STREAM_END) {
mylog(" gunzip error %d %s\n", err, stream.msg);
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/saf_sofa_reader/libmysofa/hrtf/kdtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern "C" {
struct kdtree;

/* create a kd-tree for 3-dimensional data */
struct kdtree *kd_create();
struct kdtree *kd_create(void);

/* free the struct kdtree */
void kd_free(struct kdtree *tree);
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/saf_sofa_reader/libmysofa/hrtf/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int validAddress(struct READER *reader, uint64_t address) {

int mysofa_read(struct READER *reader, void *buf, size_t n) {
if (reader->fhd)
return fread(buf, 1, n, reader->fhd);
return (int)fread(buf, 1, n, reader->fhd);
else {
if (reader->memory_pos + n > reader->memory_len) {
n = reader->memory_len - reader->memory_pos;
Expand All @@ -34,7 +34,7 @@ int mysofa_read(struct READER *reader, void *buf, size_t n) {
memcpy(buf, reader->memory + reader->memory_pos, n);
reader->memory_pos += n;

return n;
return (int)n;
}
}

Expand Down
10 changes: 5 additions & 5 deletions framework/modules/saf_sofa_reader/libmysofa/hrtf/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,21 +125,21 @@ void nsearch(const void *key, const char *base, size_t num, size_t size,
else if (result > 0)
start = mid + 1;
else {
*lower = mid;
*higher = mid;
*lower = (int)mid;
*higher = (int)mid;
return;
}
}

if (start == num) {
*lower = start - 1;
*lower = (int)start - 1;
*higher = -1;
} else if (start == 0) {
*lower = -1;
*higher = 0;
} else {
*lower = start - 1;
*higher = start;
*lower = (int)start - 1;
*higher = (int)start;
}
}

Expand Down

0 comments on commit 0d2aba5

Please sign in to comment.