IopBios: Use typedefs and explicit casting

This commit is contained in:
Ty 2025-11-22 16:29:44 -05:00 committed by Ty
parent 89de00ac36
commit 53598b970d

View File

@ -44,39 +44,39 @@
typedef struct typedef struct
{ {
unsigned int mode; u32 mode;
unsigned int attr; u32 attr;
unsigned int size; u32 size;
unsigned char ctime[8]; u8 ctime[8];
unsigned char atime[8]; u8 atime[8];
unsigned char mtime[8]; u8 mtime[8];
unsigned int hisize; u32 hisize;
} fio_stat_t; } fio_stat_t;
typedef struct typedef struct
{ {
fio_stat_t _fioStat; fio_stat_t _fioStat;
/** Number of subs (main) / subpart number (sub) */ /** Number of subs (main) / subpart number (sub) */
unsigned int private_0; u32 private_0;
unsigned int private_1; u32 private_1;
unsigned int private_2; u32 private_2;
unsigned int private_3; u32 private_3;
unsigned int private_4; u32 private_4;
/** Sector start. */ /** Sector start. */
unsigned int private_5; u32 private_5;
} fxio_stat_t; } fxio_stat_t;
typedef struct typedef struct
{ {
fio_stat_t stat; fio_stat_t stat;
char name[256]; char name[256];
unsigned int unknown; u32 unknown;
} fio_dirent_t; } fio_dirent_t;
typedef struct typedef struct
{ {
fxio_stat_t stat; fxio_stat_t stat;
char name[256]; char name[256];
unsigned int unknown; u32 unknown;
} fxio_dirent_t; } fxio_dirent_t;
static std::string hostRoot; static std::string hostRoot;
@ -171,7 +171,7 @@ namespace R3000A
if (!FileSystem::StatFile(file_path.c_str(), &file_stats)) if (!FileSystem::StatFile(file_path.c_str(), &file_stats))
return -IOP_ENOENT; return -IOP_ENOENT;
host_stats->size = file_stats.st_size; host_stats->size = (u32)file_stats.st_size;
host_stats->hisize = 0; host_stats->hisize = 0;
// Convert the mode. // Convert the mode.
@ -315,13 +315,13 @@ namespace R3000A
switch (whence) switch (whence)
{ {
case IOP_SEEK_SET: case IOP_SEEK_SET:
err = ::lseek(fd, offset, SEEK_SET); err = static_cast<int>(::lseek(fd, offset, SEEK_SET));
break; break;
case IOP_SEEK_CUR: case IOP_SEEK_CUR:
err = ::lseek(fd, offset, SEEK_CUR); err = static_cast<int>(::lseek(fd, offset, SEEK_CUR));
break; break;
case IOP_SEEK_END: case IOP_SEEK_END:
err = ::lseek(fd, offset, SEEK_END); err = static_cast<int>(::lseek(fd, offset, SEEK_END));
break; break;
default: default:
return -IOP_EIO; return -IOP_EIO;
@ -332,12 +332,12 @@ namespace R3000A
virtual int read(void* buf, u32 count) /* Flawfinder: ignore */ virtual int read(void* buf, u32 count) /* Flawfinder: ignore */
{ {
return translate_error(::read(fd, buf, count)); return translate_error(static_cast<int>(::read(fd, buf, count)));
} }
virtual int write(void* buf, u32 count) virtual int write(void* buf, u32 count)
{ {
return translate_error(::write(fd, buf, count)); return translate_error(static_cast<int>(::write(fd, buf, count)));
} }
}; };
@ -762,7 +762,7 @@ namespace R3000A
v0 = host_stat(full_path, (fxio_stat_t*)&buf); v0 = host_stat(full_path, (fxio_stat_t*)&buf);
for (size_t i = 0; i < sizeof(fxio_stat_t); i++) for (size_t i = 0; i < sizeof(fxio_stat_t); i++)
iopMemWrite8(data + i, buf[i]); iopMemWrite8(static_cast<u32>(data + i), buf[i]);
} }
else else
{ {
@ -770,7 +770,7 @@ namespace R3000A
v0 = host_stat(full_path, (fio_stat_t*)&buf); v0 = host_stat(full_path, (fio_stat_t*)&buf);
for (size_t i = 0; i < sizeof(fio_stat_t); i++) for (size_t i = 0; i < sizeof(fio_stat_t); i++)
iopMemWrite8(data + i, buf[i]); iopMemWrite8(static_cast<u32>(data + i), buf[i]);
} }
pc = ra; pc = ra;
return 1; return 1;