int64 squashed into int

2 views
Skip to first unread message

Erik van der Kouwe

unread,
Jun 29, 2011, 9:46:19 AM6/29/11
to V3VEE Development, Jack Lange
Dear all,

In filedisk.c we have:

static int read(uint8_t * buf, uint64_t lba, uint64_t num_bytes, void *
private_data) {
...
return read_all(disk->fd, buf, lba, num_bytes);
}

which calls:

static int read_all(v3_file_t fd, char * buf, int offset, int length) {
...
int tmp_bytes = v3_file_read(fd, buf + bytes_read, length -
bytes_read, offset + bytes_read);
...
}

which in turn calls:

uint64_t v3_file_read(v3_file_t file, uint8_t * buf, uint64_t len,
uint64_t off);

ISTM this truncates the offset to 32 bits, while read had 64 bits and
v3_file_read can also deal with 64 bits. Unless for some reason the
offset is expected to always fit in 32 bits, this may not be a good idea.

The same situation is found for the similar write functions.

With kind regards,
Erik

Reply all
Reply to author
Forward
0 new messages