:: commit 034b5cca506a9828849b39c9b1faa1d23e30b77a

mintsuki <mintsuki@protonmail.com> — 2023-03-29 18:29

parents: e132b5dfa5

limine-deploy: Check ferror() before using perror() on fread/fwrite fails

diff --git a/host/limine-deploy.c b/host/limine-deploy.c
index ecd803a8..2547d260 100644
--- a/host/limine-deploy.c
+++ b/host/limine-deploy.c
@@ -228,7 +228,9 @@ static bool device_flush_cache(void) {
 
     size_t ret = fwrite(cache, block_size, 1, device);
     if (ret != 1) {
-        perror("ERROR");
+        if (ferror(device)) {
+            perror("ERROR");
+        }
         return false;
     }
 
@@ -252,7 +254,9 @@ static bool device_cache_block(uint64_t block) {
 
     size_t ret = fread(cache, block_size, 1, device);
     if (ret != 1) {
-        perror("ERROR");
+        if (ferror(device)) {
+            perror("ERROR");
+        }
         return false;
     }
 
tab: 248 wrap: offon