You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2019/04/16 00:31:34 UTC

[trafficserver] branch master updated: Ran CPP check on a few files while prodding around

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

zwoop 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 af308e5  Ran CPP check on a few files while prodding around
af308e5 is described below

commit af308e54db7f18cdb92dd4700bdff37af97ea45e
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Tue Mar 26 21:21:26 2019 +0100

    Ran CPP check on a few files while prodding around
    
    Another example of some of the changes it recommends, I think
    it would be useful to try to work on getting us CPPCheck "free".
---
 proxy/IPAllow.h            |   6 +--
 proxy/InkAPIInternal.h     |  23 ++++------
 proxy/hdrs/HTTP.h          |   2 +-
 proxy/hdrs/HdrToken.h      |   3 +-
 proxy/hdrs/MIME.h          | 108 +++++++++++++++++++++++----------------------
 proxy/http/HttpSM.cc       |  61 ++++++++++++-------------
 proxy/http/HttpSM.h        |   2 +-
 proxy/http/HttpTunnel.h    |   5 ++-
 proxy/logging/Log.cc       |  25 ++++++-----
 proxy/logging/Log.h        |   2 +-
 proxy/logging/LogAccess.cc |   7 ++-
 proxy/logging/LogAccess.h  |   2 +-
 proxy/logging/LogField.h   |   2 +-
 proxy/logging/LogObject.h  |   4 +-
 proxy/logging/LogSock.h    |   2 +-
 15 files changed, 125 insertions(+), 129 deletions(-)

diff --git a/proxy/IPAllow.h b/proxy/IPAllow.h
index 2fedf29..112d977 100644
--- a/proxy/IPAllow.h
+++ b/proxy/IPAllow.h
@@ -98,8 +98,8 @@ public:
     using self_type = ACL; ///< Self reference type.
   public:
     ACL()                  = default;
-    ACL(const self_type &) = delete; // no copies.
-    ACL(self_type &&that) noexcept;  // move allowed.
+    ACL(const self_type &) = delete;         // no copies.
+    explicit ACL(self_type &&that) noexcept; // move allowed.
     ~ACL();
 
     self_type &operator=(const self_type &) = delete;
@@ -131,7 +131,7 @@ public:
     IpAllow *_config{nullptr}; ///< The backing configuration.
   };
 
-  IpAllow(const char *config_var);
+  explicit IpAllow(const char *config_var);
 
   void Print();
 
diff --git a/proxy/InkAPIInternal.h b/proxy/InkAPIInternal.h
index ee516e2..17ba528 100644
--- a/proxy/InkAPIInternal.h
+++ b/proxy/InkAPIInternal.h
@@ -53,20 +53,13 @@ enum CacheInfoMagic {
 
 struct CacheInfo {
   CryptoHash cache_key;
-  CacheFragType frag_type;
-  char *hostname;
-  int len;
-  time_t pin_in_cache;
-  CacheInfoMagic magic;
+  CacheFragType frag_type = CACHE_FRAG_TYPE_NONE;
+  char *hostname          = nullptr;
+  int len                 = 0;
+  time_t pin_in_cache     = 0;
+  CacheInfoMagic magic    = CACHE_INFO_MAGIC_ALIVE;
 
-  CacheInfo()
-  {
-    frag_type    = CACHE_FRAG_TYPE_NONE;
-    hostname     = nullptr;
-    len          = 0;
-    pin_in_cache = 0;
-    magic        = CACHE_INFO_MAGIC_ALIVE;
-  }
+  CacheInfo() {}
 };
 
 class FileImpl
@@ -268,7 +261,7 @@ class HttpAPIHooks : public FeatureAPIHooks<TSHttpHookID, TS_HTTP_LAST_HOOK>
 class TSSslHookInternalID
 {
 public:
-  constexpr TSSslHookInternalID(TSHttpHookID id) : _id(id - TS_SSL_FIRST_HOOK) {}
+  explicit constexpr TSSslHookInternalID(TSHttpHookID id) : _id(id - TS_SSL_FIRST_HOOK) {}
 
   constexpr operator int() const { return _id; }
 
@@ -295,7 +288,7 @@ class LifecycleAPIHooks : public FeatureAPIHooks<TSLifecycleHookID, TS_LIFECYCLE
 class ConfigUpdateCallback : public Continuation
 {
 public:
-  ConfigUpdateCallback(INKContInternal *contp) : Continuation(contp->mutex.get()), m_cont(contp)
+  explicit ConfigUpdateCallback(INKContInternal *contp) : Continuation(contp->mutex.get()), m_cont(contp)
   {
     SET_HANDLER(&ConfigUpdateCallback::event_handler);
   }
diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h
index 94e1a10..8636cf9 100644
--- a/proxy/hdrs/HTTP.h
+++ b/proxy/hdrs/HTTP.h
@@ -1236,7 +1236,7 @@ HTTPHdr::is_cache_control_set(const char *cc_directive_wks)
   ink_assert(valid());
   ink_assert(hdrtoken_is_wks(cc_directive_wks));
 
-  HdrTokenHeapPrefix *prefix = hdrtoken_wks_to_prefix(cc_directive_wks);
+  const HdrTokenHeapPrefix *prefix = hdrtoken_wks_to_prefix(cc_directive_wks);
   ink_assert(prefix->wks_token_type == HDRTOKEN_TYPE_CACHE_CONTROL);
 
   uint32_t cc_mask = prefix->wks_type_specific.u.cache_control.cc_mask;
diff --git a/proxy/hdrs/HdrToken.h b/proxy/hdrs/HdrToken.h
index ab5f4fb..8a50a16 100644
--- a/proxy/hdrs/HdrToken.h
+++ b/proxy/hdrs/HdrToken.h
@@ -137,11 +137,12 @@ hdrtoken_is_valid_wks_idx(int wks_idx)
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
+// ToDo: This, and dependencies / users should probalby be const HdrTokenHeapPrefix * IMO.
 inline HdrTokenHeapPrefix *
 hdrtoken_wks_to_prefix(const char *wks)
 {
   ink_assert(hdrtoken_is_wks(wks));
-  return ((HdrTokenHeapPrefix *)(wks - sizeof(HdrTokenHeapPrefix)));
+  return reinterpret_cast<HdrTokenHeapPrefix *>(const_cast<char *>(wks) - sizeof(HdrTokenHeapPrefix));
 }
 
 /*-------------------------------------------------------------------------
diff --git a/proxy/hdrs/MIME.h b/proxy/hdrs/MIME.h
index 311b5cc..6ff23f7 100644
--- a/proxy/hdrs/MIME.h
+++ b/proxy/hdrs/MIME.h
@@ -117,7 +117,7 @@ struct MIMEField {
   bool
   is_cooked()
   {
-    return (m_flags & MIME_FIELD_SLOT_FLAGS_COOKED);
+    return (m_flags & MIME_FIELD_SLOT_FLAGS_COOKED) ? true : false;
   }
 
   bool
@@ -135,10 +135,10 @@ struct MIMEField {
   bool
   supports_commas() const
   {
-    if (m_wks_idx >= 0)
+    if (m_wks_idx >= 0) {
       return (hdrtoken_index_to_flags(m_wks_idx) & MIME_FLAGS_COMMAS);
-    else
-      return true; // by default, assume supports commas
+    }
+    return true; // by default, assume supports commas
   }
 
   /// @return The name of @a this field.
@@ -814,11 +814,10 @@ MIMEField::name_get(int *length) const
 inline void
 MIMEField::name_set(HdrHeap *heap, MIMEHdrImpl *mh, const char *name, int length)
 {
-  int16_t name_wks_idx;
   const char *name_wks;
 
   if (hdrtoken_is_wks(name)) {
-    name_wks_idx = hdrtoken_wks_to_index(name);
+    int16_t name_wks_idx = hdrtoken_wks_to_index(name);
     mime_field_name_set(heap, mh, this, name_wks_idx, name, length, true);
   } else {
     int field_name_wks_idx = hdrtoken_tokenize(name, length, &name_wks);
@@ -857,31 +856,31 @@ MIMEField::value_get(int *length) const
 inline int32_t
 MIMEField::value_get_int() const
 {
-  return (mime_field_value_get_int(this));
+  return mime_field_value_get_int(this);
 }
 
 inline uint32_t
 MIMEField::value_get_uint() const
 {
-  return (mime_field_value_get_uint(this));
+  return mime_field_value_get_uint(this);
 }
 
 inline int64_t
 MIMEField::value_get_int64() const
 {
-  return (mime_field_value_get_int64(this));
+  return mime_field_value_get_int64(this);
 }
 
 inline time_t
 MIMEField::value_get_date() const
 {
-  return (mime_field_value_get_date(this));
+  return mime_field_value_get_date(this);
 }
 
 inline int
 MIMEField::value_get_comma_list(StrList *list) const
 {
-  return (mime_field_value_get_comma_list(this, list));
+  return mime_field_value_get_comma_list(this, list);
 }
 
 /*-------------------------------------------------------------------------
@@ -1169,7 +1168,7 @@ MIMEHdr::field_create(const char *name, int length)
     mime_field_name_set(m_heap, m_mime, field, field_name_wks_idx, name, length, true);
   }
 
-  return (field);
+  return field;
 }
 
 /*-------------------------------------------------------------------------
@@ -1304,10 +1303,11 @@ inline int
 MIMEHdr::value_get_index(const char *name, int name_length, const char *value, int value_length) const
 {
   const MIMEField *field = field_find(name, name_length);
-  if (field)
+
+  if (field) {
     return field->value_get_index(value, value_length);
-  else
-    return -1;
+  }
+  return -1;
 }
 
 /*-------------------------------------------------------------------------
@@ -1316,7 +1316,9 @@ MIMEHdr::value_get_index(const char *name, int name_length, const char *value, i
 inline const char *
 MIMEHdr::value_get(const char *name, int name_length, int *value_length_return) const
 {
-  if (const MIMEField *field = field_find(name, name_length); field) {
+  const MIMEField *field = field_find(name, name_length);
+
+  if (field) {
     return field->value_get(value_length_return);
   }
   return nullptr;
@@ -1325,7 +1327,9 @@ MIMEHdr::value_get(const char *name, int name_length, int *value_length_return)
 inline std::string_view
 MIMEHdr::value_get(std::string_view const &name) const
 {
-  if (MIMEField const *field = field_find(name.data(), name.size()); field) {
+  MIMEField const *field = field_find(name.data(), name.size());
+
+  if (field) {
     return field->value_get();
   }
   return {};
@@ -1336,10 +1340,10 @@ MIMEHdr::value_get_int(const char *name, int name_length) const
 {
   const MIMEField *field = field_find(name, name_length);
 
-  if (field)
-    return (mime_field_value_get_int(field));
-  else
-    return (0);
+  if (field) {
+    return mime_field_value_get_int(field);
+  }
+  return 0;
 }
 
 inline uint32_t
@@ -1347,10 +1351,10 @@ MIMEHdr::value_get_uint(const char *name, int name_length) const
 {
   const MIMEField *field = field_find(name, name_length);
 
-  if (field)
-    return (mime_field_value_get_uint(field));
-  else
-    return (0);
+  if (field) {
+    return mime_field_value_get_uint(field);
+  }
+  return 0;
 }
 
 inline int64_t
@@ -1358,10 +1362,10 @@ MIMEHdr::value_get_int64(const char *name, int name_length) const
 {
   const MIMEField *field = field_find(name, name_length);
 
-  if (field)
-    return (mime_field_value_get_int64(field));
-  else
-    return (0);
+  if (field) {
+    return mime_field_value_get_int64(field);
+  }
+  return 0;
 }
 
 inline time_t
@@ -1369,10 +1373,10 @@ MIMEHdr::value_get_date(const char *name, int name_length) const
 {
   const MIMEField *field = field_find(name, name_length);
 
-  if (field)
-    return (mime_field_value_get_date(field));
-  else
-    return (0);
+  if (field) {
+    return mime_field_value_get_date(field);
+  }
+  return 0;
 }
 
 inline int
@@ -1380,10 +1384,10 @@ MIMEHdr::value_get_comma_list(const char *name, int name_length, StrList *list)
 {
   const MIMEField *field = field_find(name, name_length);
 
-  if (field)
-    return (field->value_get_comma_list(list));
-  else
-    return (0);
+  if (field) {
+    return field->value_get_comma_list(list);
+  }
+  return 0;
 }
 
 /*-------------------------------------------------------------------------
@@ -1547,7 +1551,7 @@ MIMEHdr::get_age()
 inline int64_t
 MIMEHdr::get_content_length() const
 {
-  return (value_get_int64(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH));
+  return value_get_int64(MIME_FIELD_CONTENT_LENGTH, MIME_LEN_CONTENT_LENGTH);
 }
 
 /*-------------------------------------------------------------------------
@@ -1556,7 +1560,7 @@ MIMEHdr::get_content_length() const
 inline time_t
 MIMEHdr::get_date()
 {
-  return (value_get_date(MIME_FIELD_DATE, MIME_LEN_DATE));
+  return value_get_date(MIME_FIELD_DATE, MIME_LEN_DATE);
 }
 
 /*-------------------------------------------------------------------------
@@ -1565,7 +1569,7 @@ MIMEHdr::get_date()
 inline time_t
 MIMEHdr::get_expires()
 {
-  return (value_get_date(MIME_FIELD_EXPIRES, MIME_LEN_EXPIRES));
+  return value_get_date(MIME_FIELD_EXPIRES, MIME_LEN_EXPIRES);
 }
 
 /*-------------------------------------------------------------------------
@@ -1574,7 +1578,7 @@ MIMEHdr::get_expires()
 inline time_t
 MIMEHdr::get_if_modified_since()
 {
-  return (value_get_date(MIME_FIELD_IF_MODIFIED_SINCE, MIME_LEN_IF_MODIFIED_SINCE));
+  return value_get_date(MIME_FIELD_IF_MODIFIED_SINCE, MIME_LEN_IF_MODIFIED_SINCE);
 }
 
 /*-------------------------------------------------------------------------
@@ -1583,7 +1587,7 @@ MIMEHdr::get_if_modified_since()
 inline time_t
 MIMEHdr::get_if_unmodified_since()
 {
-  return (value_get_date(MIME_FIELD_IF_UNMODIFIED_SINCE, MIME_LEN_IF_UNMODIFIED_SINCE));
+  return value_get_date(MIME_FIELD_IF_UNMODIFIED_SINCE, MIME_LEN_IF_UNMODIFIED_SINCE);
 }
 
 /*-------------------------------------------------------------------------
@@ -1592,7 +1596,7 @@ MIMEHdr::get_if_unmodified_since()
 inline time_t
 MIMEHdr::get_last_modified()
 {
-  return (value_get_date(MIME_FIELD_LAST_MODIFIED, MIME_LEN_LAST_MODIFIED));
+  return value_get_date(MIME_FIELD_LAST_MODIFIED, MIME_LEN_LAST_MODIFIED);
 }
 
 /*-------------------------------------------------------------------------
@@ -1601,7 +1605,7 @@ MIMEHdr::get_last_modified()
 inline time_t
 MIMEHdr::get_if_range_date()
 {
-  return (value_get_date(MIME_FIELD_IF_RANGE, MIME_LEN_IF_RANGE));
+  return value_get_date(MIME_FIELD_IF_RANGE, MIME_LEN_IF_RANGE);
 }
 
 /*-------------------------------------------------------------------------
@@ -1610,7 +1614,7 @@ MIMEHdr::get_if_range_date()
 inline int32_t
 MIMEHdr::get_max_forwards()
 {
-  return (value_get_int(MIME_FIELD_MAX_FORWARDS, MIME_LEN_MAX_FORWARDS));
+  return value_get_int(MIME_FIELD_MAX_FORWARDS, MIME_LEN_MAX_FORWARDS);
 }
 
 /*-------------------------------------------------------------------------
@@ -1622,7 +1626,7 @@ MIMEHdr::get_warning(int idx)
   (void)idx;
   // FIXME: what do we do here?
   ink_release_assert(!"unimplemented");
-  return (0);
+  return 0;
 }
 
 /*-------------------------------------------------------------------------
@@ -1631,7 +1635,7 @@ MIMEHdr::get_warning(int idx)
 inline uint32_t
 MIMEHdr::get_cooked_cc_mask()
 {
-  return (m_mime->m_cooked_stuff.m_cache_control.m_mask);
+  return m_mime->m_cooked_stuff.m_cache_control.m_mask;
 }
 
 /*-------------------------------------------------------------------------
@@ -1640,7 +1644,7 @@ MIMEHdr::get_cooked_cc_mask()
 inline int32_t
 MIMEHdr::get_cooked_cc_max_age()
 {
-  return (m_mime->m_cooked_stuff.m_cache_control.m_secs_max_age);
+  return m_mime->m_cooked_stuff.m_cache_control.m_secs_max_age;
 }
 
 /*-------------------------------------------------------------------------
@@ -1649,7 +1653,7 @@ MIMEHdr::get_cooked_cc_max_age()
 inline int32_t
 MIMEHdr::get_cooked_cc_s_maxage()
 {
-  return (m_mime->m_cooked_stuff.m_cache_control.m_secs_s_maxage);
+  return m_mime->m_cooked_stuff.m_cache_control.m_secs_s_maxage;
 }
 
 /*-------------------------------------------------------------------------
@@ -1658,7 +1662,7 @@ MIMEHdr::get_cooked_cc_s_maxage()
 inline int32_t
 MIMEHdr::get_cooked_cc_max_stale()
 {
-  return (m_mime->m_cooked_stuff.m_cache_control.m_secs_max_stale);
+  return m_mime->m_cooked_stuff.m_cache_control.m_secs_max_stale;
 }
 
 /*-------------------------------------------------------------------------
@@ -1667,7 +1671,7 @@ MIMEHdr::get_cooked_cc_max_stale()
 inline int32_t
 MIMEHdr::get_cooked_cc_min_fresh()
 {
-  return (m_mime->m_cooked_stuff.m_cache_control.m_secs_min_fresh);
+  return m_mime->m_cooked_stuff.m_cache_control.m_secs_min_fresh;
 }
 
 /*-------------------------------------------------------------------------
@@ -1676,7 +1680,7 @@ MIMEHdr::get_cooked_cc_min_fresh()
 inline bool
 MIMEHdr::get_cooked_pragma_no_cache()
 {
-  return (m_mime->m_cooked_stuff.m_pragma.m_no_cache);
+  return m_mime->m_cooked_stuff.m_pragma.m_no_cache;
 }
 
 /*-------------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 3b9ae71..533db3f 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -992,9 +992,6 @@ HttpSM::state_read_push_response_header(int event, void *data)
   ink_assert(ua_entry->read_vio == (VIO *)data);
   ink_assert(t_state.current.server == nullptr);
 
-  int64_t data_size  = 0;
-  int64_t bytes_used = 0;
-
   switch (event) {
   case VC_EVENT_EOS:
     ua_entry->eos = true;
@@ -1018,17 +1015,16 @@ HttpSM::state_read_push_response_header(int event, void *data)
   while (ua_buffer_reader->read_avail() && state == PARSE_RESULT_CONT) {
     const char *start = ua_buffer_reader->start();
     const char *tmp   = start;
-    data_size         = ua_buffer_reader->block_read_avail();
+    int64_t data_size = ua_buffer_reader->block_read_avail();
     ink_assert(data_size >= 0);
 
     /////////////////////
     // tokenize header //
     /////////////////////
-    state =
-      t_state.hdr_info.server_response.parse_resp(&http_parser, &tmp, tmp + data_size, false // Only call w/ eof when data exhausted
-      );
+    state = t_state.hdr_info.server_response.parse_resp(&http_parser, &tmp, tmp + data_size,
+                                                        false); // Only call w/ eof when data exhausted
 
-    bytes_used = tmp - start;
+    int64_t bytes_used = tmp - start;
 
     ink_release_assert(bytes_used <= data_size);
     ua_buffer_reader->consume(bytes_used);
@@ -1719,14 +1715,13 @@ HttpSM::state_http_server_open(int event, void *data)
     pending_action = nullptr;
   }
   milestones[TS_MILESTONE_SERVER_CONNECT_END] = Thread::get_hrtime();
-  HttpServerSession *session;
-  NetVConnection *netvc = nullptr;
+  NetVConnection *netvc                       = nullptr;
 
   switch (event) {
   case NET_EVENT_OPEN: {
-    session = (TS_SERVER_SESSION_SHARING_POOL_THREAD == t_state.http_config_param->server_session_sharing_pool) ?
-                THREAD_ALLOC_INIT(httpServerSessionAllocator, mutex->thread_holding) :
-                httpServerSessionAllocator.alloc();
+    HttpServerSession *session = (TS_SERVER_SESSION_SHARING_POOL_THREAD == t_state.http_config_param->server_session_sharing_pool) ?
+                                   THREAD_ALLOC_INIT(httpServerSessionAllocator, mutex->thread_holding) :
+                                   httpServerSessionAllocator.alloc();
     session->sharing_pool  = static_cast<TSServerSessionSharingPoolType>(t_state.http_config_param->server_session_sharing_pool);
     session->sharing_match = static_cast<TSServerSessionSharingMatchType>(t_state.txn_conf->server_session_sharing_match);
 
@@ -4398,8 +4393,6 @@ Lfaild:
 void
 HttpSM::calculate_output_cl(int64_t num_chars_for_ct, int64_t num_chars_for_cl)
 {
-  int i;
-
   if (t_state.range_setup != HttpTransact::RANGE_REQUESTED && t_state.range_setup != HttpTransact::RANGE_NOT_TRANSFORM_REQUESTED) {
     return;
   }
@@ -4409,7 +4402,7 @@ HttpSM::calculate_output_cl(int64_t num_chars_for_ct, int64_t num_chars_for_cl)
   if (t_state.num_range_fields == 1) {
     t_state.range_output_cl = t_state.ranges[0]._end - t_state.ranges[0]._start + 1;
   } else {
-    for (i = 0; i < t_state.num_range_fields; i++) {
+    for (int i = 0; i < t_state.num_range_fields; i++) {
       if (t_state.ranges[i]._start >= 0) {
         t_state.range_output_cl += boundary_size;
         t_state.range_output_cl += sub_header_size + num_chars_for_ct;
@@ -4446,9 +4439,6 @@ void
 HttpSM::do_range_setup_if_necessary()
 {
   MIMEField *field;
-  INKVConnInternal *range_trans;
-  int field_content_type_len = -1;
-  const char *content_type;
 
   ink_assert(t_state.cache_info.object_read != nullptr);
 
@@ -4492,11 +4482,14 @@ HttpSM::do_range_setup_if_necessary()
       // We have to do the transform on (allowed) multi-range request, *or* if the VC is not pread capable
       if (do_transform) {
         if (api_hooks.get(TS_HTTP_RESPONSE_TRANSFORM_HOOK) == nullptr) {
+          int field_content_type_len = -1;
+          const char *content_type   = t_state.cache_info.object_read->response_get()->value_get(
+            MIME_FIELD_CONTENT_TYPE, MIME_LEN_CONTENT_TYPE, &field_content_type_len);
+
           Debug("http_trans", "Unable to accelerate range request, fallback to transform");
-          content_type = t_state.cache_info.object_read->response_get()->value_get(MIME_FIELD_CONTENT_TYPE, MIME_LEN_CONTENT_TYPE,
-                                                                                   &field_content_type_len);
+
           // create a Range: transform processor for requests of type Range: bytes=1-2,4-5,10-100 (eg. multiple ranges)
-          range_trans = transformProcessor.range_transform(
+          INKVConnInternal *range_trans = transformProcessor.range_transform(
             mutex.get(), t_state.ranges, t_state.num_range_fields, &t_state.hdr_info.transform_response, content_type,
             field_content_type_len, t_state.cache_info.object_read->object_size_get());
           api_hooks.append(TS_HTTP_RESPONSE_TRANSFORM_HOOK, range_trans);
@@ -4621,7 +4614,7 @@ HttpSM::do_cache_prepare_update()
 void
 HttpSM::do_cache_prepare_action(HttpCacheSM *c_sm, CacheHTTPInfo *object_read_info, bool retry, bool allow_multiple)
 {
-  URL *o_url, *c_url, *s_url;
+  URL *o_url, *s_url;
   bool restore_client_request = false;
 
   ink_assert(!pending_action);
@@ -4643,7 +4636,7 @@ HttpSM::do_cache_prepare_action(HttpCacheSM *c_sm, CacheHTTPInfo *object_read_in
   // modify client request to make it have the url we are going to
   // store into the cache
   if (restore_client_request) {
-    c_url = t_state.hdr_info.client_request.url_get();
+    URL *c_url = t_state.hdr_info.client_request.url_get();
     s_url->copy(c_url);
   }
 
@@ -5856,16 +5849,15 @@ HttpSM::issue_cache_update()
 int
 HttpSM::write_header_into_buffer(HTTPHdr *h, MIOBuffer *b)
 {
-  int bufindex;
   int dumpoffset;
-  int done, tmp;
-  IOBufferBlock *block;
+  int done;
 
   dumpoffset = 0;
   do {
-    bufindex = 0;
-    tmp      = dumpoffset;
-    block    = b->get_current_block();
+    IOBufferBlock *block = b->get_current_block();
+    int bufindex         = 0;
+    int tmp              = dumpoffset;
+
     ink_assert(block->write_avail() > 0);
     done = h->print(block->start(), block->write_avail(), &bufindex, &tmp);
     dumpoffset += bufindex;
@@ -6330,7 +6322,6 @@ HttpSM::setup_internal_transfer(HttpSMHandler handler_arg)
 int
 HttpSM::find_http_resp_buffer_size(int64_t content_length)
 {
-  int64_t buf_size;
   int64_t alloc_index;
 
   if (content_length == HTTP_UNDEFINED_CL) {
@@ -6341,6 +6332,8 @@ HttpSM::find_http_resp_buffer_size(int64_t content_length)
       alloc_index = DEFAULT_RESPONSE_BUFFER_SIZE_INDEX;
     }
   } else {
+    int64_t buf_size;
+
 #ifdef WRITE_AND_TRANSFER
     buf_size = HTTP_HEADER_BUFFER_SIZE + content_length - index_to_buffer_size(HTTP_SERVER_RESP_HDR_BUFFER_INDEX);
 #else
@@ -7796,9 +7789,9 @@ HttpSM::redirect_request(const char *arg_redirect_url, const int arg_redirect_le
 
   bool noPortInHost = HttpConfig::m_master.redirection_host_no_port;
 
-  bool isRedirectUrlOriginForm = clientUrl.m_url_impl->m_len_scheme <= 0 && clientUrl.m_url_impl->m_len_user <= 0 &&
-                                 clientUrl.m_url_impl->m_len_password <= 0 && clientUrl.m_url_impl->m_len_host <= 0 &&
-                                 clientUrl.m_url_impl->m_len_port <= 0;
+  bool isRedirectUrlOriginForm = !clientUrl.m_url_impl->m_len_scheme && !clientUrl.m_url_impl->m_len_user &&
+                                 !clientUrl.m_url_impl->m_len_password && !clientUrl.m_url_impl->m_len_host &&
+                                 !clientUrl.m_url_impl->m_len_port;
 
   // check to see if the client request passed a host header, if so copy the host and port from the redirect url and
   // make a new host header
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index 30ace9e..fe31729 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -99,7 +99,7 @@ struct HttpVCTableEntry {
 
 struct HttpVCTable {
   static const int vc_table_max_entries = 4;
-  HttpVCTable(HttpSM *);
+  explicit HttpVCTable(HttpSM *);
 
   HttpVCTableEntry *new_entry();
   HttpVCTableEntry *find_entry(VConnection *);
diff --git a/proxy/http/HttpTunnel.h b/proxy/http/HttpTunnel.h
index 9a91f50..272b33e 100644
--- a/proxy/http/HttpTunnel.h
+++ b/proxy/http/HttpTunnel.h
@@ -517,7 +517,7 @@ inline bool
 HttpTunnelConsumer::is_downstream_from(VConnection *vc)
 {
   HttpTunnelProducer *p = producer;
-  HttpTunnelConsumer *c;
+
   while (p) {
     if (p->vc == vc) {
       return true;
@@ -525,7 +525,8 @@ HttpTunnelConsumer::is_downstream_from(VConnection *vc)
     // The producer / consumer chain can contain a cycle in the case
     // of a blind tunnel so give up if we find ourself (the original
     // consumer).
-    c = p->self_consumer;
+    HttpTunnelConsumer *c = p->self_consumer;
+
     p = (c && c != this) ? c->producer : nullptr;
   }
   return false;
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index e3870ac..9762dae 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -278,7 +278,10 @@ struct LoggingPreprocContinuation : public Continuation {
     return 0;
   }
 
-  LoggingPreprocContinuation(int idx) : Continuation(nullptr), m_idx(idx) { SET_HANDLER(&LoggingPreprocContinuation::mainEvent); }
+  explicit LoggingPreprocContinuation(int idx) : Continuation(nullptr), m_idx(idx)
+  {
+    SET_HANDLER(&LoggingPreprocContinuation::mainEvent);
+  }
 };
 
 struct LoggingFlushContinuation : public Continuation {
@@ -291,7 +294,10 @@ struct LoggingFlushContinuation : public Continuation {
     return 0;
   }
 
-  LoggingFlushContinuation(int idx) : Continuation(nullptr), m_idx(idx) { SET_HANDLER(&LoggingFlushContinuation::mainEvent); }
+  explicit LoggingFlushContinuation(int idx) : Continuation(nullptr), m_idx(idx)
+  {
+    SET_HANDLER(&LoggingFlushContinuation::mainEvent);
+  }
 };
 
 struct LoggingCollateContinuation : public Continuation {
@@ -1252,11 +1258,10 @@ Log::preproc_thread_main(void *args)
     if (TSSystemState::is_event_system_shut_down()) {
       return nullptr;
     }
-    size_t buffers_preproced = 0;
-    LogConfig *current       = (LogConfig *)configProcessor.get(log_configid);
+    LogConfig *current = static_cast<LogConfig *>(configProcessor.get(log_configid));
 
     if (likely(current)) {
-      buffers_preproced = current->log_object_manager.preproc_buffers(idx);
+      size_t buffers_preproced = current->log_object_manager.preproc_buffers(idx);
 
       // config->increment_space_used(bytes_to_disk);
       // TODO: the bytes_to_disk should be set to Log
@@ -1295,7 +1300,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
     if (TSSystemState::is_event_system_shut_down()) {
       return nullptr;
     }
-    fdata = (LogFlushData *)ink_atomiclist_popall(flush_data_list);
+    fdata = static_cast<LogFlushData *>(ink_atomiclist_popall(flush_data_list));
 
     // invert the list
     //
@@ -1312,7 +1317,7 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
       LogFile *logfile  = fdata->m_logfile.get();
 
       if (logfile->m_file_format == LOG_FILE_BINARY) {
-        logbuffer                      = (LogBuffer *)fdata->m_data;
+        logbuffer                      = static_cast<LogBuffer *>(fdata->m_data);
         LogBufferHeader *buffer_header = logbuffer->header();
 
         buf         = (char *)buffer_header;
@@ -1475,7 +1480,7 @@ Log::collate_thread_main(void * /* args ATS_UNUSED */)
       }
 
       Debug("log-sock", "pending message ...");
-      header = (LogBufferHeader *)sock->read_alloc(sock_id, &bytes_read);
+      header = static_cast<LogBufferHeader *>(sock->read_alloc(sock_id, &bytes_read));
       if (!header) {
         Debug("log-sock", "Error reading LogBuffer from collation client");
         continue;
@@ -1536,9 +1541,9 @@ Log::match_logobject(LogBufferHeader *header)
     LogFormat fmt("__collation_format__", header->fmt_fieldlist(), header->fmt_printf());
 
     if (fmt.valid()) {
-      LogFileFormat file_format = header->log_object_flags & LogObject::BINARY ?
+      LogFileFormat file_format = (header->log_object_flags & LogObject::BINARY) ?
                                     LOG_FILE_BINARY :
-                                    (header->log_object_flags & LogObject::WRITES_TO_PIPE ? LOG_FILE_PIPE : LOG_FILE_ASCII);
+                                    ((header->log_object_flags & LogObject::WRITES_TO_PIPE) ? LOG_FILE_PIPE : LOG_FILE_ASCII);
 
       obj = new LogObject(&fmt, Log::config->logfile_dir, header->log_filename(), file_format, nullptr,
                           (Log::RollingEnabledValues)Log::config->rolling_enabled, Log::config->collation_preproc_threads,
diff --git a/proxy/logging/Log.h b/proxy/logging/Log.h
index 00e0d1b..d266019 100644
--- a/proxy/logging/Log.h
+++ b/proxy/logging/Log.h
@@ -87,7 +87,7 @@ public:
   {
     switch (m_logfile->m_file_format) {
     case LOG_FILE_BINARY:
-      logbuffer = (LogBuffer *)m_data;
+      logbuffer = static_cast<LogBuffer *>(m_data);
       LogBuffer::destroy(logbuffer);
       break;
     case LOG_FILE_ASCII:
diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc
index da106fa..43e5c75 100644
--- a/proxy/logging/LogAccess.cc
+++ b/proxy/logging/LogAccess.cc
@@ -1332,9 +1332,6 @@ LogAccess::validate_unmapped_url()
 void
 LogAccess::validate_unmapped_url_path()
 {
-  int len;
-  char *c;
-
   if (m_client_req_unmapped_url_path_str == nullptr && m_client_req_unmapped_url_host_str == nullptr) {
     // Use unmapped canonical URL as default
     m_client_req_unmapped_url_path_str = m_client_req_unmapped_url_canon_str;
@@ -1343,7 +1340,9 @@ LogAccess::validate_unmapped_url_path()
     m_client_req_unmapped_url_host_str = INVALID_STR;
 
     if (m_client_req_unmapped_url_path_len >= 6) { // xxx:// - minimum schema size
-      c = (char *)memchr((void *)m_client_req_unmapped_url_path_str, ':', m_client_req_unmapped_url_path_len - 1);
+      int len;
+      char *c = (char *)memchr((void *)m_client_req_unmapped_url_path_str, ':', m_client_req_unmapped_url_path_len - 1);
+
       if (c && (len = (int)(c - m_client_req_unmapped_url_path_str)) <= 5) { // 5 - max schema size
         if (len + 2 <= m_client_req_unmapped_url_canon_len && c[1] == '/' && c[2] == '/') {
           len += 3; // Skip "://"
diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h
index c915204..1d35627 100644
--- a/proxy/logging/LogAccess.h
+++ b/proxy/logging/LogAccess.h
@@ -118,7 +118,7 @@ public:
   {
   }
 
-  LogAccess(HttpSM *sm);
+  explicit LogAccess(HttpSM *sm);
 
   inkcoreapi ~LogAccess() {}
   inkcoreapi void init();
diff --git a/proxy/logging/LogField.h b/proxy/logging/LogField.h
index 94823e4..e02dba3 100644
--- a/proxy/logging/LogField.h
+++ b/proxy/logging/LogField.h
@@ -50,7 +50,7 @@ struct LogSlice {
   // Initialize LogSlice by slice notation,
   // the str looks like: "xxx[0:30]".
   //
-  LogSlice(char *str);
+  explicit LogSlice(char *str);
 
   //
   // Convert slice notation to target string's offset,
diff --git a/proxy/logging/LogObject.h b/proxy/logging/LogObject.h
index 761530c..dff5853 100644
--- a/proxy/logging/LogObject.h
+++ b/proxy/logging/LogObject.h
@@ -234,12 +234,12 @@ public:
   inline bool
   receives_remote_data() const
   {
-    return m_flags & REMOTE_DATA ? true : false;
+    return (m_flags & REMOTE_DATA) ? true : false;
   }
   inline bool
   writes_to_pipe() const
   {
-    return m_flags & WRITES_TO_PIPE ? true : false;
+    return (m_flags & WRITES_TO_PIPE) ? true : false;
   }
   inline bool
   writes_to_disk()
diff --git a/proxy/logging/LogSock.h b/proxy/logging/LogSock.h
index d1ad1e9..f2eb70e 100644
--- a/proxy/logging/LogSock.h
+++ b/proxy/logging/LogSock.h
@@ -61,7 +61,7 @@ public:
     LS_N_STATES,
   };
 
-  LogSock(int max_connects = 1);
+  explicit LogSock(int max_connects = 1);
   ~LogSock();
 
   bool pending_any(int *cid, int timeout_msec = 0);