From: Yann Collet Date: Thu, 17 Oct 2019 21:29:48 +0000 (-0700) Subject: fix harness test X-Git-Tag: v1.4.4~1^2~23^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b8e873357a32e53edb6ef3b7cbe8bc58a9c75fc;p=thirdparty%2Fzstd.git fix harness test --- diff --git a/doc/educational_decoder/harness.c b/doc/educational_decoder/harness.c index de2e12358..a704f6bdb 100644 --- a/doc/educational_decoder/harness.c +++ b/doc/educational_decoder/harness.c @@ -39,19 +39,15 @@ static size_t read_file(const char *path, u8 **ptr) exit(1); } - size_t pos = 0; - while (!feof(f)) { - size_t const read = fread(*ptr + pos, 1, size, f); - if (ferror(f)) { - fprintf(stderr, "error while reading file %s \n", path); - exit(1); - } - pos += read; + size_t const read = fread(*ptr, 1, size, f); + if (read != size) { /* must read everything in one pass */ + fprintf(stderr, "error while reading file %s \n", path); + exit(1); } fclose(f); - return pos; + return read; } static void write_file(const char *path, const u8 *ptr, size_t size)