From 734a3394faffd042b99c520963f78d3084f2e56e Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Wed, 23 Aug 2017 15:14:02 -0700 Subject: Do not allow first version to have non-empty . Stating on a tag in fwk compat mat means the fragment is conditionally used. Older libvintf (libvintf on O devices) use the first tag with a match version unconditionally. Disable this to allow old libvintf to parse the requirements more correctly. In detail: * O libvintf may still falsely accept incompatible fwk comp mat, because it only looks at the first element. The conditional requirements are not checked. * O libvintf does not falsely reject a compatible fwk comp mat. Conditional requirements are never the first element and hence are not checked by O libvintf. This is a workaround solution for backwards compatibility, since O has been released. Test: libvintf_test Bug: 64124223 Change-Id: I20a9bb768720fc83ac5cdf293a976cb279cb6eab Merged-In: I20a9bb768720fc83ac5cdf293a976cb279cb6eab --- parse_xml.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/parse_xml.cpp b/parse_xml.cpp index f524fb8..3e495fd 100644 --- a/parse_xml.cpp +++ b/parse_xml.cpp @@ -887,6 +887,21 @@ struct CompatibilityMatrixConverter : public XmlNodeConverterframework.mAvbMetaVersion)) { return false; } + + std::set seenKernelVersions; + for (const auto& kernel : object->framework.mKernels) { + Version minLts(kernel.minLts().version, kernel.minLts().majorRev); + if (seenKernelVersions.find(minLts) != seenKernelVersions.end()) { + continue; + } + if (!kernel.conditions().empty()) { + this->mLastError = "First for version " + to_string(minLts) + + " must have empty for backwards compatibility."; + return false; + } + seenKernelVersions.insert(minLts); + } + } else if (object->mType == SchemaType::DEVICE) { // can be missing because it can be determined at build time, not hard-coded // in the XML file. -- cgit v1.2.3-54-g00ecf