From: Jens Axboe Date: Thu, 3 Jul 2014 21:32:07 +0000 (-0600) Subject: iolog: do stat() after fopen() X-Git-Tag: fio-2.1.11~21 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=fd771971384a5ff2c59921617f3d59e26490ec06;p=fio.git iolog: do stat() after fopen() Avoid static checker complaining about a potential race here, ordering doesn't matter to fio. Signed-off-by: Jens Axboe --- diff --git a/iolog.c b/iolog.c index d08569fd..75ce623f 100644 --- a/iolog.c +++ b/iolog.c @@ -806,20 +806,21 @@ int iolog_file_inflate(const char *file) struct iolog_compress ic; z_stream stream; struct stat sb; - size_t ret; + ssize_t ret; FILE *f; - if (stat(file, &sb) < 0) { - perror("stat"); - return 1; - } - f = fopen(file, "r"); if (!f) { perror("fopen"); return 1; } + if (stat(file, &sb) < 0) { + fclose(f); + perror("stat"); + return 1; + } + ic.buf = malloc(sb.st_size); ic.len = sb.st_size; ic.nofree = 1;