From: Huawei Lin Date: Fri, 17 Nov 2023 15:22:56 +0000 (-0500) Subject: llava : fix compilation warning that fread return value is not used (#4069) X-Git-Tag: upstream/0.0.4488~2959 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=c7cce1246e248124117ae5bc058923e3ade95f11;p=pkg%2Fggml%2Fsources%2Fllama.cpp llava : fix compilation warning that fread return value is not used (#4069) --- 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;