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

bneradt 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 15207bb347 clang-analyzer fixes for clang14 (#10055)
15207bb347 is described below

commit 15207bb3471b4f489ab3beff5757e4cc05b31167
Author: Brian Olsen <[email protected]>
AuthorDate: Wed Jul 19 22:32:53 2023 -0600

    clang-analyzer fixes for clang14 (#10055)
    
    * clang-analyzer fixes for clang14
    
    * rename NetEvent::free to NetEvent::free_thread for clang-analyzer's sake
    
    ---------
    
    Co-authored-by: Brian Olsen <[email protected]>
---
 iocore/net/NetEvent.h                    |  2 +-
 iocore/net/NetHandler.cc                 |  2 +-
 iocore/net/P_QUICNetVConnection_quiche.h |  2 +-
 iocore/net/P_SSLNetVConnection.h         |  2 +-
 iocore/net/P_UnixNetVConnection.h        |  2 +-
 iocore/net/QUICNetProcessor_quiche.cc    |  2 +-
 iocore/net/QUICNetVConnection.cc         | 10 +++++-----
 iocore/net/QUICNetVConnection_quiche.cc  |  6 +++---
 iocore/net/SSLNetVConnection.cc          |  2 +-
 iocore/net/UnixNetVConnection.cc         | 10 +++++-----
 proxy/http/HttpSM.cc                     |  6 +++---
 src/tscore/ArgParser.cc                  |  9 ++++++---
 src/tscore/Layout.cc                     |  3 ++-
 13 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/iocore/net/NetEvent.h b/iocore/net/NetEvent.h
index 552d9878e0..7043ec167a 100644
--- a/iocore/net/NetEvent.h
+++ b/iocore/net/NetEvent.h
@@ -41,7 +41,7 @@ public:
   virtual ~NetEvent() {}
   virtual void net_read_io(NetHandler *nh, EThread *lthread)  = 0;
   virtual void net_write_io(NetHandler *nh, EThread *lthread) = 0;
-  virtual void free(EThread *t)                               = 0;
+  virtual void free_thread(EThread *t)                        = 0;
 
   // since we want this class to be independent from VConnection, 
Continutaion. There should be
   // a pure virtual function which connect sub class and NetHandler.
diff --git a/iocore/net/NetHandler.cc b/iocore/net/NetHandler.cc
index 330463374d..b11820aee8 100644
--- a/iocore/net/NetHandler.cc
+++ b/iocore/net/NetHandler.cc
@@ -202,7 +202,7 @@ NetHandler::free_netevent(NetEvent *ne)
   // Release ne from NetHandler
   stopIO(ne);
   // Clear and deallocate ne
-  ne->free(t);
+  ne->free_thread(t);
 }
 
 //
diff --git a/iocore/net/P_QUICNetVConnection_quiche.h 
b/iocore/net/P_QUICNetVConnection_quiche.h
index a8832401bd..d83d789a2f 100644
--- a/iocore/net/P_QUICNetVConnection_quiche.h
+++ b/iocore/net/P_QUICNetVConnection_quiche.h
@@ -88,7 +88,7 @@ public:
   void set_local_addr() override;
 
   // NetEvent
-  void free(EThread *t) override;
+  void free_thread(EThread *t) override;
 
   // UnixNetVConnection
   void reenable(VIO *vio) override;
diff --git a/iocore/net/P_SSLNetVConnection.h b/iocore/net/P_SSLNetVConnection.h
index 9c138da4a0..74e68f32ef 100644
--- a/iocore/net/P_SSLNetVConnection.h
+++ b/iocore/net/P_SSLNetVConnection.h
@@ -112,7 +112,7 @@ class SSLNetVConnection : public UnixNetVConnection,
 public:
   int sslStartHandShake(int event, int &err) override;
   void clear() override;
-  void free(EThread *t) override;
+  void free_thread(EThread *t) override;
 
   bool
   trackFirstHandshake() override
diff --git a/iocore/net/P_UnixNetVConnection.h 
b/iocore/net/P_UnixNetVConnection.h
index fbc9747a85..1a21b0caa8 100644
--- a/iocore/net/P_UnixNetVConnection.h
+++ b/iocore/net/P_UnixNetVConnection.h
@@ -141,7 +141,7 @@ public:
   // NetEvent
   virtual void net_read_io(NetHandler *nh, EThread *lthread) override;
   virtual void net_write_io(NetHandler *nh, EThread *lthread) override;
-  virtual void free(EThread *t) override;
+  virtual void free_thread(EThread *t) override;
   virtual int
   close() override
   {
diff --git a/iocore/net/QUICNetProcessor_quiche.cc 
b/iocore/net/QUICNetProcessor_quiche.cc
index 741df02eb2..2326aac250 100644
--- a/iocore/net/QUICNetProcessor_quiche.cc
+++ b/iocore/net/QUICNetProcessor_quiche.cc
@@ -152,7 +152,7 @@ QUICNetProcessor::connect_re(Continuation *cont, sockaddr 
const *remote_addr, Ne
   Action *status;
   bool result = udpNet.CreateUDPSocket(&fd, remote_addr, &status, opt);
   if (!result) {
-    vc->free(t);
+    vc->free_thread(t);
     return status;
   }
 
diff --git a/iocore/net/QUICNetVConnection.cc b/iocore/net/QUICNetVConnection.cc
index 7b9e891a34..cd2282d31b 100644
--- a/iocore/net/QUICNetVConnection.cc
+++ b/iocore/net/QUICNetVConnection.cc
@@ -357,7 +357,7 @@ QUICNetVConnection::acceptEvent(int event, Event *e)
 
   // Send this NetVC to NetHandler and start to polling read & write event.
   if (h->startIO(this) < 0) {
-    free(t);
+    this->free_thread(t);
     return EVENT_DONE;
   }
 
@@ -397,7 +397,7 @@ QUICNetVConnection::startEvent(int event, Event *e)
   if (!action_.cancelled) {
     this->connectUp(e->ethread, NO_FD);
   } else {
-    this->free(e->ethread);
+    this->free_thread(e->ethread);
   }
 
   return EVENT_DONE;
@@ -486,7 +486,7 @@ QUICNetVConnection::start()
 }
 
 void
-QUICNetVConnection::free(EThread *t)
+QUICNetVConnection::free_thread(EThread *t)
 {
   QUICConDebug("Free connection");
 
@@ -519,7 +519,7 @@ QUICNetVConnection::free(EThread *t)
 void
 QUICNetVConnection::free()
 {
-  this->free(this_ethread());
+  this->free_thread(this_ethread());
 }
 
 // called by ET_UDP
@@ -1013,7 +1013,7 @@ QUICNetVConnection::state_connection_closed(int event, 
Event *data)
     if (this->nh) {
       this->nh->free_netevent(this);
     } else {
-      this->free(this->mutex->thread_holding);
+      this->free_thread(this->mutex->thread_holding);
     }
     break;
   }
diff --git a/iocore/net/QUICNetVConnection_quiche.cc 
b/iocore/net/QUICNetVConnection_quiche.cc
index 321e356980..143a4cbf24 100644
--- a/iocore/net/QUICNetVConnection_quiche.cc
+++ b/iocore/net/QUICNetVConnection_quiche.cc
@@ -81,7 +81,7 @@ QUICNetVConnection::init(QUICVersion version, 
QUICConnectionId peer_cid, QUICCon
 void
 QUICNetVConnection::free()
 {
-  this->free(this_ethread());
+  this->free_thread(this_ethread());
 }
 
 // called by ET_UDP
@@ -112,7 +112,7 @@ QUICNetVConnection::set_local_addr()
 }
 
 void
-QUICNetVConnection::free(EThread *t)
+QUICNetVConnection::free_thread(EThread *t)
 {
   QUICConDebug("Free connection");
 
@@ -296,7 +296,7 @@ QUICNetVConnection::acceptEvent(int event, Event *e)
 
   // Send this NetVC to NetHandler and start to polling read & write event.
   if (h->startIO(this) < 0) {
-    free(t);
+    this->free_thread(t);
     return EVENT_DONE;
   }
 
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index 376969af06..cc79701e79 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -964,7 +964,7 @@ SSLNetVConnection::clear()
   super::clear();
 }
 void
-SSLNetVConnection::free(EThread *t)
+SSLNetVConnection::free_thread(EThread *t)
 {
   ink_release_assert(t == this_ethread());
 
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index 842a8b98b5..132106df88 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -641,7 +641,7 @@ UnixNetVConnection::do_io_close(int alerrno /* = -1 */)
   // FIXME: the nh must not nullptr.
   ink_assert(nh);
 
-  // The vio continuations will be cleared in ::clear called from ::free
+  // The vio continuations will be cleared in ::clear called from ::free_thread
   read.enabled    = 0;
   write.enabled   = 0;
   read.vio.nbytes = 0;
@@ -680,7 +680,7 @@ UnixNetVConnection::do_io_close(int alerrno /* = -1 */)
     if (nh) {
       nh->free_netevent(this);
     } else {
-      this->free(t);
+      this->free_thread(t);
     }
   }
 }
@@ -1021,7 +1021,7 @@ UnixNetVConnection::acceptEvent(int event, Event *e)
 
   // Send this NetVC to NetHandler and start to polling read & write event.
   if (h->startIO(this) < 0) {
-    free(t);
+    this->free_thread(t);
     return EVENT_DONE;
   }
 
@@ -1239,7 +1239,7 @@ fail:
   if (nullptr != nh) {
     nh->free_netevent(this);
   } else {
-    this->free(t);
+    this->free_thread(t);
   }
   return CONNECT_FAILURE;
 }
@@ -1286,7 +1286,7 @@ UnixNetVConnection::clear()
 }
 
 void
-UnixNetVConnection::free(EThread *t)
+UnixNetVConnection::free_thread(EThread *t)
 {
   ink_release_assert(t == this_ethread());
 
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 514311575d..48f3eb0e6e 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -8260,13 +8260,13 @@ HttpSM::redirect_request(const char *arg_redirect_url, 
const int arg_redirect_le
       // The redirect URL did not begin with a slash, so we parsed some or all
       // of the relative URI path as the host.
       // Prepend a slash and parse again.
-      char redirect_url_leading_slash[arg_redirect_len + 1];
+      std::string redirect_url_leading_slash(arg_redirect_len + 1, '\0');
       redirect_url_leading_slash[0] = '/';
       if (arg_redirect_len > 0) {
-        memcpy(redirect_url_leading_slash + 1, arg_redirect_url, 
arg_redirect_len);
+        memcpy(redirect_url_leading_slash.data() + 1, arg_redirect_url, 
arg_redirect_len);
       }
       url_nuke_proxy_stuff(redirectUrl.m_url_impl);
-      redirectUrl.parse(redirect_url_leading_slash, arg_redirect_len + 1);
+      redirectUrl.parse(redirect_url_leading_slash.c_str(), arg_redirect_len + 
1);
     }
   }
 
diff --git a/src/tscore/ArgParser.cc b/src/tscore/ArgParser.cc
index d37ec1382a..a8b177f73e 100644
--- a/src/tscore/ArgParser.cc
+++ b/src/tscore/ArgParser.cc
@@ -429,7 +429,8 @@ ArgParser::Command::append_option_data(Arguments &ret, 
AP_StrVec &args, int inde
         ArgParser::Option cur_option = it->second;
         // handle environment variable
         if (!cur_option.envvar.empty()) {
-          ret.set_env(cur_option.key, getenv(cur_option.envvar.c_str()) ? 
getenv(cur_option.envvar.c_str()) : "");
+          const char *const env = getenv(cur_option.envvar.c_str());
+          ret.set_env(cur_option.key, nullptr != env ? env : "");
         }
         ret.append_arg(cur_option.key, value);
         check_map[cur_option.long_option] += 1;
@@ -473,7 +474,8 @@ ArgParser::Command::append_option_data(Arguments &ret, 
AP_StrVec &args, int inde
         }
         // handle environment variable
         if (!cur_option.envvar.empty()) {
-          ret.set_env(cur_option.key, getenv(cur_option.envvar.c_str()) ? 
getenv(cur_option.envvar.c_str()) : "");
+          const char *const env = getenv(cur_option.envvar.c_str());
+          ret.set_env(cur_option.key, nullptr != env ? env : "");
         }
       }
     }
@@ -518,7 +520,8 @@ ArgParser::Command::parse(Arguments &ret, AP_StrVec &args)
       }
       // set ENV var
       if (!_envvar.empty()) {
-        ret.set_env(_key, getenv(_envvar.c_str()) ? getenv(_envvar.c_str()) : 
"");
+        const char *const env = getenv(_envvar.c_str());
+        ret.set_env(_key, nullptr != env ? env : "");
       }
       break;
     }
diff --git a/src/tscore/Layout.cc b/src/tscore/Layout.cc
index 795d0fa17c..04fcd4d276 100644
--- a/src/tscore/Layout.cc
+++ b/src/tscore/Layout.cc
@@ -155,7 +155,8 @@ Layout::Layout(std::string_view const _prefix)
     std::string path;
     int len;
     if (getenv("TS_ROOT") != nullptr) {
-      std::string env_path(getenv("TS_ROOT"));
+      const char *const env = getenv("TS_ROOT");
+      std::string env_path(nullptr != env ? env : "");
       len = env_path.size();
       if ((len + 1) > PATH_NAME_MAX) {
         ink_fatal("TS_ROOT environment variable is too big: %d, max %d\n", 
len, PATH_NAME_MAX - 1);

Reply via email to