Skip to content

Commit c7cce12

Browse files
authored
llava : fix compilation warning that fread return value is not used (#4069)
1 parent f7d5e97 commit c7cce12

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/llava/llava.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,14 @@ static bool load_file_to_bytes(const char* path, unsigned char** bytesOut, long
127127
fclose(file);
128128
return false;
129129
}
130-
fread(buffer, 1, fileSize, file); // Read the file into the buffer
130+
errno = 0;
131+
size_t ret = fread(buffer, 1, fileSize, file); // Read the file into the buffer
132+
if (ferror(file)) {
133+
die_fmt("read error: %s", strerror(errno));
134+
}
135+
if (ret != (size_t) fileSize) {
136+
die("unexpectedly reached end of file");
137+
}
131138
fclose(file); // Close the file
132139

133140
*bytesOut = buffer;

0 commit comments

Comments
 (0)