Skip to content

Commit

Permalink
addressed warnings when under MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
DESKTOP-O8FHBKJ\Leo committed Nov 17, 2021
1 parent 86c3262 commit 8f19dd9
Show file tree
Hide file tree
Showing 7 changed files with 753 additions and 745 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ static int readOHDRHeaderMessageDatatype(struct READER *reader,

switch (dt->class_and_version & 0xf) {
case 0: /* int */
dt->u.i.bit_offset = readValue(reader, 2);
dt->u.i.bit_precision = readValue(reader, 2);
dt->u.i.bit_offset = (uint16_t)readValue(reader, 2);
dt->u.i.bit_precision = (uint16_t)readValue(reader, 2);
mylog(" INT bit %d %d %d %d\n", dt->u.i.bit_offset,
dt->u.i.bit_precision, dt->class_and_version >> 4, dt->size);
break;
Expand Down Expand Up @@ -527,7 +527,7 @@ static int readOHDRHeaderMessageDataLayout(struct READER *reader,

if (validAddress(reader, data_address)) {
store = ftell(reader->fhd);
if (fseek(reader->fhd, data_address, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)data_address, SEEK_SET) < 0)
return errno; // LCOV_EXCL_LINE
if (!data->data) {
if (data_size > 0x10000000)
Expand All @@ -540,7 +540,7 @@ static int readOHDRHeaderMessageDataLayout(struct READER *reader,
err = (int)fread(data->data, 1, data_size, reader->fhd);
if (err != (int)data_size)
return MYSOFA_READ_ERROR; // LCOV_EXCL_LINE
if (fseek(reader->fhd, store, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)store, SEEK_SET) < 0)
return errno; // LCOV_EXCL_LINE
}
break;
Expand All @@ -565,11 +565,11 @@ static int readOHDRHeaderMessageDataLayout(struct READER *reader,

size = data->datalayout_chunk[dimensionality - 1];
for (i = 0; i < data->ds.dimensionality; i++)
size *= data->ds.dimension_size[i];
size *= (unsigned int)data->ds.dimension_size[i];

if (validAddress(reader, data_address) && dimensionality <= 4) {
store = ftell(reader->fhd);
if (fseek(reader->fhd, data_address, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)data_address, SEEK_SET) < 0)
return errno; // LCOV_EXCL_LINE
if (!data->data) {
if (size > 0x10000000)
Expand All @@ -582,7 +582,7 @@ static int readOHDRHeaderMessageDataLayout(struct READER *reader,
err = treeRead(reader, data);
if (err)
return err; // LCOV_EXCL_LINE
if (fseek(reader->fhd, store, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)store, SEEK_SET) < 0)
return errno; // LCOV_EXCL_LINE
}
break;
Expand Down Expand Up @@ -924,7 +924,7 @@ static int readOHDRHeaderMessageContinue(struct READER *reader,

store = ftell(reader->fhd);

if (fseek(reader->fhd, offset, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)offset, SEEK_SET) < 0)
return errno; // LCOV_EXCL_LINE

err = readOCHK(reader, dataobject, offset + length);
Expand Down Expand Up @@ -1186,7 +1186,7 @@ static int readOHDRmessages(struct READER *reader,
}
}

if (fseek(fhd, end_of_messages + 4, SEEK_SET) < 0) /* skip checksum */
if (fseek(fhd, (long)end_of_messages + 4, SEEK_SET) < 0) /* skip checksum */
return errno;

return MYSOFA_OK;
Expand Down Expand Up @@ -1269,7 +1269,7 @@ int dataobjectRead(struct READER *reader, struct DATAOBJECT *dataobject,

/* parse message attribute info */
if (validAddress(reader, dataobject->ai.fractal_heap_address)) {
if (fseek(reader->fhd, dataobject->ai.fractal_heap_address, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)dataobject->ai.fractal_heap_address, SEEK_SET) < 0)
return errno;
err = fractalheapRead(reader, dataobject, &dataobject->attributes_heap);
if (err)
Expand All @@ -1278,7 +1278,7 @@ int dataobjectRead(struct READER *reader, struct DATAOBJECT *dataobject,

/* parse message link info */
if (validAddress(reader, dataobject->li.fractal_heap_address)) {
fseek(reader->fhd, dataobject->li.fractal_heap_address, SEEK_SET);
fseek(reader->fhd, (long)dataobject->li.fractal_heap_address, SEEK_SET);
err = fractalheapRead(reader, dataobject, &dataobject->objects_heap);
if (err)
return err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#define MAX_NAME_LENGTH (0x100)

static int log2i(int a) { return round(log2(a)); }
static int log2i(int a) { return (int)round(log2(a)); }

static int directblockRead(struct READER *reader, struct DATAOBJECT *dataobject,
struct FRACTALHEAP *fractalheap) {
Expand Down Expand Up @@ -95,11 +95,11 @@ static int directblockRead(struct READER *reader, struct DATAOBJECT *dataobject,
if (fseek(reader->fhd, 4, SEEK_CUR))
return errno; // LCOV_EXCL_LINE

offset_size = ceilf(log2f(fractalheap->maximum_heap_size) / 8);
offset_size = (int)ceilf(log2f(fractalheap->maximum_heap_size) / 8);
if (fractalheap->maximum_direct_block_size < fractalheap->maximum_size)
length_size = ceilf(log2f(fractalheap->maximum_direct_block_size) / 8);
length_size = (int)ceilf(log2f((float)fractalheap->maximum_direct_block_size) / 8);
else
length_size = ceilf(log2f(fractalheap->maximum_size) / 8);
length_size = (int)ceilf(log2f((float)fractalheap->maximum_size) / 8);

mylog(" %d %" PRIu64 " %d\n", size, block_offset, offset_size);

Expand Down Expand Up @@ -260,7 +260,7 @@ static int directblockRead(struct READER *reader, struct DATAOBJECT *dataobject,
dataobject->directory = dir;

store = ftell(reader->fhd);
if (fseek(reader->fhd, heap_header_address, SEEK_SET)) {
if (fseek(reader->fhd, (long)heap_header_address, SEEK_SET)) {
free(name); // LCOV_EXCL_LINE
return errno; // LCOV_EXCL_LINE
}
Expand Down Expand Up @@ -509,7 +509,7 @@ static int indirectblockRead(struct READER *reader,
mylog(">> %d %" PRIX64 " %d\n", k, child_direct_block, size);
if (validAddress(reader, child_direct_block)) {
store = ftell(reader->fhd);
if (fseek(reader->fhd, child_direct_block, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)child_direct_block, SEEK_SET) < 0)
return errno;
err = directblockRead(reader, dataobject, fractalheap);
if (err)
Expand All @@ -529,7 +529,7 @@ static int indirectblockRead(struct READER *reader,

if (validAddress(reader, child_direct_block)) {
store = ftell(reader->fhd);
if (fseek(reader->fhd, child_indirect_block, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)child_indirect_block, SEEK_SET) < 0)
return errno;
err = indirectblockRead(reader, dataobject, fractalheap, iblock_size * 2);
if (err)
Expand Down Expand Up @@ -658,7 +658,7 @@ int fractalheapRead(struct READER *reader, struct DATAOBJECT *dataobject,

if (validAddress(reader, fractalheap->address_of_root_block)) {

if (fseek(reader->fhd, fractalheap->address_of_root_block, SEEK_SET) < 0)
if (fseek(reader->fhd, (long)fractalheap->address_of_root_block, SEEK_SET) < 0)
return errno;
if (fractalheap->current_row)
err = indirectblockRead(reader, dataobject, fractalheap,
Expand Down
Loading

0 comments on commit 8f19dd9

Please sign in to comment.