Skip to content

Commit 3fd4e08

Browse files
authored
Merge pull request #8045 from The-OpenROAD-Project-staging/secure-jhkim-trivial
Fixed coverity CID 1620019 issue.
2 parents 6d5aa6b + e18e624 commit 3fd4e08

File tree

5 files changed

+33
-17
lines changed

5 files changed

+33
-17
lines changed

src/rsz/src/Rebuffer.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "Rebuffer.hh"
55

6+
#include <limits>
67
#include <memory>
78

89
#include "BufferMove.hh"
@@ -2009,10 +2010,14 @@ void Rebuffer::printProgress(int iteration,
20092010
if (iteration % print_interval_ == 0 || force || end) {
20102011
const double design_area = resizer_->computeDesignArea();
20112012
const double area_growth = design_area - initial_design_area_;
2013+
double area_growth_percent = std::numeric_limits<double>::infinity();
2014+
if (std::abs(initial_design_area_) > 0.0) {
2015+
area_growth_percent = area_growth / initial_design_area_ * 100.0;
2016+
}
20122017

20132018
logger_->report("{: >9s} | {: >+8.1f}% | {: >7d} | {: >8d} | {: >9d}",
20142019
end ? "final" : std::to_string(iteration),
2015-
area_growth / initial_design_area_ * 1e2,
2020+
area_growth_percent,
20162021
removed_count_,
20172022
inserted_count_,
20182023
remaining);

src/rsz/src/Rebuffer.hh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,27 @@ class Rebuffer : public sta::dbStaState
139139

140140
Logger* logger_ = nullptr;
141141
dbNetwork* db_network_ = nullptr;
142-
Resizer* resizer_;
143-
est::EstimateParasitics* estimate_parasitics_;
142+
Resizer* resizer_ = nullptr;
143+
est::EstimateParasitics* estimate_parasitics_ = nullptr;
144144

145145
std::vector<BufferSize> buffer_sizes_;
146146
std::map<LibertyCell*, BufferSize*> buffer_sizes_index_;
147147

148-
Pin* pin_;
149-
float fanout_limit_;
150-
float drvr_pin_max_slew_;
151-
float drvr_load_high_water_mark_;
148+
Pin* pin_ = nullptr;
149+
float fanout_limit_ = 0.0f;
150+
float drvr_pin_max_slew_ = 0.0f;
151+
float drvr_load_high_water_mark_ = 0.0f;
152152
const Corner* corner_ = nullptr;
153153
LibertyPort* drvr_port_ = nullptr;
154-
Path* arrival_paths_[RiseFall::index_count];
154+
Path* arrival_paths_[RiseFall::index_count] = {nullptr};
155155

156-
int resizer_max_wire_length_;
157-
int wire_length_step_;
156+
int resizer_max_wire_length_ = 0;
157+
int wire_length_step_ = 0;
158158

159-
double initial_design_area_;
160-
int print_interval_;
161-
int removed_count_;
162-
int inserted_count_;
159+
double initial_design_area_ = 0.0;
160+
int print_interval_ = 0;
161+
int removed_count_ = 0;
162+
int inserted_count_ = 0;
163163

164164
// margins in percent
165165
float slew_margin_ = 20.0f;

src/rsz/src/RecoverPower.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "RecoverPower.hh"
55

66
#include <algorithm>
7+
#include <limits>
78
#include <string>
89

910
#include "db_sta/dbNetwork.hh"
@@ -470,11 +471,15 @@ void RecoverPower::printProgress(int iteration, bool force, bool end) const
470471

471472
const double design_area = resizer_->computeDesignArea();
472473
const double area_growth = design_area - initial_design_area_;
474+
double area_growth_percent = std::numeric_limits<double>::infinity();
475+
if (std::abs(initial_design_area_) > 0.0) {
476+
area_growth_percent = area_growth / initial_design_area_ * 100.0;
477+
}
473478

474479
logger_->report(
475480
"{: >9s} | {: >+8.1f}% | {: >8d} | {: >8s} | {}",
476481
itr_field,
477-
area_growth / initial_design_area_ * 1e2,
482+
area_growth_percent,
478483
resize_count_,
479484
delayAsString(wns, sta_, 3),
480485
worst_vertex != nullptr ? worst_vertex->name(network_) : "");

src/rsz/src/RepairSetup.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <algorithm>
77
#include <cmath>
88
#include <cstddef>
9+
#include <limits>
910
#include <memory>
1011
#include <optional>
1112
#include <sstream>
@@ -740,6 +741,10 @@ void RepairSetup::printProgress(const int iteration,
740741

741742
const double design_area = resizer_->computeDesignArea();
742743
const double area_growth = design_area - initial_design_area_;
744+
double area_growth_percent = std::numeric_limits<double>::infinity();
745+
if (std::abs(initial_design_area_) > 0.0) {
746+
area_growth_percent = area_growth / initial_design_area_ * 100.0;
747+
}
743748

744749
// This actually prints both committed and pending moves, so the moves could
745750
// could go down if a pass is rejected and restored by the ECO.
@@ -754,7 +759,7 @@ void RepairSetup::printProgress(const int iteration,
754759
+ resizer_->split_load_move_->numMoves(),
755760
resizer_->clone_move_->numMoves(),
756761
resizer_->swap_pins_move_->numMoves(),
757-
area_growth / initial_design_area_ * 1e2,
762+
area_growth_percent,
758763
delayAsString(wns, sta_, 3),
759764
delayAsString(tns, sta_, 1),
760765
max(0, num_viols),

src/rsz/src/UnbufferMove.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ bool UnbufferMove::canRemoveBuffer(Instance* buffer, bool honorDontTouchFixed)
342342
if (!sdc_->isConstrained(in_pin) && !sdc_->isConstrained(out_pin)
343343
&& (!removed || !sdc_->isConstrained(removed))
344344
&& !sdc_->isConstrained(buffer)) {
345-
return !db_net_removed || db_net_survivor->canMergeNet(db_net_removed);
345+
return db_net_removed == nullptr
346+
|| (db_net_survivor && db_net_survivor->canMergeNet(db_net_removed));
346347
}
347348
return false;
348349
}

0 commit comments

Comments
 (0)