Skip to content

Commit 57cf143

Browse files
committed
lib: move posix_fadvise before gx_decompress_file's reading of the fd
1 parent 35e538d commit 57cf143

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/rfbl.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,14 +1331,13 @@ errno_t gx_decompress_file(const char *infile, BINARY &outbin,
13311331
if (static_cast<unsigned long long>(sb.st_size) < inbufsize)
13321332
inbufsize = sb.st_size;
13331333
auto inbuf = std::make_unique<char[]>(inbufsize);
1334-
auto rdret = read(fd.get(), inbuf.get(), inbufsize);
1335-
if (rdret < 0)
1336-
return errno;
13371334
#if defined(HAVE_POSIX_FADVISE)
13381335
if (posix_fadvise(fd.get(), 0, sb.st_size, POSIX_FADV_SEQUENTIAL) != 0)
13391336
/* ignore */;
13401337
#endif
1341-
1338+
auto rdret = read(fd.get(), inbuf.get(), inbufsize);
1339+
if (rdret < 0)
1340+
return errno;
13421341
auto outsize = ZSTD_getFrameContentSize(inbuf.get(), rdret);
13431342
if (outsize == ZSTD_CONTENTSIZE_ERROR)
13441343
return EIO;

0 commit comments

Comments
 (0)