shithub: psxe

Download patch

ref: 5a78ffea7388a6ef0b522aaa7636c64f21459ae7
parent: 19f73abc04a5db98a72fdd9c7beb079016692418
author: allkern <lisandroaalarcon@gmail.com>
date: Mon Aug 5 06:15:41 EDT 2024

Fix fread warnings

--- a/psx/cpu.c
+++ b/psx/cpu.c
@@ -1554,6 +1554,10 @@
     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
--- a/psx/dev/cdrom/cue.c
+++ b/psx/dev/cdrom/cue.c
@@ -414,8 +414,10 @@
             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 {
             data->buf = file;
@@ -554,7 +556,8 @@
     } 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;
--- a/psx/dev/cdrom/cue.h
+++ b/psx/dev/cdrom/cue.h
@@ -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 {
--- a/psx/dev/exp1.c
+++ b/psx/dev/exp1.c
@@ -28,12 +28,14 @@
     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);
 }
--