summaryrefslogtreecommitdiff
path: root/examples/llava
diff options
context:
space:
mode:
authorHuawei Lin <huaweilin.cs@gmail.com>2023-11-17 10:22:56 -0500
committerGitHub <noreply@github.com>2023-11-17 17:22:56 +0200
commitc7cce1246e248124117ae5bc058923e3ade95f11 (patch)
treee96636164fcbdb09403d61a68642867378454524 /examples/llava
parentf7d5e975424ff0eea55ca5a9181ac8e15553c1fc (diff)
llava : fix compilation warning that fread return value is not used (#4069)
Diffstat (limited to 'examples/llava')
-rw-r--r--examples/llava/llava.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/llava/llava.cpp b/examples/llava/llava.cpp
index d10bcf2d..0cae8c4b 100644
--- a/examples/llava/llava.cpp
+++ b/examples/llava/llava.cpp
@@ -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;