Skip to content

Commit

Permalink
addressed some more libmysofa warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
leomccormack committed Nov 21, 2023
1 parent 6f0f0da commit 6280d2a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 14 deletions.
4 changes: 3 additions & 1 deletion framework/modules/saf_sofa_reader/libmysofa/hdf/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ static int readBTLF(struct READER *reader, struct BTREE *btree,

char buf[5];

UNUSED(*btree);

UNUSED(heap_id);
UNUSED(hash_of_name);
UNUSED(creation_order);
Expand Down Expand Up @@ -307,7 +309,7 @@ int treeRead(struct READER *reader, struct DATAOBJECT *data) {
free(output); // LCOV_EXCL_LINE
return MYSOFA_NO_MEMORY; // LCOV_EXCL_LINE
}
if (mysofa_read(reader, input, size_of_chunk) != size_of_chunk) {
if (mysofa_read(reader, input, size_of_chunk) != (int)size_of_chunk) {
free(output); // LCOV_EXCL_LINE
free(input); // LCOV_EXCL_LINE
return MYSOFA_INVALID_FORMAT; // LCOV_EXCL_LINE
Expand Down
16 changes: 9 additions & 7 deletions framework/modules/saf_sofa_reader/libmysofa/hdf/dataobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ static int readOHDRHeaderMessageDatatype(struct READER *reader,
mylog(" COMPOUND %d %02X\n", dt->size, dt->class_bit_field);
switch (dt->class_and_version >> 4) {
case 3:
for (i = 0; i < (dt->class_bit_field & 0xffff); i++) {
for (i = 0; i < (int)(dt->class_bit_field & 0xffff); i++) {
int maxsize = 0x1000;
buffer = malloc(maxsize);
if (!buffer)
Expand Down Expand Up @@ -301,7 +301,7 @@ static int readOHDRHeaderMessageDatatype(struct READER *reader,
break;

case 1:
for (i = 0; i < (dt->class_bit_field & 0xffff); i++) {
for (i = 0; i < (int)(dt->class_bit_field & 0xffff); i++) {
char name[256];
int res;
for (j = 0;; j++) {
Expand Down Expand Up @@ -512,7 +512,7 @@ static int readOHDRHeaderMessageDataLayout(struct READER *reader,
return MYSOFA_NO_MEMORY; // LCOV_EXCL_LINE

err = mysofa_read(reader, data->data, data_size);
if (err != data_size)
if (err != (int)data_size)
return MYSOFA_READ_ERROR; // LCOV_EXCL_LINE
if (mysofa_seek(reader, store, SEEK_SET) < 0)
return errno; // LCOV_EXCL_LINE
Expand Down Expand Up @@ -753,6 +753,8 @@ int readDataVar(struct READER *reader, struct DATAOBJECT *data,
int err;
struct DATAOBJECT *referenceData;

UNUSED(*ds);

if (dt->list) {
if (dt->list - dt->size == 8) {
readValue(reader, 4); /* TODO unknown? */
Expand All @@ -778,7 +780,7 @@ int readDataVar(struct READER *reader, struct DATAOBJECT *data,
if (buffer == NULL) {
return MYSOFA_NO_MEMORY; // LCOV_EXCL_LINE
}
if (mysofa_read(reader, buffer, dt->size) != dt->size) {
if (mysofa_read(reader, buffer, dt->size) != (int)dt->size) {
free(buffer); // LCOV_EXCL_LINE
return MYSOFA_READ_ERROR; // LCOV_EXCL_LINE
}
Expand Down Expand Up @@ -843,10 +845,10 @@ int readDataDim(struct READER *reader, struct DATAOBJECT *da,
struct DATATYPE *dt, struct DATASPACE *ds, int dim) {
int i, err;

if (dim >= sizeof(ds->dimension_size) / sizeof(ds->dimension_size[0]))
if (dim >= (int)sizeof(ds->dimension_size) / (int)sizeof(ds->dimension_size[0]))
return MYSOFA_UNSUPPORTED_FORMAT; // LCOV_EXCL_LINE

for (i = 0; i < ds->dimension_size[dim]; i++) {
for (i = 0; i < (int)ds->dimension_size[dim]; i++) {
if (dim + 1 < ds->dimensionality) {
if (!!(err = readDataDim(reader, da, dt, ds, dim + 1))) {
return err; // LCOV_EXCL_LINE
Expand Down Expand Up @@ -1077,7 +1079,7 @@ static int readOHDRmessages(struct READER *reader,
long end;

while (mysofa_tell(reader) <
end_of_messages - 4) { /* final gap may has a size of up to 3 */
(long)end_of_messages - 4) { /* final gap may has a size of up to 3 */
uint8_t header_message_type = (uint8_t)mysofa_getc(reader);
uint16_t header_message_size = (uint16_t)readValue(reader, 2);
uint8_t header_message_flags = (uint8_t)mysofa_getc(reader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int directblockRead(struct READER *reader, struct DATAOBJECT *dataobject,

if (!(name = malloc(length + 1)))
return MYSOFA_NO_MEMORY; // LCOV_EXCL_LINE
if (mysofa_read(reader, name, length) != length) {
if (mysofa_read(reader, name, length) != (int)length) {
free(name); // LCOV_EXCL_LINE
return MYSOFA_READ_ERROR; // LCOV_EXCL_LINE
}
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 @@ -46,7 +46,7 @@ static int readGCOL(struct READER *reader) {
}
end += collection_size - 8;

while (mysofa_tell(reader) <= end - 8 - reader->superblock.size_of_lengths) {
while (mysofa_tell(reader) <= (long)end - 8 - reader->superblock.size_of_lengths) {

gcol = malloc(sizeof(*gcol));
if (!gcol)
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/saf_sofa_reader/libmysofa/hdf/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ void gcolFree(struct GCOL *gcol);
int treeRead(struct READER *reader, struct DATAOBJECT *data);

struct READER {
FILE *fhd; //< file handler if file is used
FILE *fhd; // file handler if file is used

const char *memory; //< memory buffer if memory shall be used
const char *memory; // memory buffer if memory shall be used
uint64_t memory_pos;
uint64_t memory_len;

Expand Down
4 changes: 2 additions & 2 deletions framework/modules/saf_sofa_reader/libmysofa/hdf/superblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int superblockRead2or3(struct READER *reader, struct SUPERBLOCK *superblock) {
if (mysofa_seek(reader, 0L, SEEK_END))
return errno;

if (superblock->end_of_file_address != mysofa_tell(reader)) {
if (superblock->end_of_file_address != (uint64_t)mysofa_tell(reader)) {
mylog("file size mismatch\n");
return MYSOFA_INVALID_FORMAT;
}
Expand Down Expand Up @@ -165,7 +165,7 @@ int superblockRead0or1(struct READER *reader, struct SUPERBLOCK *superblock,
if (mysofa_seek(reader, 0L, SEEK_END))
return errno;

if (superblock->end_of_file_address != mysofa_tell(reader)) {
if (superblock->end_of_file_address != (uint64_t)mysofa_tell(reader)) {
mylog("file size mismatch\n");
}
/* end of superblock */
Expand Down

0 comments on commit 6280d2a

Please sign in to comment.