This is an automated email from the ASF dual-hosted git repository.

dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 416f6ed341 Coverity: Some fixes. (#11982)
416f6ed341 is described below

commit 416f6ed3412aabb9a1c882f3b53175dcc73ef128
Author: Damian Meden <[email protected]>
AuthorDate: Mon Jan 27 09:46:00 2025 +0100

    Coverity: Some fixes. (#11982)
    
    * Coverity: Fix for CID-1528633 and CID-1523681
    
    * CID-1544434 - Unchecked return value
    
    * CID-1544425 Use of auto that causes a copy
---
 src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc | 4 ++--
 src/proxy/http/remap/unit-tests/test_PluginFactory.cc     | 4 ++--
 src/tscore/unit_tests/test_Ptr.cc                         | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc 
b/src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
index aef2a1f36d..e26c8ec721 100644
--- a/src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
+++ b/src/proxy/http/remap/unit-tests/test_NextHopRoundRobin.cc
@@ -248,10 +248,10 @@ SCENARIO("Testing NextHopRoundRobin class, using policy 
'rr-ip'", "[NextHopRound
     sockaddr_in sa2 = {};
     sa1.sin_port    = 10000;
     sa1.sin_family  = AF_INET;
-    inet_pton(AF_INET, "192.168.1.1", &(sa1.sin_addr));
+    REQUIRE(inet_pton(AF_INET, "192.168.1.1", &(sa1.sin_addr)) == 1);
     sa2.sin_port   = 10001;
     sa2.sin_family = AF_INET;
-    inet_pton(AF_INET, "192.168.1.2", &(sa2.sin_addr));
+    REQUIRE(inet_pton(AF_INET, "192.168.1.2", &(sa2.sin_addr)) == 1);
     HttpSM        sm;
     ParentResult *result = &sm.t_state.parent_result;
     TSHttpTxn     txnp   = reinterpret_cast<TSHttpTxn>(&sm);
diff --git a/src/proxy/http/remap/unit-tests/test_PluginFactory.cc 
b/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
index 6997da4d34..ff78963e5e 100644
--- a/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
+++ b/src/proxy/http/remap/unit-tests/test_PluginFactory.cc
@@ -468,7 +468,7 @@ SCENARIO("multiple search dirs + multiple or no plugins 
installed", "[plugin][co
 
     std::string error;
 
-    for (auto searchDir : searchDirs) {
+    for (auto const &searchDir : searchDirs) {
       CHECK(fs::create_directories(searchDir, ec));
       fs::copy(pluginBuildPath, searchDir, ec);
     }
@@ -477,7 +477,7 @@ SCENARIO("multiple search dirs + multiple or no plugins 
installed", "[plugin][co
     /* Instantiate and initialize a plugin DSO instance. */
     PluginFactoryUnitTest factory(tempComponent);
     factory.setRuntimeDir(runtimeRootDir);
-    for (auto searchDir : searchDirs) {
+    for (auto const &searchDir : searchDirs) {
       factory.addSearchDir(searchDir);
     }
 
diff --git a/src/tscore/unit_tests/test_Ptr.cc 
b/src/tscore/unit_tests/test_Ptr.cc
index cfa721df36..79ef8313f5 100644
--- a/src/tscore/unit_tests/test_Ptr.cc
+++ b/src/tscore/unit_tests/test_Ptr.cc
@@ -49,7 +49,7 @@ TEST_CASE("Ptr", "[libts][ptr]")
   REQUIRE(p1->refcount() == 3);
   p3 = nullptr; // clear ref drops ref count.
   REQUIRE(p1->refcount() == 2);
-  p2->refcount_dec();
+  REQUIRE(p2->refcount_dec() == 1);
   delete p1.detach();
   // If that doesn't work, the subsequent alive counts will be off.
 
@@ -72,7 +72,7 @@ TEST_CASE("Ptr", "[libts][ptr]")
     Ptr<PtrObject> pn2(pn1);
     REQUIRE(pn1->refcount() == 2);
 
-    Ptr<PtrObject> pn3 = p1;
+    Ptr<PtrObject> pn3 = std::move(p1);
   }
 
   // Everything goes out of scope, so the refcounts should drop to zero.

Reply via email to