Skip to content

Commit a6bbc93

Browse files
authored
Merge pull request #9041 from eder-matheus/coverity_fixes
misc: coverity fixes
2 parents 4a6119c + 5378881 commit a6bbc93

File tree

13 files changed

+73
-28
lines changed

13 files changed

+73
-28
lines changed

src/grt/src/GlobalRouter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ GlobalRouter::GlobalRouter(utl::Logger* logger,
7878
grid_origin_(0, 0),
7979
groute_renderer_(nullptr),
8080
grid_(new Grid),
81+
is_incremental_(false),
8182
adjustment_(0.0),
8283
congestion_report_iter_step_(0),
8384
allow_congestion_(false),
@@ -2329,8 +2330,7 @@ void GlobalRouter::loadGuidesFromDB()
23292330
void GlobalRouter::ensurePinsPositions(odb::dbNet* db_net)
23302331
{
23312332
std::string pins_not_covered;
2332-
netIsCovered(db_net, pins_not_covered);
2333-
if (!pins_not_covered.empty()) {
2333+
if (!netIsCovered(db_net, pins_not_covered)) {
23342334
Net* net = db_net_map_[db_net];
23352335
for (Pin& pin : net->getPins()) {
23362336
if (pins_not_covered.find(pin.getName()) != std::string::npos) {

src/grt/src/RepairAntennas.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ RepairAntennas::RepairAntennas(GlobalRouter* grouter,
4141
unique_diode_index_(1),
4242
illegal_diode_placement_count_(0),
4343
has_new_violations_(false),
44-
routing_source_(RoutingSource::None)
44+
routing_source_(RoutingSource::None),
45+
tile_size_(0),
46+
jumper_size_(0),
47+
smaller_seg_size_(0)
4548
{
4649
block_ = db_->getChip()->getBlock();
4750
while (block_->findInst(

src/grt/src/Rudy.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ Rudy::Rudy(odb::dbBlock* block, grt::GlobalRouter* grouter)
4747
}
4848
pitch_terms += 1.0 / pitch;
4949
}
50-
wire_width_ = (1 / pitch_terms) * 1.25; // = harm. mean / num_routing_layers
50+
51+
if (pitch_terms != 0) {
52+
wire_width_
53+
= (1 / pitch_terms) * 1.25; // = harm. mean / num_routing_layers
54+
}
5155

5256
int x_grids, y_grids;
5357
grouter_->getGridSize(x_grids, y_grids);

src/grt/src/cugr/src/GridGraph.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,14 @@ AccessPointSet GridGraph::selectAccessPoints(const GRNet* net) const
405405
if (bestAccessDist.first == 0) {
406406
logger_->warn(utl::GRT, 274, "pin is hard to access.");
407407
}
408+
409+
if (bestIndex == -1) {
410+
logger_->error(utl::GRT,
411+
283,
412+
"No preferred access point found for pin on net {}.",
413+
net->getName());
414+
}
415+
408416
const PointT selectedPoint = accessPoints[bestIndex];
409417
const AccessPoint ap{selectedPoint, {}};
410418
auto it = selected_access_points.emplace(ap).first;

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,12 @@ void MazeRoute::run()
220220
}
221221

222222
solutions_.emplace_back(foundSolution);
223-
assert(foundPinIndex >= 0);
223+
if (foundPinIndex == -1) {
224+
logger_->error(utl::GRT,
225+
282,
226+
"Failed to find connected pin on net {}.",
227+
net_->getName());
228+
}
224229
visited[foundPinIndex] = true;
225230
numDetached -= 1;
226231

@@ -266,7 +271,13 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
266271
if (!lastNode || !temp->prev) {
267272
// Both the start and the end of the path should contain pins
268273
const int pinIndex = graph_.getVertexPin(temp->vertex);
269-
assert(pinIndex != -1);
274+
if (pinIndex == -1) {
275+
logger_->error(utl::GRT,
276+
284,
277+
"Pin index not found for vertex {} on net {}.",
278+
temp->vertex,
279+
net_->getName());
280+
}
270281
node->setFixedLayers(graph_.getPseudoPin(pinIndex).layers);
271282
}
272283
lastNode = std::move(node);
@@ -279,7 +290,13 @@ std::shared_ptr<SteinerTreeNode> MazeRoute::getSteinerTree() const
279290
}
280291
}
281292
}
282-
assert(tree);
293+
294+
if (tree == nullptr) {
295+
logger_->error(utl::GRT,
296+
285,
297+
"Steiner tree construction failed for net {}.",
298+
net_->getName());
299+
}
283300

284301
// Remove redundant tree nodes
285302
SteinerTreeNode::preorder(

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,12 @@ std::shared_ptr<GRTreeNode> PatternRoute::getRoutingTree(
640640
}
641641
}
642642
assert(parentLayerIndex >= 0);
643+
if (parentLayerIndex < 0) {
644+
logger_->error(utl::GRT,
645+
286,
646+
"Failed to determine parent layer index on net {}.",
647+
net_->getName());
648+
}
643649
std::shared_ptr<GRTreeNode> routingNode
644650
= std::make_shared<GRTreeNode>(parentLayerIndex, node->x(), node->y());
645651
std::shared_ptr<GRTreeNode> lowestRoutingNode = routingNode;

src/grt/src/fastroute/include/DataType.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct Segment // A Segment is a 2-pin connection
6060
y1(y1),
6161
x2(x2),
6262
y2(y2),
63+
Zpoint(-1),
6364
cost(cost),
6465
xFirst(false),
6566
HVH(false)
@@ -174,8 +175,8 @@ struct TreeNode
174175
int nbr_count = 0;
175176
int nbr[3]; // three neighbors
176177
int edge[3]; // three adjacent edges
177-
int hID;
178-
int lID;
178+
int hID = -1;
179+
int lID = -1;
179180
// If two nodes are at the same x & y then the duplicate will have
180181
// stackAlias set to the index of the first node. This does not
181182
// apply to pins nodes, only Steiner nodes.
@@ -219,7 +220,7 @@ struct TreeEdge
219220
{
220221
bool assigned;
221222

222-
int len; // the Manhanttan Distance for two end nodes
223+
int len = 0; // the Manhanttan Distance for two end nodes
223224
int n1, n1a;
224225
int n2, n2a;
225226
Route route;

src/grt/src/fastroute/include/Graph2D.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ class Graph2D
122122
std::vector<int> getMultipleCongestedNDRnet();
123123

124124
private:
125-
int x_grid_;
126-
int y_grid_;
127-
int num_layers_;
125+
int x_grid_ = 0;
126+
int y_grid_ = 0;
127+
int num_layers_ = 0;
128128
std::set<std::string> congestion_nets_;
129129

130130
void updateCongList(const std::string& net_name, double edge_cost);
@@ -156,7 +156,7 @@ class Graph2D
156156
h_ndr_nets_; // The way it is indexed is (X, Y)
157157
std::vector<NDRCongestion> congested_ndrs_;
158158

159-
utl::Logger* logger_;
159+
utl::Logger* logger_ = nullptr;
160160

161161
std::set<std::pair<int, int>> h_used_ggrid_;
162162
std::set<std::pair<int, int>> v_used_ggrid_;

src/grt/src/fastroute/src/utility.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void FastRouteCore::ensurePinCoverage()
393393

394394
TreeEdge new_edge;
395395
new_edge.assigned = true;
396-
new_edge.route = via_route;
396+
new_edge.route = std::move(via_route);
397397
treeedges.emplace_back(new_edge);
398398
}
399399
}
@@ -2876,7 +2876,7 @@ int FastRouteCore::splitEdge(std::vector<TreeEdge>& treeedges,
28762876
new_node.edge[1] = new_edge_id;
28772877
new_node.edge[2] = edge_n1n2;
28782878

2879-
treeedges.push_back(new_edge);
2879+
treeedges.push_back(std::move(new_edge));
28802880
treenodes.push_back(new_node);
28812881

28822882
return new_node_id;

src/ppl/src/IOPlacer.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ void IOPlacer::findSections(int begin,
10041004
n_sec.used_slots = 0;
10051005
n_sec.edge = edge;
10061006

1007-
sections.push_back(n_sec);
1007+
sections.push_back(std::move(n_sec));
10081008
begin = ++end_slot;
10091009
}
10101010
}
@@ -3023,14 +3023,16 @@ void IOPlacer::filterObstructedSlotsForTopLayer()
30233023

30243024
// check for slots that go beyond the die boundary
30253025
odb::Rect die_area = getBlock()->getDieArea();
3026-
for (auto& slot : top_layer_slots_) {
3027-
odb::Point& point = slot.pos;
3028-
if (point.x() - top_grid_->pin_width / 2 < die_area.xMin()
3029-
|| point.y() - top_grid_->pin_height / 2 < die_area.yMin()
3030-
|| point.x() + top_grid_->pin_width / 2 > die_area.xMax()
3031-
|| point.y() + top_grid_->pin_height / 2 > die_area.yMax()) {
3032-
// mark slot as blocked since it extends beyond the die area
3033-
slot.blocked = true;
3026+
if (top_grid_ != nullptr) {
3027+
for (auto& slot : top_layer_slots_) {
3028+
odb::Point& point = slot.pos;
3029+
if (point.x() - top_grid_->pin_width / 2 < die_area.xMin()
3030+
|| point.y() - top_grid_->pin_height / 2 < die_area.yMin()
3031+
|| point.x() + top_grid_->pin_width / 2 > die_area.xMax()
3032+
|| point.y() + top_grid_->pin_height / 2 > die_area.yMax()) {
3033+
// mark slot as blocked since it extends beyond the die area
3034+
slot.blocked = true;
3035+
}
30343036
}
30353037
}
30363038

@@ -3102,7 +3104,7 @@ std::vector<Section> IOPlacer::findSectionsForTopLayer(const odb::Rect& region)
31023104
n_sec.used_slots = 0;
31033105
n_sec.edge = Edge::invalid;
31043106

3105-
sections.push_back(n_sec);
3107+
sections.push_back(std::move(n_sec));
31063108
edge_begin = ++end_slot;
31073109
}
31083110
}

0 commit comments

Comments
 (0)