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

gancho pushed a commit to branch 8.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 2a70ee8e4b2d329da7721dac255d1220791ea1b1
Author: Gancho Tenev <gan...@apache.org>
AuthorDate: Thu Mar 19 15:31:48 2020 -0700

    cachekey plugin docs and clang-format/tidy changes
    
    Cherry-picked some isolated cachekey related changes
    from the following commits to branck 8.1.x:
      aa58b6eb8 Ran clang-format
      4cfd5a738 Ran make clang-tidy
      8e451b774 Fixes spelling in plugins
      7651e269d Ran clang-tidy with modernize-use-default-member-init
      d77cd7316 Ran clang-tidy
---
 plugins/cachekey/README.md   |  2 +-
 plugins/cachekey/cachekey.cc |  1 +
 plugins/cachekey/configs.cc  |  6 +++---
 plugins/cachekey/configs.h   | 10 +++++-----
 plugins/cachekey/pattern.cc  | 10 +++++-----
 plugins/cachekey/pattern.h   | 14 +++++++-------
 plugins/cachekey/plugin.cc   |  4 ++--
 7 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/plugins/cachekey/README.md b/plugins/cachekey/README.md
index 91dc725..6cc5989 100644
--- a/plugins/cachekey/README.md
+++ b/plugins/cachekey/README.md
@@ -1,7 +1,7 @@
 # Description
 This plugin allows some common cache key manipulations based on various HTTP 
request elements.  It can
 
-* sort query parameters to prevent query parameters reordereding from being a 
cache miss
+* sort query parameters to prevent query parameters reordering from being a 
cache miss
 * ignore specific query parameters from the cache key by name or regular 
expression
 * ignore all query parameters from the cache key
 * only use specific query parameters in the cache key by name or regular 
expression
diff --git a/plugins/cachekey/cachekey.cc b/plugins/cachekey/cachekey.cc
index 5eedc76..5f12889 100644
--- a/plugins/cachekey/cachekey.cc
+++ b/plugins/cachekey/cachekey.cc
@@ -23,6 +23,7 @@
 
 #include <cstring> /* strlen() */
 #include <sstream> /* istringstream */
+#include <utility>
 #include "cachekey.h"
 
 static void
diff --git a/plugins/cachekey/configs.cc b/plugins/cachekey/configs.cc
index 05d93ca..938ae1d 100644
--- a/plugins/cachekey/configs.cc
+++ b/plugins/cachekey/configs.cc
@@ -183,8 +183,8 @@ ConfigElements::noIncludeExcludeRules() const
 
 ConfigElements::~ConfigElements()
 {
-  for (auto it = _captures.begin(); it != _captures.end(); it++) {
-    delete it->second;
+  for (auto &_capture : _captures) {
+    delete _capture.second;
   }
 }
 
@@ -414,7 +414,7 @@ Configs::init(int argc, const char *argv[], bool 
perRemapConfig)
 
   for (;;) {
     int opt;
-    opt = getopt_long(argc, (char *const *)argv, "", longopt, nullptr);
+    opt = getopt_long(argc, const_cast<char *const *>(argv), "", longopt, 
nullptr);
 
     if (opt == -1) {
       break;
diff --git a/plugins/cachekey/configs.h b/plugins/cachekey/configs.h
index 454fb36..e8712f1 100644
--- a/plugins/cachekey/configs.h
+++ b/plugins/cachekey/configs.h
@@ -51,7 +51,7 @@ typedef std::set<CacheKeyKeyType> CacheKeyKeyTypeSet;
 class ConfigElements
 {
 public:
-  ConfigElements() : _sort(false), _remove(false), _skip(false) {}
+  ConfigElements() {}
   virtual ~ConfigElements();
   void setExclude(const char *arg);
   void setInclude(const char *arg);
@@ -92,9 +92,9 @@ protected:
   MultiPattern _includePatterns;
   MultiPattern _excludePatterns;
 
-  bool _sort;
-  bool _remove;
-  bool _skip;
+  bool _sort   = false;
+  bool _remove = false;
+  bool _skip   = false;
 
   std::map<String, MultiPattern *> _captures;
 };
@@ -158,7 +158,7 @@ public:
   /**
    * @brief provides means for post-processing of the plugin parameters to 
finalize the configuration or to "cache" some of the
    * decisions for later use.
-   * @return true if succesful, false if failure.
+   * @return true if successful, false if failure.
    */
   bool finalize();
 
diff --git a/plugins/cachekey/pattern.cc b/plugins/cachekey/pattern.cc
index 27eb94e..c934902 100644
--- a/plugins/cachekey/pattern.cc
+++ b/plugins/cachekey/pattern.cc
@@ -38,7 +38,7 @@ replaceString(String &str, const String &from, const String 
&to)
   }
 }
 
-Pattern::Pattern() : _re(nullptr), _extra(nullptr), _pattern(""), 
_replacement(""), _replace(false), _tokenCount(0) {}
+Pattern::Pattern() : _pattern(""), _replacement("") {}
 
 /**
  * @brief Initializes PCRE pattern by providing the subject and replacement 
strings.
@@ -47,18 +47,18 @@ Pattern::Pattern() : _re(nullptr), _extra(nullptr), 
_pattern(""), _replacement("
  * @return true if successful, false if failure
  */
 bool
-Pattern::init(const String &pattern, const String &replacenemt, bool replace)
+Pattern::init(const String &pattern, const String &replacement, bool replace)
 {
   pcreFree();
 
   _pattern.assign(pattern);
-  _replacement.assign(replacenemt);
+  _replacement.assign(replacement);
   _replace = replace;
 
   _tokenCount = 0;
 
   if (!compile()) {
-    CacheKeyDebug("failed to initialize pattern:'%s', replacement:'%s'", 
pattern.c_str(), replacenemt.c_str());
+    CacheKeyDebug("failed to initialize pattern:'%s', replacement:'%s'", 
pattern.c_str(), replacement.c_str());
     pcreFree();
     return false;
   }
@@ -151,7 +151,7 @@ Pattern::pcreFree()
 }
 
 /**
- * @bried Destructor, frees PCRE related resources.
+ * @brief Destructor, frees PCRE related resources.
  */
 Pattern::~Pattern()
 {
diff --git a/plugins/cachekey/pattern.h b/plugins/cachekey/pattern.h
index 876edf0..2b36fd7 100644
--- a/plugins/cachekey/pattern.h
+++ b/plugins/cachekey/pattern.h
@@ -45,7 +45,7 @@ public:
   Pattern();
   virtual ~Pattern();
 
-  bool init(const String &pattern, const String &replacenemt, bool replace);
+  bool init(const String &pattern, const String &replacement, bool replace);
   bool init(const String &config);
   bool empty() const;
   bool match(const String &subject);
@@ -57,16 +57,16 @@ private:
   bool compile();
   void pcreFree();
 
-  pcre *_re;          /**< @brief PCRE compiled info structure, computed 
during initialization */
-  pcre_extra *_extra; /**< @brief PCRE study data block, computed during 
initialization */
+  pcre *_re          = nullptr; /**< @brief PCRE compiled info structure, 
computed during initialization */
+  pcre_extra *_extra = nullptr; /**< @brief PCRE study data block, computed 
during initialization */
 
   String _pattern;     /**< @brief PCRE pattern string, containing PCRE 
patterns and capturing groups. */
   String _replacement; /**< @brief PCRE replacement string, containing $0..$9 
to be replaced with content of the capturing groups */
 
-  bool _replace; /**< @brief true if a replacement is needed, false if not, 
this is to distinguish between an empty replacement
-                    string and no replacement needed case */
+  bool _replace = false; /**< @brief true if a replacement is needed, false if 
not, this is to distinguish between an empty
+                    replacement string and no replacement needed case */
 
-  int _tokenCount;              /**< @brief number of replacements $0..$9 
found in the replacement string if not empty */
+  int _tokenCount = 0;          /**< @brief number of replacements $0..$9 
found in the replacement string if not empty */
   int _tokens[TOKENCOUNT];      /**< @brief replacement index 0..9, since they 
can be used in the replacement string in any order */
   int _tokenOffset[TOKENCOUNT]; /**< @brief replacement offset inside the 
replacement string */
 };
@@ -77,7 +77,7 @@ private:
 class MultiPattern
 {
 public:
-  MultiPattern(const String name = "") : _name(name) {}
+  MultiPattern(const String &name = "") : _name(name) {}
   virtual ~MultiPattern();
 
   bool empty() const;
diff --git a/plugins/cachekey/plugin.cc b/plugins/cachekey/plugin.cc
index a05117f..d92c079 100644
--- a/plugins/cachekey/plugin.cc
+++ b/plugins/cachekey/plugin.cc
@@ -165,7 +165,7 @@ TSRemapNewInstance(int argc, char *argv[], void **instance, 
char *errBuf, int er
 void
 TSRemapDeleteInstance(void *instance)
 {
-  Configs *config = (Configs *)instance;
+  Configs *config = static_cast<Configs *>(instance);
   delete config;
 }
 
@@ -181,7 +181,7 @@ TSRemapDeleteInstance(void *instance)
 TSRemapStatus
 TSRemapDoRemap(void *instance, TSHttpTxn txn, TSRemapRequestInfo *rri)
 {
-  Configs *config = (Configs *)instance;
+  Configs *config = static_cast<Configs *>(instance);
 
   if (nullptr != config) {
     setCacheKey(txn, config, rri);

Reply via email to