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

bcall 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 1f01233  Ran clang-tidy with modernize-loop-convert
1f01233 is described below

commit 1f012332685fd7ee73b274785cdd9cdf2d157d88
Author: Bryan Call <bc...@apache.org>
AuthorDate: Sat Apr 7 12:46:43 2018 -0700

    Ran clang-tidy with modernize-loop-convert
---
 .../AsyncHttpFetchStreaming.cc                     |  6 +-
 example/cppapi/clientrequest/ClientRequest.cc      |  5 +-
 example/cppapi/serverresponse/ServerResponse.cc    |  7 +-
 iocore/net/SSLUtils.cc                             |  4 +-
 iocore/net/UnixNetProcessor.cc                     |  4 +-
 lib/cppapi/AsyncHttpFetch.cc                       |  6 +-
 lib/cppapi/Headers.cc                              |  4 +-
 lib/records/RecHttp.cc                             |  3 +-
 lib/ts/test_PriorityQueue.cc                       |  4 +-
 lib/ts/unit-tests/test_IpMap.cc                    |  5 +-
 mgmt/LocalManager.cc                               |  9 +--
 plugins/s3_auth/aws_auth_v4.cc                     | 28 ++++----
 proxy/InkAPI.cc                                    |  3 +-
 proxy/logging/LogObject.cc                         | 75 +++++++++++-----------
 14 files changed, 76 insertions(+), 87 deletions(-)

diff --git 
a/example/cppapi/async_http_fetch_streaming/AsyncHttpFetchStreaming.cc 
b/example/cppapi/async_http_fetch_streaming/AsyncHttpFetchStreaming.cc
index e91a310..412ced8 100644
--- a/example/cppapi/async_http_fetch_streaming/AsyncHttpFetchStreaming.cc
+++ b/example/cppapi/async_http_fetch_streaming/AsyncHttpFetchStreaming.cc
@@ -122,10 +122,10 @@ Intercept::handleAsyncComplete(AsyncHttpFetch 
&async_http_fetch)
     oss << HTTP_VERSION_STRINGS[response.getVersion()] << ' ' << 
response.getStatusCode() << ' ' << response.getReasonPhrase()
         << "\r\n";
     Headers &response_headers = response.getHeaders();
-    for (Headers::iterator iter = response_headers.begin(), end = 
response_headers.end(); iter != end; ++iter) {
-      HeaderFieldName header_name = (*iter).name();
+    for (auto &&response_header : response_headers) {
+      HeaderFieldName header_name = response_header.name();
       if (header_name != "Transfer-Encoding") {
-        oss << header_name.str() << ": " << (*iter).values() << "\r\n";
+        oss << header_name.str() << ": " << response_header.values() << "\r\n";
       }
     }
     oss << "\r\n";
diff --git a/example/cppapi/clientrequest/ClientRequest.cc 
b/example/cppapi/clientrequest/ClientRequest.cc
index 3179813..00bc1ac 100644
--- a/example/cppapi/clientrequest/ClientRequest.cc
+++ b/example/cppapi/clientrequest/ClientRequest.cc
@@ -101,9 +101,8 @@ public:
     cout << "Adding a new accept type accept header" << endl;
     client_request_headers.append("accept", "text/blah");
 
-    for (Headers::iterator header_iter = client_request_headers.begin(), 
header_end = client_request_headers.end();
-         header_iter != header_end; ++header_iter) {
-      cout << (*header_iter).str() << endl;
+    for (auto &&client_request_header : client_request_headers) {
+      cout << client_request_header.str() << endl;
     }
 
     /*
diff --git a/example/cppapi/serverresponse/ServerResponse.cc 
b/example/cppapi/serverresponse/ServerResponse.cc
index 5e2e7f8..74c2363 100644
--- a/example/cppapi/serverresponse/ServerResponse.cc
+++ b/example/cppapi/serverresponse/ServerResponse.cc
@@ -103,11 +103,10 @@ private:
   void
   printHeadersManual(Headers &headers)
   {
-    for (Headers::iterator header_iter = headers.begin(), header_end = 
headers.end(); header_iter != header_end; ++header_iter) {
-      cout << "Header " << (*header_iter).name() << ": " << endl;
+    for (auto &&header : headers) {
+      cout << "Header " << header.name() << ": " << endl;
 
-      for (HeaderField::iterator value_iter = (*header_iter).begin(), 
values_end = (*header_iter).end(); value_iter != values_end;
-           ++value_iter) {
+      for (HeaderField::iterator value_iter = header.begin(), values_end = 
header.end(); value_iter != values_end; ++value_iter) {
         cout << "\t" << *value_iter << endl;
       }
     }
diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc
index ff447dd..4921d72 100644
--- a/iocore/net/SSLUtils.cc
+++ b/iocore/net/SSLUtils.cc
@@ -1975,8 +1975,8 @@ ssl_store_ssl_context(const SSLConfigParams *params, 
SSLCertLookup *lookup, cons
     ctx = nullptr;
   }
 
-  for (unsigned int i = 0; i < cert_list.size(); i++) {
-    X509_free(cert_list[i]);
+  for (auto &i : cert_list) {
+    X509_free(i);
   }
 
   return ctx;
diff --git a/iocore/net/UnixNetProcessor.cc b/iocore/net/UnixNetProcessor.cc
index f63eaa0..92c37c0 100644
--- a/iocore/net/UnixNetProcessor.cc
+++ b/iocore/net/UnixNetProcessor.cc
@@ -204,8 +204,8 @@ UnixNetProcessor::accept_internal(Continuation *cont, int 
fd, AcceptOptions cons
 void
 NetProcessor::stop_accept()
 {
-  for (auto na = naVec.begin(); na != naVec.end(); ++na) {
-    (*na)->stop_accept();
+  for (auto &na : naVec) {
+    na->stop_accept();
   }
 }
 
diff --git a/lib/cppapi/AsyncHttpFetch.cc b/lib/cppapi/AsyncHttpFetch.cc
index 82f9ffa..c9f184c 100644
--- a/lib/cppapi/AsyncHttpFetch.cc
+++ b/lib/cppapi/AsyncHttpFetch.cc
@@ -231,9 +231,9 @@ AsyncHttpFetch::run()
                     state_->request_->getUrl().getUrlString().c_str(), 
HTTP_VERSION_STRINGS[state_->request_->getVersion()].c_str(),
                     reinterpret_cast<struct sockaddr const *>(&addr), 
TS_FETCH_FLAGS_STREAM | TS_FETCH_FLAGS_DECHUNK);
     string header_value;
-    for (Headers::iterator iter = headers.begin(), end = headers.end(); iter 
!= end; ++iter) {
-      HeaderFieldName header_name = (*iter).name();
-      header_value                = (*iter).values();
+    for (auto &&header : headers) {
+      HeaderFieldName header_name = header.name();
+      header_value                = header.values();
       TSFetchHeaderAdd(state_->fetch_sm_, header_name.c_str(), 
header_name.length(), header_value.data(), header_value.size());
     }
     LOG_DEBUG("Launching streaming fetch");
diff --git a/lib/cppapi/Headers.cc b/lib/cppapi/Headers.cc
index 5645951..c44140f 100644
--- a/lib/cppapi/Headers.cc
+++ b/lib/cppapi/Headers.cc
@@ -693,8 +693,8 @@ std::string
 Headers::wireStr()
 {
   string retval;
-  for (iterator iter = begin(), last = end(); iter != last; ++iter) {
-    HeaderField hf = *iter;
+  for (auto &&iter : *this) {
+    HeaderField hf = iter;
     retval += hf.name().str();
     retval += ": ";
     retval += hf.values(", ");
diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc
index b35cae2..5c73a81 100644
--- a/lib/records/RecHttp.cc
+++ b/lib/records/RecHttp.cc
@@ -291,8 +291,7 @@ HttpProxyPort::processOptions(const char *opts)
     return zret;
   }
 
-  for (int i = 0, n_items = values.size(); i < n_items; ++i) {
-    const char *item = values[i];
+  for (auto item : values) {
     if (isdigit(item[0])) { // leading digit -> port value
       char *ptr;
       int port = strtoul(item, &ptr, 10);
diff --git a/lib/ts/test_PriorityQueue.cc b/lib/ts/test_PriorityQueue.cc
index 2bdd635..bb5b51c 100644
--- a/lib/ts/test_PriorityQueue.cc
+++ b/lib/ts/test_PriorityQueue.cc
@@ -54,8 +54,8 @@ dump(PQ *pq)
 {
   std::vector<Entry *> v = pq->dump();
 
-  for (uint32_t i = 0; i < v.size(); i++) {
-    cout << v[i]->index << "," << v[i]->node->weight << "," << 
v[i]->node->content << endl;
+  for (auto &i : v) {
+    cout << i->index << "," << i->node->weight << "," << i->node->content << 
endl;
   }
   cout << "--------" << endl;
 }
diff --git a/lib/ts/unit-tests/test_IpMap.cc b/lib/ts/unit-tests/test_IpMap.cc
index 3ffd66c..accb945 100644
--- a/lib/ts/unit-tests/test_IpMap.cc
+++ b/lib/ts/unit-tests/test_IpMap.cc
@@ -37,11 +37,10 @@ void
 IpMapTestPrint(IpMap &map)
 {
   printf("IpMap Dump\n");
-  for (IpMap::iterator spot(map.begin()), limit(map.end()); spot != limit; 
++spot) {
+  for (auto &spot : map) {
     ip_text_buffer ipb1, ipb2;
 
-    printf("%s - %s : %p\n", ats_ip_ntop(spot->min(), ipb1, sizeof ipb1), 
ats_ip_ntop(spot->max(), ipb2, sizeof(ipb2)),
-           spot->data());
+    printf("%s - %s : %p\n", ats_ip_ntop(spot.min(), ipb1, sizeof ipb1), 
ats_ip_ntop(spot.max(), ipb2, sizeof(ipb2)), spot.data());
   }
   printf("\n");
 }
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 66ebad1..897360f 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -919,8 +919,7 @@ LocalManager::startProxy(const char *onetime_options)
       bool need_comma_p = false;
 
       ink_strlcat(real_proxy_options, " --httpport ", OPTIONS_SIZE);
-      for (int i = 0, limit = m_proxy_ports.size(); i < limit; ++i) {
-        HttpProxyPort &p = m_proxy_ports[i];
+      for (auto &p : m_proxy_ports) {
         if (ts::NO_FD != p.m_fd) {
           if (need_comma_p) {
             ink_strlcat(real_proxy_options, ",", OPTIONS_SIZE);
@@ -957,8 +956,7 @@ LocalManager::startProxy(const char *onetime_options)
 void
 LocalManager::closeProxyPorts()
 {
-  for (int i = 0, n = lmgmt->m_proxy_ports.size(); i < n; ++i) {
-    HttpProxyPort &p = lmgmt->m_proxy_ports[i];
+  for (auto &p : lmgmt->m_proxy_ports) {
     if (ts::NO_FD != p.m_fd) {
       close_socket(p.m_fd);
       p.m_fd = ts::NO_FD;
@@ -977,8 +975,7 @@ LocalManager::listenForProxy()
   }
 
   // We are not already bound, bind the port
-  for (int i = 0, n = lmgmt->m_proxy_ports.size(); i < n; ++i) {
-    HttpProxyPort &p = lmgmt->m_proxy_ports[i];
+  for (auto &p : lmgmt->m_proxy_ports) {
     if (ts::NO_FD == p.m_fd) {
       this->bindProxyPort(p);
     }
diff --git a/plugins/s3_auth/aws_auth_v4.cc b/plugins/s3_auth/aws_auth_v4.cc
index 5c3cd66..da5bbe9 100644
--- a/plugins/s3_auth/aws_auth_v4.cc
+++ b/plugins/s3_auth/aws_auth_v4.cc
@@ -82,20 +82,20 @@ uriEncode(const String &in, bool isObjectName)
 {
   std::stringstream result;
 
-  for (std::string::size_type i = 0; i < in.length(); i++) {
-    if (isalnum(in[i]) || in[i] == '-' || in[i] == '_' || in[i] == '.' || 
in[i] == '~') {
+  for (char i : in) {
+    if (isalnum(i) || i == '-' || i == '_' || i == '.' || i == '~') {
       /* URI encode every byte except the unreserved characters:
        * 'A'-'Z', 'a'-'z', '0'-'9', '-', '.', '_', and '~'. */
-      result << in[i];
-    } else if (in[i] == ' ') {
+      result << i;
+    } else if (i == ' ') {
       /* The space character is a reserved character and must be encoded as 
"%20" (and not as "+"). */
       result << "%20";
-    } else if (isObjectName && in[i] == '/') {
+    } else if (isObjectName && i == '/') {
       /* Encode the forward slash character, '/', everywhere except in the 
object key name. */
       result << "/";
     } else {
       /* Letters in the hexadecimal value must be upper-case, for example 
"%1A". */
-      result << "%" << std::uppercase << std::setfill('0') << std::setw(2) << 
std::hex << (int)in[i];
+      result << "%" << std::uppercase << std::setfill('0') << std::setw(2) << 
std::hex << (int)i;
     }
   }
 
@@ -304,12 +304,12 @@ getCanonicalRequestSha256Hash(TsInterface &api, bool 
signPayload, const StringSe
   }
 
   String queryStr;
-  for (StringSet::iterator it = paramNames.begin(); it != paramNames.end(); 
it++) {
+  for (const auto &paramName : paramNames) {
     if (!queryStr.empty()) {
       queryStr.append("&");
     }
-    queryStr.append(*it);
-    queryStr.append("=").append(paramsMap[*it]);
+    queryStr.append(paramName);
+    queryStr.append("=").append(paramsMap[paramName]);
   }
   sha256Update(&canonicalRequestSha256Ctx, queryStr);
   sha256Update(&canonicalRequestSha256Ctx, "\n");
@@ -364,19 +364,19 @@ getCanonicalRequestSha256Hash(TsInterface &api, bool 
signPayload, const StringSe
     headersMap[lowercaseName] = String(trimValue, trimValueLen);
   }
 
-  for (StringSet::iterator it = signedHeadersSet.begin(); it != 
signedHeadersSet.end(); it++) {
-    sha256Update(&canonicalRequestSha256Ctx, *it);
+  for (const auto &it : signedHeadersSet) {
+    sha256Update(&canonicalRequestSha256Ctx, it);
     sha256Update(&canonicalRequestSha256Ctx, ":");
-    sha256Update(&canonicalRequestSha256Ctx, headersMap[*it]);
+    sha256Update(&canonicalRequestSha256Ctx, headersMap[it]);
     sha256Update(&canonicalRequestSha256Ctx, "\n");
   }
   sha256Update(&canonicalRequestSha256Ctx, "\n");
 
-  for (StringSet::iterator it = signedHeadersSet.begin(); it != 
signedHeadersSet.end(); ++it) {
+  for (const auto &it : signedHeadersSet) {
     if (!signedHeaders.empty()) {
       signedHeaders.append(";");
     }
-    signedHeaders.append(*it);
+    signedHeaders.append(it);
   }
 
   sha256Update(&canonicalRequestSha256Ctx, signedHeaders);
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 7b79473..61f77e1 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -9147,8 +9147,7 @@ TSPluginDescriptorAccept(TSCont contp)
   Action *action = nullptr;
 
   HttpProxyPort::Group &proxy_ports = HttpProxyPort::global();
-  for (int i = 0, n = proxy_ports.size(); i < n; ++i) {
-    HttpProxyPort &port = proxy_ports[i];
+  for (auto &port : proxy_ports) {
     if (port.isPlugin()) {
       NetProcessor::AcceptOptions net(make_net_accept_options(&port, -1 /* 
nthreads */));
       action = netProcessor.main_accept((INKContInternal *)contp, port.m_fd, 
net);
diff --git a/proxy/logging/LogObject.cc b/proxy/logging/LogObject.cc
index b4cac5e..740b4b9 100644
--- a/proxy/logging/LogObject.cc
+++ b/proxy/logging/LogObject.cc
@@ -859,15 +859,15 @@ LogObjectManager::LogObjectManager()
 
 LogObjectManager::~LogObjectManager()
 {
-  for (unsigned i = 0; i < _objects.size(); ++i) {
-    if (_objects[i]->refcount_dec() == 0) {
-      delete _objects[i];
+  for (auto &_object : _objects) {
+    if (_object->refcount_dec() == 0) {
+      delete _object;
     }
   }
 
-  for (unsigned i = 0; i < _APIobjects.size(); ++i) {
-    if (_APIobjects[i]->refcount_dec() == 0) {
-      delete _APIobjects[i];
+  for (auto &_APIobject : _APIobjects) {
+    if (_APIobject->refcount_dec() == 0) {
+      delete _APIobject;
     }
   }
 
@@ -1046,13 +1046,13 @@ LogObjectManager::_filename_resolution_abort(const char 
*filename)
 bool
 LogObjectManager::_has_internal_filename_conflict(const char *filename, 
LogObjectList &objects)
 {
-  for (unsigned i = 0; i < objects.size(); i++) {
-    if (!objects[i]->is_collation_client()) {
+  for (auto &object : objects) {
+    if (!object->is_collation_client()) {
       // an internal conflict exists if two objects request the
       // same filename, regardless of the object signatures, since
       // two objects writing to the same file would produce a
       // log with duplicate entries and non monotonic timestamps
-      if (strcmp(objects[i]->get_full_filename(), filename) == 0) {
+      if (strcmp(object->get_full_filename(), filename) == 0) {
         return true;
       }
     }
@@ -1087,9 +1087,7 @@ 
LogObjectManager::_solve_internal_filename_conflicts(LogObject *log_object, int
 LogObject *
 LogObjectManager::get_object_with_signature(uint64_t signature)
 {
-  for (unsigned i = 0; i < this->_objects.size(); i++) {
-    LogObject *obj = this->_objects[i];
-
+  for (auto obj : this->_objects) {
     if (obj->get_signature() == signature) {
       return obj;
     }
@@ -1100,14 +1098,14 @@ LogObjectManager::get_object_with_signature(uint64_t 
signature)
 void
 LogObjectManager::check_buffer_expiration(long time_now)
 {
-  for (unsigned i = 0; i < this->_objects.size(); i++) {
-    this->_objects[i]->check_buffer_expiration(time_now);
+  for (auto &_object : this->_objects) {
+    _object->check_buffer_expiration(time_now);
   }
 
   ACQUIRE_API_MUTEX("A LogObjectManager::check_buffer_expiration");
 
-  for (unsigned i = 0; i < this->_APIobjects.size(); i++) {
-    this->_APIobjects[i]->check_buffer_expiration(time_now);
+  for (auto &_APIobject : this->_APIobjects) {
+    _APIobject->check_buffer_expiration(time_now);
   }
 
   RELEASE_API_MUTEX("R LogObjectManager::check_buffer_expiration");
@@ -1118,14 +1116,14 @@ LogObjectManager::preproc_buffers(int idx)
 {
   size_t buffers_preproced = 0;
 
-  for (unsigned i = 0; i < this->_objects.size(); i++) {
-    buffers_preproced += this->_objects[i]->preproc_buffers(idx);
+  for (auto &_object : this->_objects) {
+    buffers_preproced += _object->preproc_buffers(idx);
   }
 
   ACQUIRE_API_MUTEX("A LogObjectManager::preproc_buffers");
 
-  for (unsigned i = 0; i < this->_APIobjects.size(); i++) {
-    buffers_preproced += this->_APIobjects[i]->preproc_buffers(idx);
+  for (auto &_APIobject : this->_APIobjects) {
+    buffers_preproced += _APIobject->preproc_buffers(idx);
   }
 
   RELEASE_API_MUTEX("R LogObjectManager::preproc_buffers");
@@ -1189,8 +1187,8 @@ LogObjectManager::transfer_objects(LogObjectManager 
&old_mgr)
 
   if (is_debug_tag_set("log-config-transfer")) {
     Debug("log-config-transfer", "TRANSFER OBJECTS: list of old objects");
-    for (unsigned i = 0; i < old_mgr._objects.size(); i++) {
-      Debug("log-config-transfer", "%s", 
old_mgr._objects[i]->get_original_filename());
+    for (auto &_object : old_mgr._objects) {
+      Debug("log-config-transfer", "%s", _object->get_original_filename());
     }
 
     Debug("log-config-transfer", "TRANSFER OBJECTS : list of new objects");
@@ -1200,12 +1198,11 @@ LogObjectManager::transfer_objects(LogObjectManager 
&old_mgr)
   }
 
   // Transfer the API objects from the old manager. The old manager will 
retain its refcount.
-  for (unsigned i = 0; i < old_mgr._APIobjects.size(); ++i) {
-    manage_api_object(old_mgr._APIobjects[i]);
+  for (auto &_APIobject : old_mgr._APIobjects) {
+    manage_api_object(_APIobject);
   }
 
-  for (unsigned i = 0; i < old_mgr._objects.size(); ++i) {
-    LogObject *old_obj = old_mgr._objects[i];
+  for (auto old_obj : old_mgr._objects) {
     LogObject *new_obj;
 
     Debug("log-config-transfer", "examining existing object %s", 
old_obj->get_base_filename());
@@ -1245,14 +1242,14 @@ LogObjectManager::roll_files(long time_now)
 {
   int num_rolled = 0;
 
-  for (unsigned i = 0; i < this->_objects.size(); i++) {
-    num_rolled += this->_objects[i]->roll_files(time_now);
+  for (auto &_object : this->_objects) {
+    num_rolled += _object->roll_files(time_now);
   }
 
   ACQUIRE_API_MUTEX("A LogObjectManager::roll_files");
 
-  for (unsigned i = 0; i < this->_APIobjects.size(); i++) {
-    num_rolled += this->_APIobjects[i]->roll_files(time_now);
+  for (auto &_APIobject : this->_APIobjects) {
+    num_rolled += _APIobject->roll_files(time_now);
   }
 
   RELEASE_API_MUTEX("R LogObjectManager::roll_files");
@@ -1277,9 +1274,9 @@ LogObjectManager::display(FILE *str)
 LogObject *
 LogObjectManager::find_by_format_name(const char *name) const
 {
-  for (unsigned i = 0; i < this->_objects.size(); ++i) {
-    if (this->_objects[i] && this->_objects[i]->m_format->name_id() == 
LogFormat::id_from_name(name)) {
-      return this->_objects[i];
+  for (auto _object : this->_objects) {
+    if (_object && _object->m_format->name_id() == 
LogFormat::id_from_name(name)) {
+      return _object;
     }
   }
   return nullptr;
@@ -1290,8 +1287,8 @@ LogObjectManager::get_num_collation_clients() const
 {
   unsigned coll_clients = 0;
 
-  for (unsigned i = 0; i < this->_objects.size(); ++i) {
-    if (this->_objects[i] && this->_objects[i]->is_collation_client()) {
+  for (auto _object : this->_objects) {
+    if (_object && _object->is_collation_client()) {
       ++coll_clients;
     }
   }
@@ -1342,14 +1339,14 @@ LogObjectManager::log(LogAccess *lad)
 void
 LogObjectManager::flush_all_objects()
 {
-  for (unsigned i = 0; i < this->_objects.size(); ++i) {
-    this->_objects[i]->force_new_buffer();
+  for (auto &_object : this->_objects) {
+    _object->force_new_buffer();
   }
 
   ACQUIRE_API_MUTEX("A LogObjectManager::flush_all_objects");
 
-  for (unsigned i = 0; i < this->_APIobjects.size(); ++i) {
-    this->_APIobjects[i]->force_new_buffer();
+  for (auto &_APIobject : this->_APIobjects) {
+    _APIobject->force_new_buffer();
   }
 
   RELEASE_API_MUTEX("R LogObjectManager::flush_all_objects");

-- 
To stop receiving notification emails like this one, please contact
bc...@apache.org.

Reply via email to