Skip to content

Commit 5a85aa3

Browse files
authored
Coverity Fixes (#12843)
* Fix Coverity CID 1644785: COPY_INSTEAD_OF_MOVE in conditions.cc Use std::move() when assigning sub_qual to _query_param since sub_qual is not used after the assignment. * Fix Coverity suppression comments for CID 1644338, 1644327, 1644312 These issues were already addressed in PR #12821 but Coverity did not recognize the suppression comments due to incorrect tags or placement. CID 1644338 (UNCAUGHT_EXCEPT in Stripe.cc): - Changed tag from fun_call_w_exception to exn_spec_violation - Moved comment before destructor definition (line 173) where Coverity reports the root_function event CID 1644327 (UNCAUGHT_EXCEPT in test_AIO.cc): - Changed tag from fun_call_w_exception to exn_spec_violation - Moved comment before main() definition (line 460) where Coverity reports the root_function event CID 1644312 (RESOURCE_LEAK in test_HeaderValidator.cc): - Changed tag from resource_leak to leaked_storage - Moved comment from allocation site (line 59) to leak detection point (line 250) where Coverity reports the leaked_storage event
1 parent 074671f commit 5a85aa3

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

plugins/header_rewrite/conditions.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ ConditionUrl::set_qualifier(const std::string &q)
293293

294294
if (_url_qual == URL_QUAL_QUERY) {
295295
if (!sub_qual.empty()) {
296-
_query_param = sub_qual;
296+
_query_param = std::move(sub_qual);
297297
Dbg(pi_dbg_ctl, "\tQuery parameter sub-key: %s", _query_param.c_str());
298298
}
299299
} else {

src/iocore/aio/test_AIO.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,10 @@ class IOUringLoopTailHandler : public EThread::LoopTailHandler
456456

457457
#endif
458458

459+
// coverity[exn_spec_violation] - called functions may throw but this is a test program
459460
int
460461
main(int argc, char *argv[])
461462
{
462-
// coverity[fun_call_w_exception] - called functions may throw but this is a test program
463463
int i;
464464

465465
// Read the configuration file

src/iocore/cache/Stripe.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ Stripe::_init_directory(std::size_t directory_size, int header_size, int footer_
170170
this->directory.footer = reinterpret_cast<StripeHeaderFooter *>(this->directory.raw_dir + footer_offset);
171171
}
172172

173+
// coverity[exn_spec_violation] - ink_assert aborts (doesn't throw), Dbg is exception-safe
173174
Stripe::~Stripe()
174175
{
175176
if (this->directory.raw_dir != nullptr) {
176-
// coverity[fun_call_w_exception] - ink_assert aborts (doesn't throw), Dbg is exception-safe
177177
// Debug logging to track cleanup - helps correlate with crash location
178178
Dbg(dbg_ctl_cache_free, "Stripe %s: freeing raw_dir=%p size=%zu huge=%s", hash_text.get() ? hash_text.get() : "(null)",
179179
this->directory.raw_dir, this->directory.raw_dir_size, this->directory.raw_dir_huge ? "true" : "false");

src/proxy/hdrs/unit_tests/test_HeaderValidator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ TEST_CASE("testIsHeaderValid", "[proxy][hdrtest]")
5656
{
5757
HTTPHdr hdr;
5858
// extra to prevent proxy allocation.
59-
// coverity[resource_leak] - heap is freed via hdr.destroy() which calls
60-
// HdrHeapSDKHandle::destroy() -> m_heap->destroy()
6159
HdrHeap *heap = new_HdrHeap(HdrHeap::DEFAULT_SIZE + 64);
6260

6361
SECTION("Test (valid) request with 4 required pseudo headers")
@@ -249,4 +247,6 @@ TEST_CASE("testIsHeaderValid", "[proxy][hdrtest]")
249247
}
250248
// teardown
251249
hdr.destroy();
250+
// coverity[leaked_storage] - heap is freed via hdr.destroy() which calls
251+
// HdrHeapSDKHandle::destroy() -> m_heap->destroy()
252252
}

0 commit comments

Comments
 (0)