diff options
author | Martin Braun <martin.braun@ettus.com> | 2020-09-21 11:47:32 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-09-25 11:21:10 -0500 |
commit | 05a6b351d75231337a4bdc783791515676b1c333 (patch) | |
tree | 8aaa859d12fde8d0c8733a76f171f916e310c496 | |
parent | 2e64cb1b2891cbecab832aec00b8269e0798ff0d (diff) | |
download | uhd-05a6b351d75231337a4bdc783791515676b1c333.tar.gz uhd-05a6b351d75231337a4bdc783791515676b1c333.tar.bz2 uhd-05a6b351d75231337a4bdc783791515676b1c333.zip |
lib: graph_utils: Fix formatting and compiler warnings
The conditional setting of some variables lead the compiler to assume
they might be used uninitialized. Circumventing compiler warning by
initializing variables to a default value, even if that's not the right
value (they will get set later).
Also applied clang-format to the same code section.
This fixes da1aeaeccc.
-rw-r--r-- | host/lib/utils/graph_utils.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/host/lib/utils/graph_utils.cpp b/host/lib/utils/graph_utils.cpp index d3288440c..e92e83da5 100644 --- a/host/lib/utils/graph_utils.cpp +++ b/host/lib/utils/graph_utils.cpp @@ -52,7 +52,7 @@ std::vector<graph_edge_t> get_block_chain(const rfnoc_graph::sptr graph, if ((source_chain) ? (edge.src_blockid == current_block && edge.src_port == current_port) : (edge.dst_blockid == current_block - && edge.dst_port == current_port)) { + && edge.dst_port == current_port)) { // If the current block is the edge's source, make the edge's // destination the current block next_found = true; @@ -101,7 +101,7 @@ void connect_through_blocks(rfnoc_graph::sptr graph, // input port match what we're looking for return dst_found || (dst_blk.to_string() == edge.dst_blockid - && dst_port == edge.dst_port); + && dst_port == edge.dst_port); }); // If our dst_blk is in the chain already, make sure its the last element and continue if (dst_found) { @@ -129,25 +129,27 @@ void connect_through_blocks(rfnoc_graph::sptr graph, // call connect on the src and dst blocks since calling // connect on SEPs is invalid std::string src_to_sep_id; - size_t src_to_sep_port; + size_t src_to_sep_port = 0; std::string sep_to_dst_id; - size_t sep_to_dst_port; + size_t sep_to_dst_port = 0; bool has_sep_connection = false; for (auto edge : block_chain) { - if(uhd::rfnoc::block_id_t(edge.dst_blockid).match(uhd::rfnoc::NODE_ID_SEP)) { + if (uhd::rfnoc::block_id_t(edge.dst_blockid).match(uhd::rfnoc::NODE_ID_SEP)) { has_sep_connection = true; - src_to_sep_id = edge.src_blockid; - src_to_sep_port = edge.src_port; - } else if(uhd::rfnoc::block_id_t(edge.src_blockid).match(uhd::rfnoc::NODE_ID_SEP)) { + src_to_sep_id = edge.src_blockid; + src_to_sep_port = edge.src_port; + } else if (uhd::rfnoc::block_id_t(edge.src_blockid) + .match(uhd::rfnoc::NODE_ID_SEP)) { has_sep_connection = true; - sep_to_dst_id = edge.dst_blockid; - sep_to_dst_port = edge.dst_port; - } else{ - graph->connect(edge.src_blockid, edge.src_port, edge.dst_blockid, edge.dst_port); + sep_to_dst_id = edge.dst_blockid; + sep_to_dst_port = edge.dst_port; + } else { + graph->connect( + edge.src_blockid, edge.src_port, edge.dst_blockid, edge.dst_port); } } - if(has_sep_connection) { + if (has_sep_connection) { graph->connect(src_to_sep_id, src_to_sep_port, sep_to_dst_id, sep_to_dst_port); } } |