Skip to content

Commit

Permalink
Fix fread warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
allkern committed Aug 5, 2024
1 parent 19f73ab commit 5a78ffe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions psx/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,10 @@ static inline uint32_t gte_divide(psx_cpu_t* cpu, uint16_t n, uint16_t d) {
return MIN(0x1ffff, res);
}

static inline void psx_gte_i_invalid(psx_cpu_t* cpu) {
log_fatal("invalid: Unimplemented GTE instruction %02x, %02x", cpu->opcode & 0x3f, cpu->opcode >> 25);
}

#define I64(v) ((int64_t)v)
#define R_TRX cpu->cop2_cr.tr.x
#define R_TRY cpu->cop2_cr.tr.y
Expand Down
7 changes: 5 additions & 2 deletions psx/dev/cdrom/cue.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ int cue_load(cue_t* cue, int mode) {
data->buf = malloc(data->size);

fseek(file, 0, SEEK_SET);
fread(data->buf, 1, data->size, file);

if (!fread(data->buf, 1, data->size, file))
return CUE_TRACK_READ_ERROR;

fclose(file);
} else {
Expand Down Expand Up @@ -554,7 +556,8 @@ int cue_read(cue_t* cue, uint32_t lba, void* buf) {
} else {
fseek(file->buf, (lba - file->start) * 2352, SEEK_SET);

fread(buf, 1, 2352, file->buf);
// Should always succeed, ignore result for speed
(void)fread(buf, 1, 2352, file->buf);
}

return (track->mode == CUE_MODE2_2352) ? TS_DATA : TS_AUDIO;
Expand Down
3 changes: 2 additions & 1 deletion psx/dev/cdrom/cue.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
enum {
CUE_OK = 0,
CUE_FILE_NOT_FOUND,
CUE_TRACK_FILE_NOT_FOUND
CUE_TRACK_FILE_NOT_FOUND,
CUE_TRACK_READ_ERROR
};

enum {
Expand Down
6 changes: 4 additions & 2 deletions psx/dev/exp1.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ void psx_exp1_load(psx_exp1_t* exp1, const char* path) {
FILE* file = fopen(path, "rb");

if (!file) {
perror("Error opening expansion ROM file \'%s\'");
perror("Error opening expansion ROM file");

exit(1);
}

fread(exp1->rom, 1, PSX_EXP1_SIZE, file);
if (!fread(exp1->rom, 1, PSX_EXP1_SIZE, file)) {
perror("Error reading expansion ROM file");
}

fclose(file);
}
Expand Down

0 comments on commit 5a78ffe

Please sign in to comment.