From 169ddca90e8bb6b6d286444a81b8eb1fbdb6c812 Mon Sep 17 00:00:00 2001 From: Greg Kaiser Date: Thu, 7 Feb 2019 08:54:01 -0800 Subject: [PATCH] [DO NOT MERGE] btif: Lighter weight file existence check We switch from the heavier weight fopen() to using access() to check for file existence and readability. This avoids some of the file opening overhead we don't need here. Bug: b/117993149 Test: TreeHugger Change-Id: Ib47b24e9d96803b7822535f9f566aa7818b38953 Merged-In: Ib47b24e9d96803b7822535f9f566aa7818b38953 --- btif/src/btif_config.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/btif/src/btif_config.cc b/btif/src/btif_config.cc index bc11ca0b2..2eaf29453 100644 --- a/btif/src/btif_config.cc +++ b/btif/src/btif_config.cc @@ -604,11 +604,8 @@ static std::string hash_file(const char* filename) { static std::string read_checksum_file(const char* checksum_filename) { // Ensure file exists - FILE* fp = fopen(checksum_filename, "rb"); - if (!fp) { + if (access(checksum_filename, R_OK) != 0) { return ""; - } else { - fclose(fp); } std::string output = btifKeystore.Decrypt(checksum_filename); return output; -- 2.11.0