From d3edb603db770917d9336b98e770434aaa617af4 Mon Sep 17 00:00:00 2001 From: Kai Krakow Date: Fri, 23 Oct 2020 10:25:27 +0200 Subject: [PATCH] DB, read_entry: Get rid of goto, simplify semi-duplicate `if` block Signed-off-by: Kai Krakow --- fossilize_db.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/fossilize_db.cpp b/fossilize_db.cpp index d718d937..820f5ec6 100644 --- a/fossilize_db.cpp +++ b/fossilize_db.cpp @@ -309,27 +309,15 @@ struct DumbDirectoryDatabase : DatabaseInterface return false; } - bool success = false; size_t file_size = size_t(ftell(file)); rewind(file); + bool success = true; if (blob) - { - if (*blob_size != file_size) - goto discard_and_close; - } + success = (*blob_size == file_size) && (fread(blob, 1, file_size, file) == file_size); else *blob_size = file_size; - if (blob) - { - if (fread(blob, 1, file_size, file) != file_size) - goto discard_and_close; - } - - success = true; - -discard_and_close: LINUX_fadvise(file, 0, file_size, POSIX_FADV_DONTNEED); fclose(file); return success;