From 9076b0c4e78e8680ce40ce48321e8ab81a87705b Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 28 Feb 2018 11:29:45 -0800 Subject: Be clearer about linker warnings. Explicitly say "warning" for warnings, explicitly say what action we're going to take (such as "(ignoring)"), always provide a link to our documentation when there is one, explicitly say what API level the behavior changes at, and explicitly say why we're allowing the misbehavior for now. Bug: http://b/71852862 Test: ran tests, looked at logcat Change-Id: I1795a5af45deb904332b866d7d666690dae4340b --- linker/linker_utils.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'linker/linker_utils.cpp') diff --git a/linker/linker_utils.cpp b/linker/linker_utils.cpp index 5bf88e764..661e7cbc1 100644 --- a/linker/linker_utils.cpp +++ b/linker/linker_utils.cpp @@ -209,31 +209,28 @@ void resolve_paths(std::vector& paths, const char* original_path = path.c_str(); if (realpath(original_path, resolved_path) != nullptr) { struct stat s; - if (stat(resolved_path, &s) == 0) { - if (S_ISDIR(s.st_mode)) { - resolved_paths->push_back(resolved_path); - } else { - DL_WARN("Warning: \"%s\" is not a directory (excluding from path)", resolved_path); - continue; - } - } else { - DL_WARN("Warning: cannot stat file \"%s\": %s", resolved_path, strerror(errno)); + if (stat(resolved_path, &s) == -1) { + DL_WARN("Warning: cannot stat file \"%s\": %s (ignoring)", resolved_path, strerror(errno)); + continue; + } + if (!S_ISDIR(s.st_mode)) { + DL_WARN("Warning: \"%s\" is not a directory (ignoring)", resolved_path); continue; } + resolved_paths->push_back(resolved_path); } else { - std::string zip_path; - std::string entry_path; - std::string normalized_path; - if (!normalize_path(original_path, &normalized_path)) { - DL_WARN("Warning: unable to normalize \"%s\"", original_path); + DL_WARN("Warning: unable to normalize \"%s\" (ignoring)", original_path); continue; } + std::string zip_path; + std::string entry_path; if (parse_zip_path(normalized_path.c_str(), &zip_path, &entry_path)) { if (realpath(zip_path.c_str(), resolved_path) == nullptr) { - DL_WARN("Warning: unable to resolve \"%s\": %s", zip_path.c_str(), strerror(errno)); + DL_WARN("Warning: unable to resolve \"%s\": %s (ignoring)", + zip_path.c_str(), strerror(errno)); continue; } @@ -242,4 +239,3 @@ void resolve_paths(std::vector& paths, } } } - -- cgit v1.2.3