Skip to content

Commit ef79cef

Browse files
authored
Merge pull request #8309 from The-OpenROAD-Project-staging/cugr-coverity
grt: cleanup some Coverity issues in cugr
2 parents b58d9be + 035fda6 commit ef79cef

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

src/grt/src/cugr/src/Layers.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,17 @@ MetalLayer::MetalLayer(odb::dbTechLayer* tech_layer,
6767
const int spacing = static_cast<int>(std::round(rule->getSpacing()));
6868
uint eol_width, eol_within, parallel_space, parallel_within;
6969
bool parallel_edge, two_edges;
70-
rule->getEol(eol_width,
71-
eol_within,
72-
parallel_edge,
73-
parallel_space,
74-
parallel_within,
75-
two_edges);
76-
// Pessimistic
77-
max_eol_spacing_ = std::max(max_eol_spacing_, spacing);
78-
max_eol_width_ = std::max(max_eol_width_, static_cast<int>(eol_width));
79-
max_eol_within_ = std::max(max_eol_within_, static_cast<int>(eol_within));
70+
if (rule->getEol(eol_width,
71+
eol_within,
72+
parallel_edge,
73+
parallel_space,
74+
parallel_within,
75+
two_edges)) {
76+
// Pessimistic
77+
max_eol_spacing_ = std::max(max_eol_spacing_, spacing);
78+
max_eol_width_ = std::max(max_eol_width_, static_cast<int>(eol_width));
79+
max_eol_within_ = std::max(max_eol_within_, static_cast<int>(eol_within));
80+
}
8081
}
8182
}
8283

src/grt/src/cugr/src/MazeRoute.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void MazeRoute::run()
197197
queue.pop();
198198
foundPinIndex = graph_.getVertexPin(solution->vertex);
199199
if (foundPinIndex != -1 && !visited[foundPinIndex]) {
200-
foundSolution = solution;
200+
foundSolution = std::move(solution);
201201
break;
202202
}
203203
// Pruning
@@ -221,11 +221,12 @@ void MazeRoute::run()
221221
}
222222

223223
solutions_.emplace_back(foundSolution);
224+
assert(foundPinIndex >= 0);
224225
visited[foundPinIndex] = true;
225226
numDetached -= 1;
226227

227228
// Update the cost of the vertices_ on the path
228-
std::shared_ptr<Solution> temp = foundSolution;
229+
std::shared_ptr<Solution> temp = std::move(foundSolution);
229230
while (temp && temp->cost != 0) {
230231
updateSolution(std::make_shared<Solution>(0, temp->vertex, temp->prev));
231232
temp = temp->prev;
@@ -255,7 +256,7 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
255256
auto it = created.find(temp->vertex);
256257
if (it == created.end()) {
257258
const PointT point = graph_.getPoint(temp->vertex);
258-
const auto node = std::make_shared<SteinerTreeNode>(point);
259+
auto node = std::make_shared<SteinerTreeNode>(point);
259260
created.emplace(temp->vertex, node);
260261
if (lastNode) {
261262
node->addChild(lastNode);
@@ -269,7 +270,7 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
269270
assert(pinIndex != -1);
270271
node->setFixedLayers(graph_.getPseudoPin(pinIndex).second);
271272
}
272-
lastNode = node;
273+
lastNode = std::move(node);
273274
temp = temp->prev;
274275
} else {
275276
if (lastNode) {
@@ -279,6 +280,7 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
279280
}
280281
}
281282
}
283+
assert(tree);
282284

283285
// Remove redundant tree nodes
284286
SteinerTreeNode::preorder(
@@ -317,7 +319,7 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
317319
== (*(temp->getChildren()[0]))[1 - direction]) {
318320
temp = temp->getChildren()[0];
319321
}
320-
child = temp;
322+
child = std::move(temp);
321323
}
322324
});
323325

src/grt/src/cugr/src/PatternRoute.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void PatternRoute::constructSteinerTree()
145145
}
146146
// Connect current to parent
147147
if (parent == nullptr) {
148-
parent = current;
148+
parent = std::move(current);
149149
} else {
150150
parent->addChild(current);
151151
}
@@ -186,7 +186,7 @@ void PatternRoute::constructRoutingDAG()
186186
constructDag(current, steinerChild);
187187
}
188188
if (dstNode == nullptr) {
189-
dstNode = current;
189+
dstNode = std::move(current);
190190
} else {
191191
dstNode->addChild(current);
192192
constructPaths(dstNode, current);
@@ -216,7 +216,7 @@ void PatternRoute::constructPaths(std::shared_ptr<PatternRoutingNode>& start,
216216
= std::make_shared<PatternRoutingNode>(
217217
midPoint, num_dag_nodes_++, true);
218218
mid->getPaths() = {{end}};
219-
childPaths.push_back(mid);
219+
childPaths.push_back(std::move(mid));
220220
}
221221
}
222222
}
@@ -637,6 +637,7 @@ std::shared_ptr<GRTreeNode> PatternRoute::getRoutingTree(
637637
}
638638
}
639639
}
640+
assert(parentLayerIndex >= 0);
640641
std::shared_ptr<GRTreeNode> routingNode
641642
= std::make_shared<GRTreeNode>(parentLayerIndex, node->x(), node->y());
642643
std::shared_ptr<GRTreeNode> lowestRoutingNode = routingNode;

0 commit comments

Comments
 (0)