diff options
author | Andrew Jeffery <andrew@aj.id.au> | 2018-02-21 16:01:42 +1030 |
---|---|---|
committer | Andrew Jeffery <andrew@aj.id.au> | 2018-03-24 13:59:32 +1030 |
commit | 62de1aae27fc324c1864bfa4f788481041a48eb3 (patch) | |
tree | 21926247e2c00d829bd2140ff0587d76b3cadf83 | |
parent | 581a4f2c267ebad0b1cbf554a7b23ebf25ececfd (diff) | |
download | phosphor-mboxd-62de1aae27fc324c1864bfa4f788481041a48eb3.tar.gz phosphor-mboxd-62de1aae27fc324c1864bfa4f788481041a48eb3.zip |
pnor_partition_table: Return early in parseTocLine()
This is part of the ongoing effort to extract parseTocLine() from the
Table class, enabling reuse in setup for test cases.
Change-Id: I0521f82727029db1ab6c59971c923fcec01b6fc9
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r-- | pnor_partition_table.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/pnor_partition_table.cpp b/pnor_partition_table.cpp index ab72b5c..64fdfb5 100644 --- a/pnor_partition_table.cpp +++ b/pnor_partition_table.cpp @@ -170,31 +170,31 @@ bool Table::parseTocLine(fs::path& dir, const std::string& line, std::regex::extended}; std::smatch match; - if (std::regex_search(line, match, regex)) + if (!std::regex_search(line, match, regex)) { - fs::path partitionFile = dir; - partitionFile /= match[NAME_MATCH].str(); - if (!fs::exists(partitionFile)) - { - MSG_ERR("Partition file %s does not exist", partitionFile.c_str()); - return false; - } + return false; + } - writeNameAndId(part, match[NAME_MATCH].str(), match[ID_MATCH].str()); - writeDefaults(part); + fs::path partitionFile = dir; + partitionFile /= match[NAME_MATCH].str(); + if (!fs::exists(partitionFile)) + { + MSG_ERR("Partition file %s does not exist", partitionFile.c_str()); + return false; + } - unsigned long start = - std::stoul(match[START_ADDR_MATCH].str(), nullptr, 16); - unsigned long end = - std::stoul(match[END_ADDR_MATCH].str(), nullptr, 16); - writeSizes(part, start, end); + writeNameAndId(part, match[NAME_MATCH].str(), match[ID_MATCH].str()); + writeDefaults(part); - // Use the shift to convert "80" to 0x80000000 - unsigned long version = - std::stoul(match[VERSION_MATCH].str(), nullptr, 16); - writeUserdata(part, version << versionShift, match.suffix().str()); - part.checksum = details::checksum(part.data); - } + unsigned long start = + std::stoul(match[START_ADDR_MATCH].str(), nullptr, 16); + unsigned long end = std::stoul(match[END_ADDR_MATCH].str(), nullptr, 16); + writeSizes(part, start, end); + + // Use the shift to convert "80" to 0x80000000 + unsigned long version = std::stoul(match[VERSION_MATCH].str(), nullptr, 16); + writeUserdata(part, version << versionShift, match.suffix().str()); + part.checksum = details::checksum(part.data); return true; } |