From 82c4dd2bc7ca81674ff94145b5ef5cae01481437 Mon Sep 17 00:00:00 2001 From: Mu-Le Lee Date: Mon, 22 Aug 2022 05:16:49 +0000 Subject: [PATCH] Fix header-abi-diff skips diff when config.json is not found Skip loading config.json when the config.json is not found so the header-abi-diff will still perform abi diff. Test: preform abi diff without config.json Bug: 243328443 Change-Id: I92ebf7e7bfe6abb57bdefa211eaf604efaee517e --- vndk/tools/header-checker/src/diff/header_abi_diff.cpp | 5 ++++- vndk/tools/header-checker/src/utils/config_file.cpp | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vndk/tools/header-checker/src/diff/header_abi_diff.cpp b/vndk/tools/header-checker/src/diff/header_abi_diff.cpp index 0ce370362..224f522c9 100644 --- a/vndk/tools/header-checker/src/diff/header_abi_diff.cpp +++ b/vndk/tools/header-checker/src/diff/header_abi_diff.cpp @@ -213,7 +213,10 @@ bool ShouldEmitWarningMessage(CompatibilityStatusIR status) { int main(int argc, const char **argv) { llvm::cl::ParseCommandLineOptions(argc, argv, "header-checker"); - ReadConfigFile(GetConfigFilePath(old_dump)); + const std::string config_file_path = GetConfigFilePath(old_dump); + if (llvm::sys::fs::exists(config_file_path)) { + ReadConfigFile(config_file_path); + } std::set ignored_symbols; if (llvm::sys::fs::exists(ignore_symbol_list)) { diff --git a/vndk/tools/header-checker/src/utils/config_file.cpp b/vndk/tools/header-checker/src/utils/config_file.cpp index c6a8eb2d2..e3efb6555 100644 --- a/vndk/tools/header-checker/src/utils/config_file.cpp +++ b/vndk/tools/header-checker/src/utils/config_file.cpp @@ -72,10 +72,7 @@ bool ConfigFile::Load(std::istream &istream) { bool ConfigFile::Load(const std::string &path) { std::ifstream stream(path); - if (stream.is_open()) { - return Load(stream); - } - return false; + return stream && Load(stream); } } // namespace utils