]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llava : fix compilation warning that fread return value is not used (#4069)
authorHuawei Lin <redacted>
Fri, 17 Nov 2023 15:22:56 +0000 (10:22 -0500)
committerGitHub <redacted>
Fri, 17 Nov 2023 15:22:56 +0000 (17:22 +0200)
examples/llava/llava.cpp

index d10bcf2d224657de8188ba8e4cbabd908fa53834..0cae8c4b10a3aa6a4fde9ff9c143ff90d843f12c 100644 (file)
@@ -127,7 +127,14 @@ static bool load_file_to_bytes(const char* path, unsigned char** bytesOut, long
         fclose(file);
         return false;
     }
-    fread(buffer, 1, fileSize, file); // Read the file into the buffer
+    errno = 0;
+    size_t ret = fread(buffer, 1, fileSize, file); // Read the file into the buffer
+    if (ferror(file)) {
+        die_fmt("read error: %s", strerror(errno));
+    }
+    if (ret != (size_t) fileSize) {
+        die("unexpectedly reached end of file");
+    }
     fclose(file); // Close the file
 
     *bytesOut = buffer;