VintfObject: fix empty lines in log
am: 9f8f656993
Change-Id: Iee870c31f3cb75756e03e80a6064bd0adc9abd56
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 47480a4..5231183 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -343,6 +343,13 @@
return out->fetchAllInformation(mFileSystem.get(), kSystemLegacyManifest, error);
}
+static void appendLine(std::string* error, const std::string& message) {
+ if (error != nullptr) {
+ if (!error->empty()) *error += "\n";
+ *error += message;
+ }
+}
+
std::vector<Named<CompatibilityMatrix>> VintfObject::getAllFrameworkMatrixLevels(
std::string* error) {
std::vector<std::string> fileNames;
@@ -358,17 +365,14 @@
std::string fetchError;
status_t status = mFileSystem->fetch(path, &content, &fetchError);
if (status != OK) {
- if (error) {
- *error += "Framework Matrix: Ignore file " + path + ": " + fetchError + "\n";
- }
+ appendLine(error, "Framework Matrix: Ignore file " + path + ": " + fetchError);
continue;
}
auto it = results.emplace(results.end());
- if (!gCompatibilityMatrixConverter(&it->object, content, error)) {
- if (error) {
- *error += "Framework Matrix: Ignore file " + path + ": " + *error + "\n";
- }
+ std::string parseError;
+ if (!gCompatibilityMatrixConverter(&it->object, content, &parseError)) {
+ appendLine(error, "Framework Matrix: Ignore file " + path + ": " + parseError);
results.erase(it);
continue;
}
@@ -376,8 +380,8 @@
if (results.empty()) {
if (error) {
- *error = "No framework matrices under " + kSystemVintfDir +
- " can be fetched or parsed.\n" + *error;
+ error->insert(0, "No framework matrices under " + kSystemVintfDir +
+ " can be fetched or parsed.\n");
}
} else {
if (error && !error->empty()) {
@@ -455,13 +459,6 @@
return ParseStatus::OK;
}
-static void appendLine(std::string* error, const std::string& message) {
- if (error != nullptr) {
- if (!error->empty()) *error += "\n";
- *error += message;
- }
-}
-
template <typename T, typename GetFunction>
static status_t getMissing(const std::string& msg, const std::shared_ptr<T>& pkg, bool mount,
std::function<status_t(void)> mountFunction,
@@ -748,11 +745,9 @@
}
if (!targetVersionServed) {
- if (error) {
- *error += toFQNameString(package, servedVersion, interface, servedInstance) +
- " is deprecated; requires at least " + to_string(targetMatrixMinVer) +
- "\n";
- }
+ appendLine(error, toFQNameString(package, servedVersion, interface, servedInstance) +
+ " is deprecated; requires at least " +
+ to_string(targetMatrixMinVer));
return true;
}
}