Skip to content

Commit 3ad065d

Browse files
Add some comments to scatter-gather parsing
1 parent 6e659aa commit 3ad065d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

libs/libarchfpga/src/read_xml_arch_file_sg.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ static std::vector<t_sg_link> parse_sg_link_tags(pugi::xml_node sg_link_list_tag
1717
std::vector<t_sg_link> sg_link_list;
1818
pugiutil::expect_only_children(sg_link_list_tag, {"sg_link"}, loc_data);
1919
for (pugi::xml_node node : sg_link_list_tag.children()) {
20-
if (strcmp(node.name(), "sg_link") != 0) continue;
21-
2220
const std::vector<std::string> expected_attributes = {"name", "x_offset", "y_offset", "z_offset", "mux", "seg_type"};
2321
pugiutil::expect_only_attributes(node, expected_attributes, loc_data);
2422

@@ -27,9 +25,10 @@ static std::vector<t_sg_link> parse_sg_link_tags(pugi::xml_node sg_link_list_tag
2725
sg_link.mux_name = pugiutil::get_attribute(node, "mux", loc_data).as_string();
2826
sg_link.seg_type = pugiutil::get_attribute(node, "seg_type", loc_data).as_string();
2927

30-
int x_offset = pugiutil::get_attribute(node, "x_offset", loc_data, pugiutil::OPTIONAL).as_int();
31-
int y_offset = pugiutil::get_attribute(node, "y_offset", loc_data, pugiutil::OPTIONAL).as_int();
32-
int z_offset = pugiutil::get_attribute(node, "z_offset", loc_data, pugiutil::OPTIONAL).as_int();
28+
// Since the offset attributes are optional and might not exist, the as_int method will return a value of zero if the attribute is empty
29+
int x_offset = pugiutil::get_attribute(node, "x_offset", loc_data, pugiutil::OPTIONAL).as_int(0);
30+
int y_offset = pugiutil::get_attribute(node, "y_offset", loc_data, pugiutil::OPTIONAL).as_int(0);
31+
int z_offset = pugiutil::get_attribute(node, "z_offset", loc_data, pugiutil::OPTIONAL).as_int(0);
3332

3433
if (x_offset == 0 && y_offset == 0 && z_offset == 0) {
3534
archfpga_throw(loc_data.filename_c_str(), loc_data.line(node), "All offset fields in the <sg_link> are non-zero or missing.");

0 commit comments

Comments
 (0)