Skip to content

Commit 6928ef6

Browse files
committed
Fixed coverity issues
Signed-off-by: Jaehyun Kim <[email protected]>
1 parent a5c2f65 commit 6928ef6

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/rsz/test/cpp/TestBufferRemoval3.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ endmodule
100100
}
101101

102102
// Clean up
103-
std::remove(after_vlog_path.c_str());
103+
removeFile(after_vlog_path);
104104
}
105105

106106
TEST_F(BufRemTest3, RemoveBufferCase5)
@@ -167,7 +167,7 @@ endmodule
167167
}
168168

169169
// Clean up
170-
std::remove(after_vlog_path.c_str());
170+
removeFile(after_vlog_path);
171171
}
172172

173173
TEST_F(BufRemTest3, RemoveBufferCase4)
@@ -295,7 +295,7 @@ endmodule
295295
}
296296

297297
// Clean up
298-
std::remove(after_vlog_path.c_str());
298+
removeFile(after_vlog_path);
299299
}
300300

301301
TEST_F(BufRemTest3, RemoveBufferCase3)
@@ -383,7 +383,7 @@ endmodule
383383
}
384384

385385
// Clean up
386-
std::remove(after_vlog_path.c_str());
386+
removeFile(after_vlog_path);
387387
}
388388

389389
TEST_F(BufRemTest3, RemoveBufferCase2)
@@ -460,7 +460,7 @@ endmodule
460460
}
461461

462462
// Clean up
463-
std::remove(after_vlog_path.c_str());
463+
removeFile(after_vlog_path);
464464
}
465465

466466
TEST_F(BufRemTest3, RemoveBufferCase1)
@@ -541,7 +541,7 @@ endmodule
541541
}
542542

543543
// Clean up
544-
std::remove(after_vlog_path.c_str());
544+
removeFile(after_vlog_path);
545545
}
546546

547547
TEST_F(BufRemTest3, RemoveBufferCase0)
@@ -629,7 +629,7 @@ endmodule
629629
}
630630

631631
// Clean up
632-
std::remove(after_vlog_path.c_str());
632+
removeFile(after_vlog_path);
633633
}
634634

635635
} // namespace rsz

src/tst/include/tst/IntegratedFixture.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class IntegratedFixture : public tst::Fixture
3232
protected:
3333
void readVerilogAndSetup(const std::string& verilog_file);
3434
void dumpVerilogAndOdb(const std::string& name) const;
35+
void removeFile(const std::string& path);
3536

3637
protected:
3738
odb::dbLib* lib_;

src/tst/src/IntegratedFixture.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,15 @@ void IntegratedFixture::readVerilogAndSetup(const std::string& verilog_file)
8989
sta::Pin* clk_pin
9090
= db_network_->findPin(db_network_->topInstance(), clk_port);
9191

92+
// STA frees the 'clk_pins' after use.
93+
// coverity[RESOURCE_LEAK: FALSE_POSITIVE]
9294
sta::PinSet* clk_pins = new sta::PinSet(db_network_);
9395
clk_pins->insert(clk_pin);
9496

9597
// Clock period = 0.5ns
9698
double period = sta_->units()->timeUnit()->userToSta(0.5);
99+
// STA takes the ownership of 'waveform'.
100+
// coverity[RESOURCE_LEAK: FALSE_POSITIVE]
97101
sta::FloatSeq* waveform = new sta::FloatSeq;
98102
waveform->push_back(0);
99103
waveform->push_back(period / 2.0);
@@ -164,4 +168,11 @@ void IntegratedFixture::dumpVerilogAndOdb(const std::string& name) const
164168
orig_odb_file.close();
165169
}
166170

171+
void IntegratedFixture::removeFile(const std::string& path)
172+
{
173+
if (std::remove(path.c_str()) != 0) {
174+
logger_.warn(utl::RSZ, 0, "Could not remove '{}'.", path);
175+
}
176+
}
177+
167178
} // namespace tst

0 commit comments

Comments
 (0)