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 2015/03/23 21:32:42 UTC

[09/52] [partial] trafficserver git commit: TS-3419 Fix some enum's such that clang-format can handle it the way we want. Basically this means having a trailing , on short enum's. TS-3419 Run clang-format over most of the source

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_auth_api.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_auth_api.h b/lib/ts/ink_auth_api.h
index 9fca069..bec81b8 100644
--- a/lib/ts/ink_auth_api.h
+++ b/lib/ts/ink_auth_api.h
@@ -29,8 +29,7 @@
 
 #include "ink_defs.h"
 
-typedef union
-{
+typedef union {
   uint64_t u64[2];
   uint32_t u32[4];
   uint16_t u16[8];
@@ -40,81 +39,41 @@ typedef union
 class INK_AUTH_SEED
 {
 public:
-  const void *data() const
+  const void *
+  data() const
   {
     return m_data;
   }
-  unsigned length() const
+  unsigned
+  length() const
   {
     return m_length;
   }
 
-  inline INK_AUTH_SEED(const void *x, unsigned ln)
-  {
-    init(x, ln);
-  }
+  inline INK_AUTH_SEED(const void *x, unsigned ln) { init(x, ln); }
 
-  inline INK_AUTH_SEED(const uint8_t & x)
-  {
-    init((const void *) &x, sizeof(x));
-  }
-  inline INK_AUTH_SEED(const uint16_t & x)
-  {
-    init((const void *) &x, sizeof(x));
-  }
-  inline INK_AUTH_SEED(const uint32_t & x)
-  {
-    init((const void *) &x, sizeof(x));
-  }
-  inline INK_AUTH_SEED(const uint64_t & x)
-  {
-    init((const void *) &x, sizeof(x));
-  }
-  inline INK_AUTH_SEED(const int8_t & x)
-  {
-    init((const void *) &x, sizeof(x));
-  }
-  inline INK_AUTH_SEED(const int16_t & x)
-  {
-    init((const void *) &x, sizeof(x));
-  }
-  inline INK_AUTH_SEED(const int32_t & x)
-  {
-    init((const void *) &x, sizeof(x));
-  }
-  inline INK_AUTH_SEED(const int64_t & x)
-  {
-    init((const void *) &x, sizeof(x));
-  }
+  inline INK_AUTH_SEED(const uint8_t &x) { init((const void *)&x, sizeof(x)); }
+  inline INK_AUTH_SEED(const uint16_t &x) { init((const void *)&x, sizeof(x)); }
+  inline INK_AUTH_SEED(const uint32_t &x) { init((const void *)&x, sizeof(x)); }
+  inline INK_AUTH_SEED(const uint64_t &x) { init((const void *)&x, sizeof(x)); }
+  inline INK_AUTH_SEED(const int8_t &x) { init((const void *)&x, sizeof(x)); }
+  inline INK_AUTH_SEED(const int16_t &x) { init((const void *)&x, sizeof(x)); }
+  inline INK_AUTH_SEED(const int32_t &x) { init((const void *)&x, sizeof(x)); }
+  inline INK_AUTH_SEED(const int64_t &x) { init((const void *)&x, sizeof(x)); }
 
-  inline INK_AUTH_SEED(const INK_AUTH_TOKEN & x)
-  {
-    init((const void *) &(x.u8[0]), sizeof(x.u8));
-  }
+  inline INK_AUTH_SEED(const INK_AUTH_TOKEN &x) { init((const void *)&(x.u8[0]), sizeof(x.u8)); }
 
-  inline INK_AUTH_SEED(const char *str)
-  {
-    init((const void *) str, strlen((const char *) str));
-  }
+  inline INK_AUTH_SEED(const char *str) { init((const void *)str, strlen((const char *)str)); }
 
-  inline INK_AUTH_SEED(const char *str, unsigned ln)
-  {
-    init((const void *) str, ln);
-  }
+  inline INK_AUTH_SEED(const char *str, unsigned ln) { init((const void *)str, ln); }
 
-  inline INK_AUTH_SEED(const unsigned char *str)
-  {
-    init((const void *) str, strlen((const char *) str));
-  }
+  inline INK_AUTH_SEED(const unsigned char *str) { init((const void *)str, strlen((const char *)str)); }
 
-  inline INK_AUTH_SEED(const unsigned char *str, unsigned ln)
-  {
-    init((const void *) str, ln);
-  }
+  inline INK_AUTH_SEED(const unsigned char *str, unsigned ln) { init((const void *)str, ln); }
 
 protected:
-
-  void init(const void *d, unsigned l)
+  void
+  init(const void *d, unsigned l)
   {
     m_data = d;
     m_length = l;
@@ -125,98 +84,94 @@ protected:
 };
 
 
-void ink_make_token(INK_AUTH_TOKEN * tok, const INK_AUTH_TOKEN & mask, const INK_AUTH_SEED * const *seeds, int slen);
+void ink_make_token(INK_AUTH_TOKEN *tok, const INK_AUTH_TOKEN &mask, const INK_AUTH_SEED *const *seeds, int slen);
 
-uint32_t ink_make_token32(uint32_t mask, const INK_AUTH_SEED * const *seeds, int slen);
-uint64_t ink_make_token64(uint64_t mask, const INK_AUTH_SEED * const *seeds, int slen);
+uint32_t ink_make_token32(uint32_t mask, const INK_AUTH_SEED *const *seeds, int slen);
+uint64_t ink_make_token64(uint64_t mask, const INK_AUTH_SEED *const *seeds, int slen);
 
 uint32_t ink_get_rand();
 
-#define INK_TOKENS_EQUAL(m,t1,t2) ((((t1)^(t2))&(~(m))) == 0)
+#define INK_TOKENS_EQUAL(m, t1, t2) ((((t1) ^ (t2)) & (~(m))) == 0)
 
 //
 // Helper functions - wiil create INK_AUTH_SEEDs from base types on fly
 //
 inline uint32_t
-ink_make_token32(uint32_t mask, const INK_AUTH_SEED & s1)
+ink_make_token32(uint32_t mask, const INK_AUTH_SEED &s1)
 {
-  const INK_AUTH_SEED *s[] = { &s1 };
+  const INK_AUTH_SEED *s[] = {&s1};
   return ink_make_token32(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint32_t
-ink_make_token32(uint32_t mask, const INK_AUTH_SEED & s1, const INK_AUTH_SEED & s2)
+ink_make_token32(uint32_t mask, const INK_AUTH_SEED &s1, const INK_AUTH_SEED &s2)
 {
-  const INK_AUTH_SEED *s[] = { &s1, &s2 };
+  const INK_AUTH_SEED *s[] = {&s1, &s2};
   return ink_make_token32(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint32_t
-ink_make_token32(uint32_t mask, const INK_AUTH_SEED & s1, const INK_AUTH_SEED & s2, const INK_AUTH_SEED & s3)
+ink_make_token32(uint32_t mask, const INK_AUTH_SEED &s1, const INK_AUTH_SEED &s2, const INK_AUTH_SEED &s3)
 {
-  const INK_AUTH_SEED *s[] = { &s1, &s2, &s3 };
+  const INK_AUTH_SEED *s[] = {&s1, &s2, &s3};
   return ink_make_token32(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint32_t
-ink_make_token32(uint32_t mask,
-                 const INK_AUTH_SEED & s1, const INK_AUTH_SEED & s2, const INK_AUTH_SEED & s3, const INK_AUTH_SEED & s4)
+ink_make_token32(uint32_t mask, const INK_AUTH_SEED &s1, const INK_AUTH_SEED &s2, const INK_AUTH_SEED &s3, const INK_AUTH_SEED &s4)
 {
-  const INK_AUTH_SEED *s[] = { &s1, &s2, &s3, &s4 };
+  const INK_AUTH_SEED *s[] = {&s1, &s2, &s3, &s4};
   return ink_make_token32(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint32_t
-ink_make_token32(uint32_t mask,
-                 const INK_AUTH_SEED & s1,
-                 const INK_AUTH_SEED & s2, const INK_AUTH_SEED & s3, const INK_AUTH_SEED & s4, const INK_AUTH_SEED & s5)
+ink_make_token32(uint32_t mask, const INK_AUTH_SEED &s1, const INK_AUTH_SEED &s2, const INK_AUTH_SEED &s3, const INK_AUTH_SEED &s4,
+                 const INK_AUTH_SEED &s5)
 {
-  const INK_AUTH_SEED *s[] = { &s1, &s2, &s3, &s4, &s5 };
+  const INK_AUTH_SEED *s[] = {&s1, &s2, &s3, &s4, &s5};
   return ink_make_token32(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint64_t
-ink_make_token64(uint64_t mask, const INK_AUTH_SEED & s1)
+ink_make_token64(uint64_t mask, const INK_AUTH_SEED &s1)
 {
-  const INK_AUTH_SEED *s[] = { &s1 };
+  const INK_AUTH_SEED *s[] = {&s1};
   return ink_make_token64(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint64_t
-ink_make_token64(uint64_t mask, const INK_AUTH_SEED & s1, const INK_AUTH_SEED & s2)
+ink_make_token64(uint64_t mask, const INK_AUTH_SEED &s1, const INK_AUTH_SEED &s2)
 {
-  const INK_AUTH_SEED *s[] = { &s1, &s2 };
+  const INK_AUTH_SEED *s[] = {&s1, &s2};
   return ink_make_token64(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint64_t
-ink_make_token64(uint64_t mask, const INK_AUTH_SEED & s1, const INK_AUTH_SEED & s2, const INK_AUTH_SEED & s3)
+ink_make_token64(uint64_t mask, const INK_AUTH_SEED &s1, const INK_AUTH_SEED &s2, const INK_AUTH_SEED &s3)
 {
-  const INK_AUTH_SEED *s[] = { &s1, &s2, &s3 };
+  const INK_AUTH_SEED *s[] = {&s1, &s2, &s3};
   return ink_make_token64(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint64_t
-ink_make_token64(uint64_t mask,
-                 const INK_AUTH_SEED & s1, const INK_AUTH_SEED & s2, const INK_AUTH_SEED & s3, const INK_AUTH_SEED & s4)
+ink_make_token64(uint64_t mask, const INK_AUTH_SEED &s1, const INK_AUTH_SEED &s2, const INK_AUTH_SEED &s3, const INK_AUTH_SEED &s4)
 {
-  const INK_AUTH_SEED *s[] = { &s1, &s2, &s3, &s4 };
+  const INK_AUTH_SEED *s[] = {&s1, &s2, &s3, &s4};
   return ink_make_token64(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline uint64_t
-ink_make_token64(uint64_t mask,
-                 const INK_AUTH_SEED & s1,
-                 const INK_AUTH_SEED & s2, const INK_AUTH_SEED & s3, const INK_AUTH_SEED & s4, const INK_AUTH_SEED & s5)
+ink_make_token64(uint64_t mask, const INK_AUTH_SEED &s1, const INK_AUTH_SEED &s2, const INK_AUTH_SEED &s3, const INK_AUTH_SEED &s4,
+                 const INK_AUTH_SEED &s5)
 {
-  const INK_AUTH_SEED *s[] = { &s1, &s2, &s3, &s4, &s5 };
+  const INK_AUTH_SEED *s[] = {&s1, &s2, &s3, &s4, &s5};
   return ink_make_token64(mask, s, sizeof(s) / sizeof(*s));
 }
 
 inline int64_t
 INK_AUTH_MAKE_INT_64(uint32_t h, uint32_t l)
 {
-  return int64_t((((uint64_t) h) << 32) + (uint32_t) l);
+  return int64_t((((uint64_t)h) << 32) + (uint32_t)l);
 }
 
 inline int64_t

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_base64.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_base64.cc b/lib/ts/ink_base64.cc
index ee87324..7a67ad1 100644
--- a/lib/ts/ink_base64.cc
+++ b/lib/ts/ink_base64.cc
@@ -108,18 +108,14 @@ ats_base64_encode(const char *inBuffer, size_t inBufferSize, char *outBuffer, si
 
 /* Converts a printable character to it's six bit representation */
 const unsigned char printableToSixBit[256] = {
-  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 62, 64, 63,
-  52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
-  10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 63, 64, 26, 27,
-  28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
-  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
-  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
-};
+  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 62, 64, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64,
+  64, 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 63,
+  64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64,
+  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+  64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64};
 
 bool
 ats_base64_decode(const char *inBuffer, size_t inBufferSize, unsigned char *outBuffer, size_t outBufSize, size_t *length)
@@ -139,9 +135,9 @@ ats_base64_decode(const char *inBuffer, size_t inBufferSize, unsigned char *outB
     ++inBytes;
 
   for (size_t i = 0; i < inBytes; i += 4) {
-    buf[0] = (unsigned char) (DECODE(inBuffer[0]) << 2 | DECODE(inBuffer[1]) >> 4);
-    buf[1] = (unsigned char) (DECODE(inBuffer[1]) << 4 | DECODE(inBuffer[2]) >> 2);
-    buf[2] = (unsigned char) (DECODE(inBuffer[2]) << 6 | DECODE(inBuffer[3]));
+    buf[0] = (unsigned char)(DECODE(inBuffer[0]) << 2 | DECODE(inBuffer[1]) >> 4);
+    buf[1] = (unsigned char)(DECODE(inBuffer[1]) << 4 | DECODE(inBuffer[2]) >> 2);
+    buf[2] = (unsigned char)(DECODE(inBuffer[2]) << 6 | DECODE(inBuffer[3]));
 
     buf += 3;
     inBuffer += 4;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_cap.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_cap.cc b/lib/ts/ink_cap.cc
index a27d64e..569e3f8 100644
--- a/lib/ts/ink_cap.cc
+++ b/lib/ts/ink_cap.cc
@@ -21,10 +21,10 @@
     limitations under the License.
 */
 
-# include "ink_config.h"
-# include "Diags.h"
-# include "ink_cap.h"
-# include "ink_thread.h"
+#include "ink_config.h"
+#include "Diags.h"
+#include "ink_cap.h"
+#include "ink_thread.h"
 
 #include <grp.h>
 
@@ -40,58 +40,51 @@
 // and if it does, it is likely that some fundamental security assumption has been violated. In that case
 // it is dangerous to continue.
 
-# if !TS_USE_POSIX_CAP
+#if !TS_USE_POSIX_CAP
 ink_mutex ElevateAccess::lock = INK_MUTEX_INIT;
 #endif
 
-#define DEBUG_CREDENTIALS(tag)  do { \
-  if (is_debug_tag_set(tag)) { \
-    uid_t uid = -1, euid = -1, suid = -1; \
-    gid_t gid = -1, egid = -1, sgid = -1; \
-    getresuid(&uid, &euid, &suid); \
-    getresgid(&gid, &egid, &sgid); \
-    Debug(tag, "uid=%ld, gid=%ld, euid=%ld, egid=%ld, suid=%ld, sgid=%ld", \
-        static_cast<long>(uid), \
-        static_cast<long>(gid), \
-        static_cast<long>(euid), \
-        static_cast<long>(egid), \
-        static_cast<long>(suid), \
-        static_cast<long>(sgid) ); \
-  } \
-} while (0)
+#define DEBUG_CREDENTIALS(tag)                                                                                               \
+  do {                                                                                                                       \
+    if (is_debug_tag_set(tag)) {                                                                                             \
+      uid_t uid = -1, euid = -1, suid = -1;                                                                                  \
+      gid_t gid = -1, egid = -1, sgid = -1;                                                                                  \
+      getresuid(&uid, &euid, &suid);                                                                                         \
+      getresgid(&gid, &egid, &sgid);                                                                                         \
+      Debug(tag, "uid=%ld, gid=%ld, euid=%ld, egid=%ld, suid=%ld, sgid=%ld", static_cast<long>(uid), static_cast<long>(gid), \
+            static_cast<long>(euid), static_cast<long>(egid), static_cast<long>(suid), static_cast<long>(sgid));             \
+    }                                                                                                                        \
+  } while (0)
 
 #if TS_USE_POSIX_CAP
 
-#define DEBUG_PRIVILEGES(tag)  do { \
-  if (is_debug_tag_set(tag)) { \
-    cap_t caps = cap_get_proc(); \
-    char* caps_text = cap_to_text(caps, NULL); \
-    Debug(tag, "caps='%s', core=%s, death signal=%d, thread=0x%llx", \
-        caps_text, \
-        is_dumpable(), \
-        death_signal(), \
-        (unsigned long long)pthread_self() ); \
-    cap_free(caps_text); \
-    cap_free(caps); \
-  } \
-} while (0)
+#define DEBUG_PRIVILEGES(tag)                                                                                    \
+  do {                                                                                                           \
+    if (is_debug_tag_set(tag)) {                                                                                 \
+      cap_t caps = cap_get_proc();                                                                               \
+      char *caps_text = cap_to_text(caps, NULL);                                                                 \
+      Debug(tag, "caps='%s', core=%s, death signal=%d, thread=0x%llx", caps_text, is_dumpable(), death_signal(), \
+            (unsigned long long)pthread_self());                                                                 \
+      cap_free(caps_text);                                                                                       \
+      cap_free(caps);                                                                                            \
+    }                                                                                                            \
+  } while (0)
 
 #else /* TS_USE_POSIX_CAP */
 
-#define DEBUG_PRIVILEGES(tag)  do { \
-  if (is_debug_tag_set(tag)) { \
-    Debug(tag, "caps='', core=%s, death signal=%d, thread=0x%llx", \
-        is_dumpable(), \
-        death_signal(), \
-        (unsigned long long)pthread_self() ); \
-  } \
-} while(0)
+#define DEBUG_PRIVILEGES(tag)                                                                       \
+  do {                                                                                              \
+    if (is_debug_tag_set(tag)) {                                                                    \
+      Debug(tag, "caps='', core=%s, death signal=%d, thread=0x%llx", is_dumpable(), death_signal(), \
+            (unsigned long long)pthread_self());                                                    \
+    }                                                                                               \
+  } while (0)
 
 #endif /* TS_USE_POSIX_CAP */
 
 #if !HAVE_GETRESUID
 static int
-getresuid(uid_t * uid, uid_t * euid, uid_t * suid)
+getresuid(uid_t *uid, uid_t *euid, uid_t *suid)
 {
   *uid = getuid();
   *euid = geteuid();
@@ -101,7 +94,7 @@ getresuid(uid_t * uid, uid_t * euid, uid_t * suid)
 
 #if !HAVE_GETRESGID
 static int
-getresgid(gid_t * gid, gid_t * egid, gid_t * sgid)
+getresgid(gid_t *gid, gid_t *egid, gid_t *sgid)
 {
   *gid = getgid();
   *egid = getegid();
@@ -145,14 +138,14 @@ death_signal()
 }
 
 void
-DebugCapabilities(char const* tag)
+DebugCapabilities(char const *tag)
 {
   DEBUG_CREDENTIALS(tag);
   DEBUG_PRIVILEGES(tag);
 }
 
 static void
-impersonate(const struct passwd * pwd, ImpersonationLevel level)
+impersonate(const struct passwd *pwd, ImpersonationLevel level)
 {
   int deathsig = death_signal();
   bool dumpable = false;
@@ -207,9 +200,9 @@ impersonate(const struct passwd * pwd, ImpersonationLevel level)
 void
 ImpersonateUserID(uid_t uid, ImpersonationLevel level)
 {
-  struct passwd * pwd;
-  struct passwd   pbuf;
-  char            buf[max_passwd_size()];
+  struct passwd *pwd;
+  struct passwd pbuf;
+  char buf[max_passwd_size()];
 
   if (getpwuid_r(uid, &pbuf, buf, sizeof(buf), &pwd) != 0) {
     Fatal("missing password database entry for UID %ld: %s", (long)uid, strerror(errno));
@@ -224,11 +217,11 @@ ImpersonateUserID(uid_t uid, ImpersonationLevel level)
 }
 
 void
-ImpersonateUser(const char * user, ImpersonationLevel level)
+ImpersonateUser(const char *user, ImpersonationLevel level)
 {
-  struct passwd * pwd;
-  struct passwd   pbuf;
-  char            buf[max_passwd_size()];
+  struct passwd *pwd;
+  struct passwd pbuf;
+  char buf[max_passwd_size()];
 
   if (*user == '#') {
     // Numeric user notation.
@@ -254,9 +247,9 @@ bool
 PreserveCapabilities()
 {
   int zret = 0;
-# if TS_USE_POSIX_CAP
+#if TS_USE_POSIX_CAP
   zret = prctl(PR_SET_KEEPCAPS, 1);
-# endif
+#endif
   Debug("privileges", "[PreserveCapabilities] zret : %d\n", zret);
   return zret == 0;
 }
@@ -266,19 +259,19 @@ bool
 RestrictCapabilities()
 {
   int zret = 0; // return value.
-# if TS_USE_POSIX_CAP
-    cap_t caps = cap_init(); // start with nothing.
-    // Capabilities we need.
-    cap_value_t perm_list[] = { CAP_NET_ADMIN, CAP_NET_BIND_SERVICE, CAP_IPC_LOCK, CAP_DAC_OVERRIDE};
-    static int const PERM_CAP_COUNT = sizeof(perm_list)/sizeof(*perm_list);
-    cap_value_t eff_list[] = { CAP_NET_ADMIN, CAP_NET_BIND_SERVICE, CAP_IPC_LOCK};
-    static int const EFF_CAP_COUNT = sizeof(eff_list)/sizeof(*eff_list);
-
-    cap_set_flag(caps, CAP_PERMITTED, PERM_CAP_COUNT, perm_list, CAP_SET);
-    cap_set_flag(caps, CAP_EFFECTIVE, EFF_CAP_COUNT, eff_list, CAP_SET);
-    zret = cap_set_proc(caps);
-    cap_free(caps);
-#  endif
+#if TS_USE_POSIX_CAP
+  cap_t caps = cap_init(); // start with nothing.
+  // Capabilities we need.
+  cap_value_t perm_list[] = {CAP_NET_ADMIN, CAP_NET_BIND_SERVICE, CAP_IPC_LOCK, CAP_DAC_OVERRIDE};
+  static int const PERM_CAP_COUNT = sizeof(perm_list) / sizeof(*perm_list);
+  cap_value_t eff_list[] = {CAP_NET_ADMIN, CAP_NET_BIND_SERVICE, CAP_IPC_LOCK};
+  static int const EFF_CAP_COUNT = sizeof(eff_list) / sizeof(*eff_list);
+
+  cap_set_flag(caps, CAP_PERMITTED, PERM_CAP_COUNT, perm_list, CAP_SET);
+  cap_set_flag(caps, CAP_EFFECTIVE, EFF_CAP_COUNT, eff_list, CAP_SET);
+  zret = cap_set_proc(caps);
+  cap_free(caps);
+#endif
   Debug("privileges", "[RestrictCapabilities] zret : %d\n", zret);
   return zret == 0;
 }
@@ -288,7 +281,7 @@ EnableCoreFile(bool flag)
 {
   int zret = 0;
 
-# if defined(PR_SET_DUMPABLE)
+#if defined(PR_SET_DUMPABLE)
   int state = flag ? 1 : 0;
   if (0 > (zret = prctl(PR_SET_DUMPABLE, state, 0, 0, 0))) {
     Warning("Unable to set PR_DUMPABLE : %s", strerror(errno));
@@ -296,7 +289,7 @@ EnableCoreFile(bool flag)
     zret = ENOSYS; // best guess
     Warning("Call to set PR_DUMPABLE was ineffective");
   }
-# endif  // linux check
+#endif // linux check
 
   Debug("privileges", "[EnableCoreFile] zret : %d\n", zret);
   return zret == 0;
@@ -359,8 +352,7 @@ elevateFileAccess(unsigned level, bool state)
 }
 #endif
 
-ElevateAccess::ElevateAccess(const bool state, unsigned lvl)
-  : elevated(false), saved_uid(geteuid()), level(lvl)
+ElevateAccess::ElevateAccess(const bool state, unsigned lvl) : elevated(false), saved_uid(geteuid()), level(lvl)
 {
   // XXX Squash a clang [-Wunused-private-field] warning. The right solution is probably to extract
   // the capabilities into a policy class.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_cap.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_cap.h b/lib/ts/ink_cap.h
index f763316..7cef1cc 100644
--- a/lib/ts/ink_cap.h
+++ b/lib/ts/ink_cap.h
@@ -21,14 +21,13 @@
   limitations under the License.
 
  */
-#if !defined (_ink_cap_h_)
+#if !defined(_ink_cap_h_)
 #define _ink_cap_h_
 #include "ink_mutex.h"
 
 /// Generate a debug message with the current capabilities for the process.
-extern void DebugCapabilities(
-  char const* tag ///< Debug message tag.
-);
+extern void DebugCapabilities(char const *tag ///< Debug message tag.
+                              );
 /// Set capabilities to persist across change of user id.
 /// @return true on success
 extern bool PreserveCapabilities();
@@ -40,26 +39,25 @@ extern bool RestrictCapabilities();
     @a flag sets whether core files are enabled on crash.
     @return true on success
  */
-extern bool EnableCoreFile(
-  bool flag ///< New enable state.
-);
+extern bool EnableCoreFile(bool flag ///< New enable state.
+                           );
 
 void EnableDeathSignal(int signum);
 
 enum ImpersonationLevel {
-  IMPERSONATE_EFFECTIVE,  // Set the effective credential set.
-  IMPERSONATE_PERMANENT   // Set the real credential (permanently).
+  IMPERSONATE_EFFECTIVE, // Set the effective credential set.
+  IMPERSONATE_PERMANENT  // Set the real credential (permanently).
 };
 
-void ImpersonateUser(const char * user, ImpersonationLevel level);
+void ImpersonateUser(const char *user, ImpersonationLevel level);
 void ImpersonateUserID(uid_t user, ImpersonationLevel level);
 
-class ElevateAccess {
+class ElevateAccess
+{
 public:
-
   typedef enum {
-    FILE_PRIVILEGE  = 0x1u, // Access filesystem objects with privilege
-    TRACE_PRIVILEGE = 0x2u  // Trace other processes with privilege
+    FILE_PRIVILEGE = 0x1u, // Access filesystem objects with privilege
+    TRACE_PRIVILEGE = 0x2u // Trace other processes with privilege
   } privilege_level;
 
   ElevateAccess(const bool state, unsigned level = FILE_PRIVILEGE);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_code.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_code.cc b/lib/ts/ink_code.cc
index 9d17a44..e099b9c 100644
--- a/lib/ts/ink_code.cc
+++ b/lib/ts/ink_code.cc
@@ -30,17 +30,20 @@
 
 ats::CryptoHash const ats::CRYPTO_HASH_ZERO; // default constructed is correct.
 
-MD5Context::MD5Context() {
+MD5Context::MD5Context()
+{
   MD5_Init(&_ctx);
 }
 
 bool
-MD5Context::update(void const* data, int length) {
+MD5Context::update(void const *data, int length)
+{
   return 0 != MD5_Update(&_ctx, data, length);
 }
 
 bool
-MD5Context::finalize(CryptoHash& hash) {
+MD5Context::finalize(CryptoHash &hash)
+{
   return 0 != MD5_Final(hash.u8, &_ctx);
 }
 
@@ -48,7 +51,8 @@ MD5Context::finalize(CryptoHash& hash) {
   @brief Wrapper around MD5_Init
 */
 int
-ink_code_incr_md5_init(INK_DIGEST_CTX * context) {
+ink_code_incr_md5_init(INK_DIGEST_CTX *context)
+{
   return MD5_Init(context);
 }
 
@@ -56,7 +60,8 @@ ink_code_incr_md5_init(INK_DIGEST_CTX * context) {
   @brief Wrapper around MD5_Update
 */
 int
-ink_code_incr_md5_update(INK_DIGEST_CTX * context, const char *input, int input_length) {
+ink_code_incr_md5_update(INK_DIGEST_CTX *context, const char *input, int input_length)
+{
   return MD5_Update(context, input, input_length);
 }
 
@@ -64,8 +69,9 @@ ink_code_incr_md5_update(INK_DIGEST_CTX * context, const char *input, int input_
   @brief Wrapper around MD5_Final
 */
 int
-ink_code_incr_md5_final(char *sixteen_byte_hash_pointer, INK_DIGEST_CTX * context) {
-  return MD5_Final((unsigned char*)sixteen_byte_hash_pointer, context);
+ink_code_incr_md5_final(char *sixteen_byte_hash_pointer, INK_DIGEST_CTX *context)
+{
+  return MD5_Final((unsigned char *)sixteen_byte_hash_pointer, context);
 }
 
 /**
@@ -74,7 +80,7 @@ ink_code_incr_md5_final(char *sixteen_byte_hash_pointer, INK_DIGEST_CTX * contex
   @return always returns 0, maybe some error checking should be done
 */
 int
-ink_code_md5(unsigned char const* input, int input_length, unsigned char *sixteen_byte_hash_pointer)
+ink_code_md5(unsigned char const *input, int input_length, unsigned char *sixteen_byte_hash_pointer)
 {
   MD5_CTX context;
 
@@ -110,7 +116,7 @@ ink_code_md5_stringify(char *dest33, const size_t destSize, const char *md5)
   }
   ink_assert(dest33[32] == '\0');
   return (dest33);
-}                               /* End ink_code_stringify_md5(const char *md5) */
+} /* End ink_code_stringify_md5(const char *md5) */
 
 /**
   @brief Converts a MD5 to a null-terminated string
@@ -126,12 +132,12 @@ ink_code_md5_stringify(char *dest33, const size_t destSize, const char *md5)
 */
 /* reentrant version */
 char *
-ink_code_to_hex_str(char *dest33, uint8_t const* hash)
+ink_code_to_hex_str(char *dest33, uint8_t const *hash)
 {
   int i;
   char *d;
 
-  static char hex_digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
+  static char hex_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
 
   d = dest33;
   for (i = 0; i < 16; i += 4) {
@@ -148,4 +154,3 @@ ink_code_to_hex_str(char *dest33, uint8_t const* hash)
   *d = '\0';
   return (dest33);
 }
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_code.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_code.h b/lib/ts/ink_code.h
index ee492f6..5d71cab 100644
--- a/lib/ts/ink_code.h
+++ b/lib/ts/ink_code.h
@@ -22,7 +22,7 @@
  */
 
 #ifndef _ink_code_h_
-#define	_ink_code_h_
+#define _ink_code_h_
 
 #include "ink_apidefs.h"
 #include <openssl/md5.h>
@@ -35,11 +35,11 @@ typedef MD5_CTX INK_DIGEST_CTX;
   Wrappers around the MD5 functions, all of this should be depericated and just use the functions directly
 */
 
-inkcoreapi int ink_code_md5(unsigned char const* input, int input_length, unsigned char *sixteen_byte_hash_pointer);
+inkcoreapi int ink_code_md5(unsigned char const *input, int input_length, unsigned char *sixteen_byte_hash_pointer);
 inkcoreapi char *ink_code_md5_stringify(char *dest33, const size_t destSize, const char *md5);
-inkcoreapi char *ink_code_to_hex_str(char *dest33, uint8_t const* md5);
+inkcoreapi char *ink_code_to_hex_str(char *dest33, uint8_t const *md5);
 
-inkcoreapi int ink_code_incr_md5_init(INK_DIGEST_CTX * context);
-inkcoreapi int ink_code_incr_md5_update(INK_DIGEST_CTX * context, const char *input, int input_length);
-inkcoreapi int ink_code_incr_md5_final(char *sixteen_byte_hash_pointer, INK_DIGEST_CTX * context);
+inkcoreapi int ink_code_incr_md5_init(INK_DIGEST_CTX *context);
+inkcoreapi int ink_code_incr_md5_update(INK_DIGEST_CTX *context, const char *input, int input_length);
+inkcoreapi int ink_code_incr_md5_final(char *sixteen_byte_hash_pointer, INK_DIGEST_CTX *context);
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_defs.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_defs.cc b/lib/ts/ink_defs.cc
index b9ba1b1..3deb389 100644
--- a/lib/ts/ink_defs.cc
+++ b/lib/ts/ink_defs.cc
@@ -37,7 +37,7 @@
 #endif
 #if defined(linux)
 #include <sys/utsname.h>
-#endif      /* MAGIC_EDITING_TAG */
+#endif /* MAGIC_EDITING_TAG */
 
 int off = 0;
 int on = 1;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_defs.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_defs.h b/lib/ts/ink_defs.h
index 8a23d04..d162a8e 100644
--- a/lib/ts/ink_defs.h
+++ b/lib/ts/ink_defs.h
@@ -22,7 +22,7 @@
  */
 
 #ifndef _ink_defs_h
-#define	_ink_defs_h
+#define _ink_defs_h
 
 
 #include "ink_config.h"
@@ -30,22 +30,22 @@
 #include <sys/mman.h>
 
 #ifdef HAVE_STDINT_H
-# include <stdint.h>
+#include <stdint.h>
 #else
 // TODO: Add "standard" int types?
 #endif
 
 #ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
+#include <inttypes.h>
 #else
 // TODO: add PRI*64 stuff?
 #endif
 
 #ifndef INT64_MIN
 #define INT64_MAX (9223372036854775807LL)
-#define INT64_MIN (-INT64_MAX -1LL)
+#define INT64_MIN (-INT64_MAX - 1LL)
 #define INT32_MAX (2147483647)
-#define INT32_MIN (-2147483647-1)
+#define INT32_MIN (-2147483647 - 1)
 #endif
 
 #define POSIX_THREAD
@@ -73,67 +73,74 @@
 // Need to use this to avoid problems when calling variadic functions
 // with many arguments. In such cases, a raw '0' or NULL can be
 // interpreted as 32 bits
-#define NULL_PTR static_cast<void*>(0)
+#define NULL_PTR static_cast<void *>(0)
 
 // Determine the element count for an array.
 #ifdef __cplusplus
-template<typename T, unsigned N>
+template <typename T, unsigned N>
 static inline unsigned
-countof(const T (&)[N]) {
+countof(const T(&)[N])
+{
   return N;
 }
 #else
-#  define countof(x) ((unsigned)(sizeof(x)/sizeof((x)[0])))
+#define countof(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
 #endif
 
-#define SOCKOPT_ON ((char*)&on)
-#define SOCKOPT_OFF ((char*)&off)
+#define SOCKOPT_ON ((char *)&on)
+#define SOCKOPT_OFF ((char *)&off)
 
 #ifndef ABS
-#define ABS(x) (((x) < 0) ? ( - (x)) : (x))
+#define ABS(x) (((x) < 0) ? (-(x)) : (x))
 #endif
 
 #ifndef MAX
-#define MAX(x,y) (((x) >= (y)) ? (x) : (y))
+#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
 #endif
 
 #ifndef MIN
-#define MIN(x,y) (((x) <= (y)) ? (x) : (y))
+#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
 #endif
 
 #ifdef __cplusplus
 // We can't use #define for min and max because it will conflict with
 // other declarations of min and max functions.  This conflict
 // occurs with STL
-template<class T> T min(const T a, const T b)
+template <class T>
+T
+min(const T a, const T b)
 {
   return a < b ? a : b;
 }
 
-template<class T> T max(const T a, const T b)
+template <class T>
+T
+max(const T a, const T b)
 {
   return a > b ? a : b;
 }
 #endif
 
-#define ATS_UNUSED __attribute__ ((unused))
-#define ATS_WARN_IF_UNUSED __attribute__ ((warn_unused_result))
-#define	ATS_UNUSED_RETURN(x)	if (x) {}
+#define ATS_UNUSED __attribute__((unused))
+#define ATS_WARN_IF_UNUSED __attribute__((warn_unused_result))
+#define ATS_UNUSED_RETURN(x) \
+  if (x) {                   \
+  }
 
 #ifndef likely
-#define likely(x)	__builtin_expect (!!(x), 1)
+#define likely(x) __builtin_expect(!!(x), 1)
 #endif
 #ifndef unlikely
-#define unlikely(x)	__builtin_expect (!!(x), 0)
+#define unlikely(x) __builtin_expect(!!(x), 0)
 #endif
 
 
 #if TS_USE_HWLOC
-#  include <hwloc.h>
+#include <hwloc.h>
 #endif
 
 #ifndef ROUNDUP
-#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
+#define ROUNDUP(x, y) ((((x) + ((y)-1)) / (y)) * (y))
 #endif
 
 #if defined(MAP_NORESERVE)
@@ -162,8 +169,9 @@ hwloc_topology_t ink_get_topology();
 /** Constants.
  */
 #ifdef __cplusplus
-namespace ts {
-  static const int NO_FD = -1; ///< No or invalid file descriptor.
+namespace ts
+{
+static const int NO_FD = -1; ///< No or invalid file descriptor.
 }
 #endif
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_error.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_error.cc b/lib/ts/ink_error.cc
index 06b9c7d..da4f432 100644
--- a/lib/ts/ink_error.cc
+++ b/lib/ts/ink_error.cc
@@ -27,7 +27,7 @@
 #include "ink_stack_trace.h"
 
 #include <syslog.h>
-#include <signal.h>    /* MAGIC_EDITING_TAG */
+#include <signal.h> /* MAGIC_EDITING_TAG */
 
 static void ink_die_die_die() TS_NORETURN;
 
@@ -51,7 +51,7 @@ ink_die_die_die()
 
 */
 void
-ink_fatal_va(const char * fmt, va_list ap)
+ink_fatal_va(const char *fmt, va_list ap)
 {
   char msg[1024];
   const size_t len = sizeof("FATAL: ") - 1;
@@ -87,11 +87,11 @@ ink_pfatal(const char *message_format, ...)
   char extended_format[4096], message[4096];
 
   int errsav = errno;
-  const char * errno_string = strerror(errsav);
+  const char *errno_string = strerror(errsav);
 
   va_start(ap, message_format);
-  snprintf(extended_format, sizeof(extended_format) - 1, "FATAL: %s <last errno = %d (%s)>",
-           message_format, errsav, (errno_string == NULL ? "unknown" : errno_string));
+  snprintf(extended_format, sizeof(extended_format) - 1, "FATAL: %s <last errno = %d (%s)>", message_format, errsav,
+           (errno_string == NULL ? "unknown" : errno_string));
   extended_format[sizeof(extended_format) - 1] = 0;
   vsnprintf(message, sizeof(message) - 1, extended_format, ap);
   message[sizeof(message) - 1] = 0;
@@ -137,8 +137,8 @@ ink_pwarning(const char *message_format, ...)
 
   va_start(ap, message_format);
   errno_string = strerror(errno);
-  snprintf(extended_format, sizeof(extended_format) - 1, "WARNING: %s <last errno = %d (%s)>",
-           message_format, errno, (errno_string == NULL ? "unknown" : errno_string));
+  snprintf(extended_format, sizeof(extended_format) - 1, "WARNING: %s <last errno = %d (%s)>", message_format, errno,
+           (errno_string == NULL ? "unknown" : errno_string));
   extended_format[sizeof(extended_format) - 1] = 0;
   vsnprintf(message, sizeof(message) - 1, extended_format, ap);
   message[sizeof(message) - 1] = 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_error.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_error.h b/lib/ts/ink_error.h
index cd96d41..aa6f8d8 100644
--- a/lib/ts/ink_error.h
+++ b/lib/ts/ink_error.h
@@ -30,7 +30,7 @@
  ****************************************************************************/
 
 #ifndef _ink_error_h_
-#define	_ink_error_h_
+#define _ink_error_h_
 
 #include <stdarg.h>
 #include "ink_platform.h"

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_exception.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_exception.h b/lib/ts/ink_exception.h
index 85b5d12..2a091f7 100644
--- a/lib/ts/ink_exception.h
+++ b/lib/ts/ink_exception.h
@@ -36,36 +36,36 @@ class Exception
 {
 };
 
-class OSException:public Exception
+class OSException : public Exception
 {
 };
 
-class IOException:public OSException
+class IOException : public OSException
 {
 };
 
-class FileOpenException:public IOException
+class FileOpenException : public IOException
 {
 };
-class FileStatException:public IOException
+class FileStatException : public IOException
 {
 };
-class FileSeekException:public IOException
+class FileSeekException : public IOException
 {
 };
-class FileReadException:public IOException
+class FileReadException : public IOException
 {
 };
-class FileWriteException:public IOException
+class FileWriteException : public IOException
 {
 };
-class FileCloseException:public IOException
+class FileCloseException : public IOException
 {
 };
 
-class MemoryMapException:public OSException
+class MemoryMapException : public OSException
 {
 };
-class MemoryUnmapException:public OSException
+class MemoryUnmapException : public OSException
 {
 };

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_file.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_file.cc b/lib/ts/ink_file.cc
index 0294482..b810ba6 100644
--- a/lib/ts/ink_file.cc
+++ b/lib/ts/ink_file.cc
@@ -46,31 +46,30 @@
 #endif
 
 #if HAVE_LINUX_HDREG_H
-#include <linux/hdreg.h>        /* for struct hd_geometry */
+#include <linux/hdreg.h> /* for struct hd_geometry */
 #endif
 
 #if HAVE_LINUX_FS_H
-#include <linux/fs.h>           /* for BLKGETSIZE.  sys/mount.h is another candidate */
+#include <linux/fs.h> /* for BLKGETSIZE.  sys/mount.h is another candidate */
 #endif
 
 typedef union {
-  uint64_t  u64;
-  uint32_t  u32;
-  off_t     off;
+  uint64_t u64;
+  uint32_t u32;
+  off_t off;
 } ioctl_arg_t;
 
 int
-ink_fputln(FILE * stream, const char *s)
+ink_fputln(FILE *stream, const char *s)
 {
   if (stream && s) {
     int rc = fputs(s, stream);
     if (rc > 0)
       rc += fputc('\n', stream);
     return rc;
-  }
-  else
+  } else
     return -EINVAL;
-}                               /* End ink_fgets */
+} /* End ink_fgets */
 
 /*---------------------------------------------------------------------------*
 
@@ -98,22 +97,22 @@ ink_file_fd_readline(int fd, int bufsz, char *buf)
   int i = 0;
 
   if (bufsz < 2)
-    return (-EINVAL);           /* bufsz must by >= 2 */
+    return (-EINVAL); /* bufsz must by >= 2 */
 
-  while (i < bufsz - 1) {       /* leave 1 byte for NUL */
-    int n = read(fd, &c, 1);    /* read 1 byte */
+  while (i < bufsz - 1) {    /* leave 1 byte for NUL */
+    int n = read(fd, &c, 1); /* read 1 byte */
     if (n == 0)
-      break;                    /* EOF */
+      break; /* EOF */
     if (n < 0)
-      return (n);               /* error */
-    buf[i++] = c;               /* store in buffer */
+      return (n); /* error */
+    buf[i++] = c; /* store in buffer */
     if (c == '\n')
-      break;                    /* stop if stored a LF */
+      break; /* stop if stored a LF */
   }
 
-  buf[i] = '\0';                /* NUL terminate buffer */
-  return (i);                   /* number of bytes read */
-}                               /* End ink_file_fd_readline */
+  buf[i] = '\0'; /* NUL terminate buffer */
+  return (i);    /* number of bytes read */
+} /* End ink_file_fd_readline */
 
 /* Write until NUL */
 int
@@ -121,11 +120,11 @@ ink_file_fd_writestring(int fd, const char *buf)
 {
   int len, i = 0;
 
-  if (buf && (len = strlen(buf)) > 0 && (i = (int) write(fd, buf, (size_t) len) != len))
+  if (buf && (len = strlen(buf)) > 0 && (i = (int)write(fd, buf, (size_t)len) != len))
     i = -1;
 
-  return i;                     /* return chars written */
-}                               /* End ink_file_fd_writestring */
+  return i; /* return chars written */
+} /* End ink_file_fd_writestring */
 
 int
 ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *addpath, int flags)
@@ -158,8 +157,7 @@ ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *add
     //
     if (!rootpath && !(flags & INK_FILEPATH_NOTABOVEROOT))
       rootpath = "";
-  }
-  else {
+  } else {
     // If INK_FILEPATH_NOTABSOLUTE is specified, the caller
     // requires a relative result.  If the rootpath is
     // ommitted, we do not retrieve the working path,
@@ -169,7 +167,7 @@ ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *add
       if (!rootpath)
         rootpath = "";
       else if (rootpath[0] == '/')
-        return EISDIR; //APR_EABSOLUTE;
+        return EISDIR; // APR_EABSOLUTE;
     }
   }
   if (!rootpath) {
@@ -187,7 +185,7 @@ ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *add
                                           // root, and at end, plus trailing
                                           // null
   if (maxlen > (size_t)pathsz) {
-    return E2BIG; //APR_ENAMETOOLONG;
+    return E2BIG; // APR_ENAMETOOLONG;
   }
   if (addpath[0] == '/') {
     // Ignore the given root path, strip off leading
@@ -199,12 +197,11 @@ ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *add
       ++addpath;
     path[0] = '/';
     pathlen = 1;
-  }
-  else {
+  } else {
     // If both paths are relative, fail early
     //
     if (rootpath[0] != '/' && (flags & INK_FILEPATH_NOTRELATIVE))
-      return EBADF; //APR_ERELATIVE;
+      return EBADF; // APR_ERELATIVE;
 
     // Base the result path on the rootpath
     //
@@ -231,32 +228,27 @@ ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *add
     if (seglen == 0 || (seglen == 1 && addpath[0] == '.')) {
       // noop segment (/ or ./) so skip it
       //
-    }
-    else if (seglen == 2 && addpath[0] == '.' && addpath[1] == '.') {
+    } else if (seglen == 2 && addpath[0] == '.' && addpath[1] == '.') {
       // backpath (../)
       if (pathlen == 1 && path[0] == '/') {
         // Attempt to move above root.  Always die if the
         // INK_FILEPATH_SECUREROOTTEST flag is specified.
         //
         if (flags & INK_FILEPATH_SECUREROOTTEST) {
-          return EACCES; //APR_EABOVEROOT;
+          return EACCES; // APR_EABOVEROOT;
         }
 
         // Otherwise this is simply a noop, above root is root.
         // Flag that rootpath was entirely replaced.
         //
         keptlen = 0;
-      }
-      else if (pathlen == 0
-               || (pathlen == 3
-               && !memcmp(path + pathlen - 3, "../", 3))
-               || (pathlen  > 3
-               && !memcmp(path + pathlen - 4, "/../", 4))) {
+      } else if (pathlen == 0 || (pathlen == 3 && !memcmp(path + pathlen - 3, "../", 3)) ||
+                 (pathlen > 3 && !memcmp(path + pathlen - 4, "/../", 4))) {
         // Path is already backpathed or empty, if the
         // INK_FILEPATH_SECUREROOTTEST.was given die now.
         //
         if (flags & INK_FILEPATH_SECUREROOTTEST) {
-          return EACCES; //APR_EABOVEROOT;
+          return EACCES; // APR_EABOVEROOT;
         }
 
         // Otherwise append another backpath, including
@@ -264,12 +256,11 @@ ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *add
         //
         memcpy(path + pathlen, "../", *next ? 3 : 2);
         pathlen += *next ? 3 : 2;
-      }
-      else {
+      } else {
         // otherwise crop the prior segment
         //
         do {
-            --pathlen;
+          --pathlen;
         } while (pathlen && path[pathlen - 1] != '/');
       }
 
@@ -278,14 +269,13 @@ ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *add
       //
       if (pathlen < keptlen) {
         if (flags & INK_FILEPATH_SECUREROOTTEST) {
-          return EACCES; //APR_EABOVEROOT;
+          return EACCES; // APR_EABOVEROOT;
         }
         keptlen = pathlen;
       }
-    }
-    else {
-        // An actual segment, append it to the destination path
-        //
+    } else {
+      // An actual segment, append it to the destination path
+      //
       if (*next) {
         seglen++;
       }
@@ -319,11 +309,10 @@ ink_filepath_merge(char *path, int pathsz, const char *rootpath, const char *add
   //
   if ((flags & INK_FILEPATH_NOTABOVEROOT) && keptlen < rootlen) {
     if (strncmp(rootpath, path, rootlen)) {
-      return EACCES; //APR_EABOVEROOT;
+      return EACCES; // APR_EABOVEROOT;
     }
-    if (rootpath[rootlen - 1] != '/'
-        && path[rootlen] && path[rootlen] != '/') {
-      return EACCES; //APR_EABOVEROOT;
+    if (rootpath[rootlen - 1] != '/' && path[rootlen] && path[rootlen] != '/') {
+      return EACCES; // APR_EABOVEROOT;
     }
   }
 
@@ -352,7 +341,7 @@ ink_filepath_make(char *path, int pathsz, const char *rootpath, const char *addp
     return 0;
   }
   rootlen = strlen(rootpath);
-  maxlen  = strlen(addpath) + 2;
+  maxlen = strlen(addpath) + 2;
   if (maxlen > (size_t)pathsz) {
     *path = '\0';
     return (int)maxlen;
@@ -376,8 +365,8 @@ ink_file_fd_zerofill(int fd, off_t size)
     return errno;
   }
 
-  // ZFS does not implement posix_fallocate() and fails with EINVAL. As a general workaround,
-  // just fall back to ftrucate if the preallocation fails.
+// ZFS does not implement posix_fallocate() and fails with EINVAL. As a general workaround,
+// just fall back to ftrucate if the preallocation fails.
 #if HAVE_POSIX_FALLOCATE
   if (posix_fallocate(fd, 0, size) == 0) {
     return 0;
@@ -392,7 +381,7 @@ ink_file_fd_zerofill(int fd, off_t size)
 }
 
 bool
-ink_file_is_directory(const char * path)
+ink_file_is_directory(const char *path)
 {
   struct stat sbuf;
 
@@ -429,18 +418,17 @@ ink_file_is_mmappable(mode_t st_mode)
 #endif
 
   return false;
-
 }
 
 bool
-ink_file_get_geometry(int fd ATS_UNUSED, ink_device_geometry& geometry)
+ink_file_get_geometry(int fd ATS_UNUSED, ink_device_geometry &geometry)
 {
   ink_zero(geometry);
 
 #if defined(freebsd) || defined(darwin) || defined(openbsd)
   ioctl_arg_t arg ATS_UNUSED;
 
-  // These IOCTLs are standard across the BSD family; Darwin has a different set though.
+// These IOCTLs are standard across the BSD family; Darwin has a different set though.
 #if defined(DIOCGMEDIASIZE)
   if (ioctl(fd, DIOCGMEDIASIZE, &arg.off) == 0) {
     geometry.totalsz = arg.off;
@@ -506,7 +494,7 @@ ink_file_get_geometry(int fd ATS_UNUSED, ink_device_geometry& geometry)
 }
 
 size_t
-ink_file_namemax(const char * path)
+ink_file_namemax(const char *path)
 {
   long namemax = pathconf(path, _PC_NAME_MAX);
   if (namemax > 0) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_file.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_file.h b/lib/ts/ink_file.h
index 41f3f96..fa4e161 100644
--- a/lib/ts/ink_file.h
+++ b/lib/ts/ink_file.h
@@ -30,7 +30,7 @@
  ****************************************************************************/
 
 #ifndef _ink_file_h_
-#define	_ink_file_h_
+#define _ink_file_h_
 
 #include "ink_config.h"
 
@@ -59,39 +59,37 @@
 
 // Cause ink_filepath_merge to fail if addpath is above rootpath
 //
-#define INK_FILEPATH_NOTABOVEROOT   0x01
+#define INK_FILEPATH_NOTABOVEROOT 0x01
 // internal: Only meaningful with INK_FILEPATH_NOTABOVEROOT
 #define INK_FILEPATH_SECUREROOTTEST 0x02
 // Cause ink_filepath_merge to fail if addpath is above rootpath,
 // even given a rootpath /foo/bar and an addpath ../bar/bash
 //
-#define INK_FILEPATH_SECUREROOT     0x03
+#define INK_FILEPATH_SECUREROOT 0x03
 // Fail ink_filepath_merge if the merged path is relative
-#define INK_FILEPATH_NOTRELATIVE    0x04
+#define INK_FILEPATH_NOTRELATIVE 0x04
 // Fail ink_filepath_merge if the merged path is absolute
-#define INK_FILEPATH_NOTABSOLUTE    0x08
+#define INK_FILEPATH_NOTABSOLUTE 0x08
 // Return the file system's native path format (e.g. path delimiters
 // of ':' on MacOS9, '\' on Win32, etc.)
-#define INK_FILEPATH_NATIVE         0x10
+#define INK_FILEPATH_NATIVE 0x10
 // Resolve the true case of existing directories and file elements
 // of addpath, (resolving any aliases on Win32) and append a proper
 // trailing slash if a directory
 //
-#define INK_FILEPATH_TRUENAME       0x20
+#define INK_FILEPATH_TRUENAME 0x20
 
 int ink_fputln(FILE *stream, const char *s);
 int ink_file_fd_readline(int fd, int bufsize, char *buf);
 int ink_file_fd_writestring(int fd, const char *buf);
-int ink_filepath_merge(char *buf, int bufsz, const char *rootpath,
-                       const char *addpath, int flags = INK_FILEPATH_TRUENAME);
+int ink_filepath_merge(char *buf, int bufsz, const char *rootpath, const char *addpath, int flags = INK_FILEPATH_TRUENAME);
 /**
  Add addpath to the rootpath prepending slash if rootpath
  is not NULL and doesn't end with the slash already and put the
  result into path buffer. If the buffer is too small to hold the
  resulting string, required size is returned. On success zero is returned
  */
-int ink_filepath_make(char *path, int pathsz, const char *rootpath,
-                      const char *addpath);
+int ink_filepath_make(char *path, int pathsz, const char *rootpath, const char *addpath);
 
 /**
  Resize and zero-fill the given file.
@@ -102,34 +100,35 @@ int ink_file_fd_zerofill(int fd, off_t size);
 /**
  Return true if the path is a directory.
  */
-bool ink_file_is_directory(const char * path);
+bool ink_file_is_directory(const char *path);
 
 /**
  Return true if this file type can be mmap(2)'ed.
  */
 bool ink_file_is_mmappable(mode_t st_mode);
 
-struct ink_device_geometry
-{
-  uint64_t  totalsz;  // Total device size in bytes.
-  unsigned  blocksz;  // Preferred I/O block size.
-  unsigned  alignsz;  // Block device alignment in bytes. Only relevant with stacked block devices.
+struct ink_device_geometry {
+  uint64_t totalsz; // Total device size in bytes.
+  unsigned blocksz; // Preferred I/O block size.
+  unsigned alignsz; // Block device alignment in bytes. Only relevant with stacked block devices.
 };
 
-bool ink_file_get_geometry(int fd, ink_device_geometry& geometry);
+bool ink_file_get_geometry(int fd, ink_device_geometry &geometry);
 
 // Return the value of pathconf(path, _PC_NAME_MAX), or the closest approximation.
-size_t ink_file_namemax(const char * path);
+size_t ink_file_namemax(const char *path);
 
 // Is the given path "."?
 static inline bool
-isdot(const char * path) {
+isdot(const char *path)
+{
   return path[0] == '.' && path[1] == '\0';
 }
 
 // Is the given path ".."?
 static inline bool
-isdotdot(const char * path) {
+isdotdot(const char *path)
+{
   return path[0] == '.' && path[1] == '.' && path[2] == '\0';
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_hash_table.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_hash_table.cc b/lib/ts/ink_hash_table.cc
index e76a500..3ba691b 100644
--- a/lib/ts/ink_hash_table.cc
+++ b/lib/ts/ink_hash_table.cc
@@ -58,7 +58,7 @@ ink_hash_table_create(InkHashTableKeyType key_type)
   Tcl_HashTable *tcl_ht_ptr;
   int tcl_key_type;
 
-  tcl_ht_ptr = (Tcl_HashTable*)ats_malloc(sizeof(Tcl_HashTable));
+  tcl_ht_ptr = (Tcl_HashTable *)ats_malloc(sizeof(Tcl_HashTable));
 
   if (key_type == InkHashTableKeyType_String)
     tcl_key_type = TCL_STRING_KEYS;
@@ -69,9 +69,9 @@ ink_hash_table_create(InkHashTableKeyType key_type)
 
   Tcl_InitHashTable(tcl_ht_ptr, tcl_key_type);
 
-  ht_ptr = (InkHashTable *) tcl_ht_ptr;
+  ht_ptr = (InkHashTable *)tcl_ht_ptr;
   return (ht_ptr);
-}                               /* End ink_hash_table_create */
+} /* End ink_hash_table_create */
 
 
 /*---------------------------------------------------------------------------*
@@ -83,15 +83,15 @@ ink_hash_table_create(InkHashTableKeyType key_type)
  *---------------------------------------------------------------------------*/
 
 InkHashTable *
-ink_hash_table_destroy(InkHashTable * ht_ptr)
+ink_hash_table_destroy(InkHashTable *ht_ptr)
 {
   Tcl_HashTable *tcl_ht_ptr;
 
-  tcl_ht_ptr = (Tcl_HashTable *) ht_ptr;
+  tcl_ht_ptr = (Tcl_HashTable *)ht_ptr;
   Tcl_DeleteHashTable(tcl_ht_ptr);
   ats_free(tcl_ht_ptr);
-  return (InkHashTable *) 0;
-}                               /* End ink_hash_table_destroy */
+  return (InkHashTable *)0;
+} /* End ink_hash_table_destroy */
 
 
 /*---------------------------------------------------------------------------*
@@ -105,7 +105,7 @@ ink_hash_table_destroy(InkHashTable * ht_ptr)
  *---------------------------------------------------------------------------*/
 
 static int
-_ink_hash_table_free_entry_value(InkHashTable * ht_ptr, InkHashTableEntry * e)
+_ink_hash_table_free_entry_value(InkHashTable *ht_ptr, InkHashTableEntry *e)
 {
   InkHashTableValue value;
 
@@ -115,11 +115,11 @@ _ink_hash_table_free_entry_value(InkHashTable * ht_ptr, InkHashTableEntry * e)
   }
 
   return (0);
-}                               /* End _ink_hash_table_free_entry_value */
+} /* End _ink_hash_table_free_entry_value */
 
 
 static int
-_ink_hash_table_xfree_entry_value(InkHashTable * ht_ptr, InkHashTableEntry * e)
+_ink_hash_table_xfree_entry_value(InkHashTable *ht_ptr, InkHashTableEntry *e)
 {
   InkHashTableValue value;
 
@@ -129,23 +129,23 @@ _ink_hash_table_xfree_entry_value(InkHashTable * ht_ptr, InkHashTableEntry * e)
   }
 
   return (0);
-}                               /* End _ink_hash_table_xfree_entry_value */
+} /* End _ink_hash_table_xfree_entry_value */
 
 InkHashTable *
-ink_hash_table_destroy_and_free_values(InkHashTable * ht_ptr)
+ink_hash_table_destroy_and_free_values(InkHashTable *ht_ptr)
 {
   ink_hash_table_map(ht_ptr, _ink_hash_table_free_entry_value);
   ink_hash_table_destroy(ht_ptr);
-  return (InkHashTable *) 0;
-}                               /* End ink_hash_table_destroy_and_free_values */
+  return (InkHashTable *)0;
+} /* End ink_hash_table_destroy_and_free_values */
 
 InkHashTable *
-ink_hash_table_destroy_and_xfree_values(InkHashTable * ht_ptr)
+ink_hash_table_destroy_and_xfree_values(InkHashTable *ht_ptr)
 {
   ink_hash_table_map(ht_ptr, _ink_hash_table_xfree_entry_value);
   ink_hash_table_destroy(ht_ptr);
-  return (InkHashTable *) 0;
-}                               /* End ink_hash_table_destroy_and_xfree_values */
+  return (InkHashTable *)0;
+} /* End ink_hash_table_destroy_and_xfree_values */
 
 
 /*---------------------------------------------------------------------------*
@@ -158,19 +158,19 @@ ink_hash_table_destroy_and_xfree_values(InkHashTable * ht_ptr)
  *---------------------------------------------------------------------------*/
 
 int
-ink_hash_table_isbound(InkHashTable * ht_ptr, const char *key)
+ink_hash_table_isbound(InkHashTable *ht_ptr, const char *key)
 {
   InkHashTableEntry *he_ptr;
 
   he_ptr = ink_hash_table_lookup_entry(ht_ptr, key);
   return ((he_ptr == NULL) ? 0 : 1);
-}                               /* End ink_hash_table_isbound */
+} /* End ink_hash_table_isbound */
 
 
 /*---------------------------------------------------------------------------*
   int ink_hash_table_lookup(InkHashTable *ht_ptr,
-		            InkHashTableKey key,
-			    InkHashTableValue *value_ptr)
+                            InkHashTableKey key,
+                            InkHashTableValue *value_ptr)
 
   This routine takes a hash table <ht_ptr>, a key <key>, and stores the
   value bound to the key by reference through <value_ptr>.  If no binding is
@@ -179,7 +179,7 @@ ink_hash_table_isbound(InkHashTable * ht_ptr, const char *key)
  *---------------------------------------------------------------------------*/
 
 int
-ink_hash_table_lookup(InkHashTable *ht_ptr, const char* key, InkHashTableValue *value_ptr)
+ink_hash_table_lookup(InkHashTable *ht_ptr, const char *key, InkHashTableValue *value_ptr)
 {
   InkHashTableEntry *he_ptr;
   InkHashTableValue value;
@@ -191,7 +191,7 @@ ink_hash_table_lookup(InkHashTable *ht_ptr, const char* key, InkHashTableValue *
   value = ink_hash_table_entry_value(ht_ptr, he_ptr);
   *value_ptr = value;
   return (1);
-}                               /* End ink_hash_table_lookup */
+} /* End ink_hash_table_lookup */
 
 
 /*---------------------------------------------------------------------------*
@@ -205,14 +205,14 @@ ink_hash_table_lookup(InkHashTable *ht_ptr, const char* key, InkHashTableValue *
  *---------------------------------------------------------------------------*/
 
 int
-ink_hash_table_delete(InkHashTable * ht_ptr, const char *key)
+ink_hash_table_delete(InkHashTable *ht_ptr, const char *key)
 {
   char *tcl_key;
   Tcl_HashTable *tcl_ht_ptr;
   Tcl_HashEntry *tcl_he_ptr;
 
-  tcl_key = (char *) key;
-  tcl_ht_ptr = (Tcl_HashTable *) ht_ptr;
+  tcl_key = (char *)key;
+  tcl_ht_ptr = (Tcl_HashTable *)ht_ptr;
   tcl_he_ptr = Tcl_FindHashEntry(tcl_ht_ptr, tcl_key);
 
   if (!tcl_he_ptr)
@@ -220,13 +220,13 @@ ink_hash_table_delete(InkHashTable * ht_ptr, const char *key)
   Tcl_DeleteHashEntry(tcl_he_ptr);
 
   return (1);
-}                               /* End ink_hash_table_delete */
+} /* End ink_hash_table_delete */
 
 
 /*---------------------------------------------------------------------------*
 
   InkHashTableEntry *ink_hash_table_lookup_entry(InkHashTable *ht_ptr,
-  						 InkHashTableKey key)
+                                                 InkHashTableKey key)
 
   This routine takes a hash table <ht_ptr> and a key <key>, and returns the
   entry matching the key, or NULL otherwise.
@@ -234,25 +234,25 @@ ink_hash_table_delete(InkHashTable * ht_ptr, const char *key)
  *---------------------------------------------------------------------------*/
 
 InkHashTableEntry *
-ink_hash_table_lookup_entry(InkHashTable * ht_ptr, const char* key)
+ink_hash_table_lookup_entry(InkHashTable *ht_ptr, const char *key)
 {
   Tcl_HashTable *tcl_ht_ptr;
   Tcl_HashEntry *tcl_he_ptr;
   InkHashTableEntry *he_ptr;
 
-  tcl_ht_ptr = (Tcl_HashTable *) ht_ptr;
+  tcl_ht_ptr = (Tcl_HashTable *)ht_ptr;
   tcl_he_ptr = Tcl_FindHashEntry(tcl_ht_ptr, key);
-  he_ptr = (InkHashTableEntry *) tcl_he_ptr;
+  he_ptr = (InkHashTableEntry *)tcl_he_ptr;
 
   return (he_ptr);
-}                               /* End ink_hash_table_lookup_entry */
+} /* End ink_hash_table_lookup_entry */
 
 
 /*---------------------------------------------------------------------------*
 
   InkHashTableEntry *ink_hash_table_get_entry(InkHashTable *ht_ptr,
-					      InkHashTableKey key,
-					      int *new_value)
+                                              InkHashTableKey key,
+                                              int *new_value)
 
   This routine takes a hash table <ht_ptr> and a key <key>, and returns the
   entry matching the key, or creates, binds, and returns a new entry.
@@ -266,22 +266,22 @@ ink_hash_table_get_entry(InkHashTable *ht_ptr, const char *key, int *new_value)
   Tcl_HashTable *tcl_ht_ptr;
   Tcl_HashEntry *tcl_he_ptr;
 
-  tcl_ht_ptr = (Tcl_HashTable *) ht_ptr;
+  tcl_ht_ptr = (Tcl_HashTable *)ht_ptr;
   tcl_he_ptr = Tcl_CreateHashEntry(tcl_ht_ptr, key, new_value);
 
   if (tcl_he_ptr == NULL) {
     ink_fatal("%s: Tcl_CreateHashEntry returned NULL", "ink_hash_table_get_entry");
   }
 
-  return ((InkHashTableEntry *) tcl_he_ptr);
-}                               /* End ink_hash_table_get_entry */
+  return ((InkHashTableEntry *)tcl_he_ptr);
+} /* End ink_hash_table_get_entry */
 
 
 /*---------------------------------------------------------------------------*
 
   void ink_hash_table_set_entry(InkHashTable *ht_ptr,
-				InkHashTableEntry *he_ptr,
-				InkHashTableValue value)
+                                InkHashTableEntry *he_ptr,
+                                InkHashTableValue value)
 
   This routine takes a hash table <ht_ptr>, a hash table entry <he_ptr>,
   and changes the value field of the entry to <value>.
@@ -289,23 +289,23 @@ ink_hash_table_get_entry(InkHashTable *ht_ptr, const char *key, int *new_value)
  *---------------------------------------------------------------------------*/
 
 void
-ink_hash_table_set_entry(InkHashTable * ht_ptr, InkHashTableEntry * he_ptr, InkHashTableValue value)
+ink_hash_table_set_entry(InkHashTable *ht_ptr, InkHashTableEntry *he_ptr, InkHashTableValue value)
 {
-  (void) ht_ptr;
+  (void)ht_ptr;
   ClientData tcl_value;
   Tcl_HashEntry *tcl_he_ptr;
 
-  tcl_value = (ClientData) value;
-  tcl_he_ptr = (Tcl_HashEntry *) he_ptr;
+  tcl_value = (ClientData)value;
+  tcl_he_ptr = (Tcl_HashEntry *)he_ptr;
   Tcl_SetHashValue(tcl_he_ptr, tcl_value);
-}                               /* End ink_hash_table_set_entry */
+} /* End ink_hash_table_set_entry */
 
 
 /*---------------------------------------------------------------------------*
 
   void ink_hash_table_insert(InkHashTable *ht_ptr,
-			     InkHashTableKey key,
-			     InkHashTableValue value)
+                             InkHashTableKey key,
+                             InkHashTableValue value)
 
   This routine takes a hash table <ht_ptr>, a key <key>, and binds the value
   <value> to the key, replacing any previous binding, if any.
@@ -313,14 +313,14 @@ ink_hash_table_set_entry(InkHashTable * ht_ptr, InkHashTableEntry * he_ptr, InkH
  *---------------------------------------------------------------------------*/
 
 void
-ink_hash_table_insert(InkHashTable * ht_ptr, const char *key, InkHashTableValue value)
+ink_hash_table_insert(InkHashTable *ht_ptr, const char *key, InkHashTableValue value)
 {
   int new_value;
   InkHashTableEntry *he_ptr;
 
   he_ptr = ink_hash_table_get_entry(ht_ptr, key, &new_value);
   ink_hash_table_set_entry(ht_ptr, he_ptr, value);
-}                               /* End ink_hash_table_insert */
+} /* End ink_hash_table_insert */
 
 
 /*---------------------------------------------------------------------------*
@@ -334,24 +334,24 @@ ink_hash_table_insert(InkHashTable * ht_ptr, const char *key, InkHashTableValue
  *---------------------------------------------------------------------------*/
 
 void
-ink_hash_table_map(InkHashTable * ht_ptr, InkHashTableEntryFunction map)
+ink_hash_table_map(InkHashTable *ht_ptr, InkHashTableEntryFunction map)
 {
   int retcode;
   InkHashTableEntry *e;
   InkHashTableIteratorState state;
 
   for (e = ink_hash_table_iterator_first(ht_ptr, &state); e != NULL; e = ink_hash_table_iterator_next(ht_ptr, &state)) {
-    retcode = (*map) (ht_ptr, e);
+    retcode = (*map)(ht_ptr, e);
     if (retcode != 0)
       break;
   }
-}                               /* End ink_hash_table_map */
+} /* End ink_hash_table_map */
 
 
 /*---------------------------------------------------------------------------*
 
   InkHashTableKey ink_hash_table_entry_key(InkHashTable *ht_ptr,
-			                   InkHashTableEntry *entry_ptr)
+                                           InkHashTableEntry *entry_ptr)
 
   This routine takes a hash table <ht_ptr> and a pointer to a hash table
   entry <entry_ptr>, and returns the key portion of the entry.
@@ -359,19 +359,19 @@ ink_hash_table_map(InkHashTable * ht_ptr, InkHashTableEntryFunction map)
  *---------------------------------------------------------------------------*/
 
 InkHashTableKey
-ink_hash_table_entry_key(InkHashTable * ht_ptr, InkHashTableEntry * entry_ptr)
+ink_hash_table_entry_key(InkHashTable *ht_ptr, InkHashTableEntry *entry_ptr)
 {
   char *tcl_key;
 
-  tcl_key = (char*) Tcl_GetHashKey((Tcl_HashTable *) ht_ptr, (Tcl_HashEntry *) entry_ptr);
-  return ((InkHashTableKey) tcl_key);
-}                               /* End ink_hash_table_entry_key */
+  tcl_key = (char *)Tcl_GetHashKey((Tcl_HashTable *)ht_ptr, (Tcl_HashEntry *)entry_ptr);
+  return ((InkHashTableKey)tcl_key);
+} /* End ink_hash_table_entry_key */
 
 
 /*---------------------------------------------------------------------------*
 
   InkHashTableValue ink_hash_table_entry_value(InkHashTable *ht_ptr,
-			                       InkHashTableEntry *entry_ptr)
+                                               InkHashTableEntry *entry_ptr)
 
   This routine takes a hash table <ht_ptr> and a pointer to a hash table
   entry <entry_ptr>, and returns the value portion of the entry.
@@ -379,15 +379,14 @@ ink_hash_table_entry_key(InkHashTable * ht_ptr, InkHashTableEntry * entry_ptr)
  *---------------------------------------------------------------------------*/
 
 InkHashTableValue
-ink_hash_table_entry_value(InkHashTable * ht_ptr, InkHashTableEntry * entry_ptr)
+ink_hash_table_entry_value(InkHashTable *ht_ptr, InkHashTableEntry *entry_ptr)
 {
-  (void) ht_ptr;
+  (void)ht_ptr;
   ClientData tcl_value;
 
-  tcl_value = Tcl_GetHashValue((Tcl_HashEntry *) entry_ptr);
-  return ((InkHashTableValue) tcl_value);
-}                               /* End ink_hash_table_entry_value */
-
+  tcl_value = Tcl_GetHashValue((Tcl_HashEntry *)entry_ptr);
+  return ((InkHashTableValue)tcl_value);
+} /* End ink_hash_table_entry_value */
 
 
 /*---------------------------------------------------------------------------*
@@ -401,7 +400,7 @@ ink_hash_table_entry_value(InkHashTable * ht_ptr, InkHashTableEntry * entry_ptr)
  *---------------------------------------------------------------------------*/
 
 static int
-DumpStringEntry(InkHashTable * ht_ptr, InkHashTableEntry * e)
+DumpStringEntry(InkHashTable *ht_ptr, InkHashTableEntry *e)
 {
   InkHashTableKey key;
   InkHashTableValue value;
@@ -409,23 +408,23 @@ DumpStringEntry(InkHashTable * ht_ptr, InkHashTableEntry * e)
   key = ink_hash_table_entry_key(ht_ptr, e);
   value = ink_hash_table_entry_value(ht_ptr, e);
 
-  fprintf(stderr, "key = '%s', value = '%s'\n", (char *) key, (char *) value);
+  fprintf(stderr, "key = '%s', value = '%s'\n", (char *)key, (char *)value);
 
   return (0);
 }
 
 
 void
-ink_hash_table_dump_strings(InkHashTable * ht_ptr)
+ink_hash_table_dump_strings(InkHashTable *ht_ptr)
 {
   ink_hash_table_map(ht_ptr, DumpStringEntry);
-}                               /* End ink_hash_table_dump_strings */
+} /* End ink_hash_table_dump_strings */
 
 
 /*---------------------------------------------------------------------------*
 
   void ink_hash_table_replace_string(InkHashTable *ht_ptr,
-				     char *string_key, char *string_value)
+                                     char *string_key, char *string_value)
 
   This conveninece routine is intended for hash tables with keys of type
   InkHashTableKeyType_String, and values being dynamically allocated strings.
@@ -435,7 +434,7 @@ ink_hash_table_dump_strings(InkHashTable * ht_ptr)
  *---------------------------------------------------------------------------*/
 
 void
-ink_hash_table_replace_string(InkHashTable * ht_ptr, char *string_key, char *string_value)
+ink_hash_table_replace_string(InkHashTable *ht_ptr, char *string_key, char *string_value)
 {
   int new_value;
   char *old_str;
@@ -447,12 +446,12 @@ ink_hash_table_replace_string(InkHashTable * ht_ptr, char *string_key, char *str
    * still dealing with pointers, and we aren't loosing any bits.
    */
 
-  he_ptr = ink_hash_table_get_entry(ht_ptr, (InkHashTableKey) string_key, &new_value);
+  he_ptr = ink_hash_table_get_entry(ht_ptr, (InkHashTableKey)string_key, &new_value);
   if (new_value == 0) {
-    old_str = (char *) ink_hash_table_entry_value(ht_ptr, he_ptr);
+    old_str = (char *)ink_hash_table_entry_value(ht_ptr, he_ptr);
     if (old_str)
       ats_free(old_str);
   }
 
   ink_hash_table_set_entry(ht_ptr, he_ptr, (InkHashTableValue)(ats_strdup(string_value)));
-}                               /* End ink_hash_table_replace_string */
+} /* End ink_hash_table_replace_string */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_hash_table.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_hash_table.h b/lib/ts/ink_hash_table.h
index ec3dc56..2894858 100644
--- a/lib/ts/ink_hash_table.h
+++ b/lib/ts/ink_hash_table.h
@@ -31,12 +31,11 @@
  ****************************************************************************/
 
 #ifndef _ink_hash_table_h_
-#define	_ink_hash_table_h_
+#define _ink_hash_table_h_
 
 #ifdef __cplusplus
-extern "C"
-{
-#endif                          /* __cplusplus */
+extern "C" {
+#endif /* __cplusplus */
 #include "ink_apidefs.h"
 
 /*===========================================================================*
@@ -47,19 +46,20 @@ extern "C"
 
 #include <tcl.h>
 
-  typedef Tcl_HashTable InkHashTable;
-  typedef Tcl_HashEntry InkHashTableEntry;
-  typedef char *InkHashTableKey;
-  typedef ClientData InkHashTableValue;
-  typedef Tcl_HashSearch InkHashTableIteratorState;
+typedef Tcl_HashTable InkHashTable;
+typedef Tcl_HashEntry InkHashTableEntry;
+typedef char *InkHashTableKey;
+typedef ClientData InkHashTableValue;
+typedef Tcl_HashSearch InkHashTableIteratorState;
 
-  typedef int (*InkHashTableEntryFunction) (InkHashTable * ht, InkHashTableEntry * entry);
+typedef int (*InkHashTableEntryFunction)(InkHashTable *ht, InkHashTableEntry *entry);
 
-  /* Types of InkHashTable Keys */
+/* Types of InkHashTable Keys */
 
-  typedef enum
-  { InkHashTableKeyType_String, InkHashTableKeyType_Word }
-  InkHashTableKeyType;
+typedef enum {
+  InkHashTableKeyType_String,
+  InkHashTableKeyType_Word,
+} InkHashTableKeyType;
 
 /*===========================================================================*
 
@@ -67,29 +67,29 @@ extern "C"
 
  *===========================================================================*/
 
-  InkHashTable *ink_hash_table_create(InkHashTableKeyType key_type);
-  InkHashTable *ink_hash_table_destroy(InkHashTable * ht_ptr);
-  InkHashTable *ink_hash_table_destroy_and_free_values(InkHashTable * ht_ptr);
-  InkHashTable *ink_hash_table_destroy_and_xfree_values(InkHashTable * ht_ptr);
-  inkcoreapi int ink_hash_table_isbound(InkHashTable * ht_ptr, const char *key);
-  inkcoreapi int ink_hash_table_lookup(InkHashTable * ht_ptr, const char *key, InkHashTableValue * value_ptr);
-  inkcoreapi int ink_hash_table_delete(InkHashTable * ht_ptr, const char *key);
-  InkHashTableEntry *ink_hash_table_lookup_entry(InkHashTable * ht_ptr, const char *key);
-  InkHashTableEntry *ink_hash_table_get_entry(InkHashTable * ht_ptr, const char *key, int *new_value);
-  void ink_hash_table_set_entry(InkHashTable * ht_ptr, InkHashTableEntry * he_ptr, InkHashTableValue value);
-  inkcoreapi void ink_hash_table_insert(InkHashTable * ht_ptr, const char *key, InkHashTableValue value);
-  void ink_hash_table_map(InkHashTable * ht_ptr, InkHashTableEntryFunction map);
-  InkHashTableKey ink_hash_table_entry_key(InkHashTable * ht_ptr, InkHashTableEntry * entry_ptr);
-  inkcoreapi InkHashTableValue ink_hash_table_entry_value(InkHashTable * ht_ptr, InkHashTableEntry * entry_ptr);
-  void ink_hash_table_dump_strings(InkHashTable * ht_ptr);
-  void ink_hash_table_replace_string(InkHashTable * ht_ptr, InkHashTableKey key, char *str);
+InkHashTable *ink_hash_table_create(InkHashTableKeyType key_type);
+InkHashTable *ink_hash_table_destroy(InkHashTable *ht_ptr);
+InkHashTable *ink_hash_table_destroy_and_free_values(InkHashTable *ht_ptr);
+InkHashTable *ink_hash_table_destroy_and_xfree_values(InkHashTable *ht_ptr);
+inkcoreapi int ink_hash_table_isbound(InkHashTable *ht_ptr, const char *key);
+inkcoreapi int ink_hash_table_lookup(InkHashTable *ht_ptr, const char *key, InkHashTableValue *value_ptr);
+inkcoreapi int ink_hash_table_delete(InkHashTable *ht_ptr, const char *key);
+InkHashTableEntry *ink_hash_table_lookup_entry(InkHashTable *ht_ptr, const char *key);
+InkHashTableEntry *ink_hash_table_get_entry(InkHashTable *ht_ptr, const char *key, int *new_value);
+void ink_hash_table_set_entry(InkHashTable *ht_ptr, InkHashTableEntry *he_ptr, InkHashTableValue value);
+inkcoreapi void ink_hash_table_insert(InkHashTable *ht_ptr, const char *key, InkHashTableValue value);
+void ink_hash_table_map(InkHashTable *ht_ptr, InkHashTableEntryFunction map);
+InkHashTableKey ink_hash_table_entry_key(InkHashTable *ht_ptr, InkHashTableEntry *entry_ptr);
+inkcoreapi InkHashTableValue ink_hash_table_entry_value(InkHashTable *ht_ptr, InkHashTableEntry *entry_ptr);
+void ink_hash_table_dump_strings(InkHashTable *ht_ptr);
+void ink_hash_table_replace_string(InkHashTable *ht_ptr, InkHashTableKey key, char *str);
 
 /* inline functions declarations */
 
 /*---------------------------------------------------------------------------*
 
   InkHashTableEntry *ink_hash_table_iterator_first
-	(InkHashTable *ht_ptr, InkHashTableIteratorState *state_ptr)
+        (InkHashTable *ht_ptr, InkHashTableIteratorState *state_ptr)
 
   This routine takes a hash table <ht_ptr>, creates some iterator state
   stored through <state_ptr>, and returns a pointer to the first hash table
@@ -98,28 +98,28 @@ extern "C"
 
  *---------------------------------------------------------------------------*/
 
-  static inline InkHashTableEntry *ink_hash_table_iterator_first
-    (InkHashTable * ht_ptr, InkHashTableIteratorState * state_ptr)
-  {
-    Tcl_HashTable *tcl_ht_ptr;
-    Tcl_HashSearch *tcl_search_state_ptr;
-    Tcl_HashEntry *tcl_he_ptr;
-    InkHashTableEntry *he_ptr;
+static inline InkHashTableEntry *
+ink_hash_table_iterator_first(InkHashTable *ht_ptr, InkHashTableIteratorState *state_ptr)
+{
+  Tcl_HashTable *tcl_ht_ptr;
+  Tcl_HashSearch *tcl_search_state_ptr;
+  Tcl_HashEntry *tcl_he_ptr;
+  InkHashTableEntry *he_ptr;
 
-      tcl_ht_ptr = (Tcl_HashTable *) ht_ptr;
-      tcl_search_state_ptr = (Tcl_HashSearch *) state_ptr;
+  tcl_ht_ptr = (Tcl_HashTable *)ht_ptr;
+  tcl_search_state_ptr = (Tcl_HashSearch *)state_ptr;
 
-      tcl_he_ptr = Tcl_FirstHashEntry(tcl_ht_ptr, tcl_search_state_ptr);
-      he_ptr = (InkHashTableEntry *) tcl_he_ptr;
+  tcl_he_ptr = Tcl_FirstHashEntry(tcl_ht_ptr, tcl_search_state_ptr);
+  he_ptr = (InkHashTableEntry *)tcl_he_ptr;
 
-      return (he_ptr);
-  }                             /* End ink_hash_table_iterator_first */
+  return (he_ptr);
+} /* End ink_hash_table_iterator_first */
 
 
 /*---------------------------------------------------------------------------*
 
   InkHashTableEntry *ink_hash_table_iterator_next(InkHashTable *ht_ptr,
-					          InkHashTableIteratorState *state_ptr)
+                                                  InkHashTableIteratorState *state_ptr)
 
   This routine takes a hash table <ht_ptr> and a pointer to iterator state
   initialized by a previous call to InkHashTableIteratorFirst(), and returns
@@ -127,21 +127,21 @@ extern "C"
 
  *---------------------------------------------------------------------------*/
 
-  static inline InkHashTableEntry *ink_hash_table_iterator_next(InkHashTable * ht_ptr,
-                                                                InkHashTableIteratorState * state_ptr)
-  {
-    (void) ht_ptr;
-    Tcl_HashSearch *tcl_search_state_ptr;
-    Tcl_HashEntry *tcl_he_ptr;
-    InkHashTableEntry *he_ptr;
+static inline InkHashTableEntry *
+ink_hash_table_iterator_next(InkHashTable *ht_ptr, InkHashTableIteratorState *state_ptr)
+{
+  (void)ht_ptr;
+  Tcl_HashSearch *tcl_search_state_ptr;
+  Tcl_HashEntry *tcl_he_ptr;
+  InkHashTableEntry *he_ptr;
 
-    tcl_search_state_ptr = (Tcl_HashSearch *) state_ptr;
+  tcl_search_state_ptr = (Tcl_HashSearch *)state_ptr;
 
-    tcl_he_ptr = Tcl_NextHashEntry(tcl_search_state_ptr);
-    he_ptr = (InkHashTableEntry *) tcl_he_ptr;
+  tcl_he_ptr = Tcl_NextHashEntry(tcl_search_state_ptr);
+  he_ptr = (InkHashTableEntry *)tcl_he_ptr;
 
-    return (he_ptr);
-  }                             /* End ink_hash_table_iterator_next */
+  return (he_ptr);
+} /* End ink_hash_table_iterator_next */
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_hrtime.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_hrtime.cc b/lib/ts/ink_hrtime.cc
index 6d2870b..1da8d24 100644
--- a/lib/ts/ink_hrtime.cc
+++ b/lib/ts/ink_hrtime.cc
@@ -56,7 +56,7 @@ int64_to_str(char *buf, unsigned int buf_size, int64_t val, unsigned int *total_
     out_buf = &buf[buf_size - 1];
   }
 
-  unsigned int num_chars = 1;   // includes eos
+  unsigned int num_chars = 1; // includes eos
   *out_buf-- = 0;
 
   if (val < 0) {
@@ -65,11 +65,11 @@ int64_to_str(char *buf, unsigned int buf_size, int64_t val, unsigned int *total_
   }
 
   if (val < 10) {
-    *out_buf-- = '0' + (char) val;
+    *out_buf-- = '0' + (char)val;
     ++num_chars;
   } else {
     do {
-      *out_buf-- = (char) (val % 10) + '0';
+      *out_buf-- = (char)(val % 10) + '0';
       val /= 10;
       ++num_chars;
     } while (val);
@@ -99,14 +99,15 @@ int64_to_str(char *buf, unsigned int buf_size, int64_t val, unsigned int *total_
         *--out_buf = pad_char;
         break;
       default:
-        for (unsigned int i = 0; i < num_padding; ++i, *--out_buf = pad_char);
+        for (unsigned int i = 0; i < num_padding; ++i, *--out_buf = pad_char)
+          ;
       }
       num_chars += num_padding;
     }
     // add minus sign if padding character is 0
     if (negative && pad_char == '0') {
       if (num_padding) {
-        *out_buf = '-';         // overwrite padding
+        *out_buf = '-'; // overwrite padding
       } else {
         *--out_buf = '-';
         ++num_chars;
@@ -154,13 +155,13 @@ squid_timestamp_to_buf(char *buf, unsigned int buf_size, long timestamp_sec, lon
   char ATS_UNUSED *ts_ms = int64_to_str(&tmp_buf[tmp_buf_size - 4], 4, ms, &num_chars_ms, 4, '0');
   ink_assert(ts_ms && num_chars_ms == 4);
 
-  unsigned int chars_to_write = num_chars_s + 3;        // no eos
+  unsigned int chars_to_write = num_chars_s + 3; // no eos
 
   if (buf_size >= chars_to_write) {
     memcpy(buf, ts_s, chars_to_write);
     res = chars_to_write;
   } else {
-    res = -((int) chars_to_write);
+    res = -((int)chars_to_write);
   }
 
   return res;
@@ -171,11 +172,11 @@ uint32_t
 init_hrtime_TCS()
 {
   int freqlen = sizeof(hrtime_freq);
-  if (sysctlbyname("machdep.tsc_freq", &hrtime_freq, (size_t *) & freqlen, NULL, 0) < 0) {
+  if (sysctlbyname("machdep.tsc_freq", &hrtime_freq, (size_t *)&freqlen, NULL, 0) < 0) {
     perror("sysctl: machdep.tsc_freq");
     exit(1);
   }
-  hrtime_freq_float = (double) 1000000000 / (double) hrtime_freq;
+  hrtime_freq_float = (double)1000000000 / (double)hrtime_freq;
   return hrtime_freq;
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_hrtime.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_hrtime.h b/lib/ts/ink_hrtime.h
index 8fb3300..e1db113 100644
--- a/lib/ts/ink_hrtime.h
+++ b/lib/ts/ink_hrtime.h
@@ -28,7 +28,7 @@
   This file contains code supporting the Inktomi high-resolution timer.
 **************************************************************************/
 
-#if !defined (_ink_hrtime_h_)
+#if !defined(_ink_hrtime_h_)
 #define _ink_hrtime_h_
 
 #include "ink_config.h"
@@ -39,7 +39,8 @@
 typedef int64_t ink_hrtime;
 
 int squid_timestamp_to_buf(char *buf, unsigned int buf_size, long timestamp_sec, long timestamp_usec);
-char *int64_to_str(char *buf, unsigned int buf_size, int64_t val, unsigned int *total_chars, unsigned int req_width=0, char pad_char='0');
+char *int64_to_str(char *buf, unsigned int buf_size, int64_t val, unsigned int *total_chars, unsigned int req_width = 0,
+                   char pad_char = '0');
 
 //////////////////////////////////////////////////////////////////////////////
 //
@@ -54,14 +55,14 @@ static inline ink_hrtime
 hrtime_rdtsc()
 {
   ink_hrtime rv;
-  asm volatile (".byte 0x0f, 0x31":"=A" (rv));
+  asm volatile(".byte 0x0f, 0x31" : "=A"(rv));
   return (rv);
 }
 static inline uint64_t
 get_hrtime_rdtsc()
 {
   // do it fixed point if you have better hardware support
-  return (uint64_t) (hrtime_freq_float * hrtime_rdtsc());
+  return (uint64_t)(hrtime_freq_float * hrtime_rdtsc());
 }
 #endif
 
@@ -71,20 +72,20 @@ get_hrtime_rdtsc()
 //
 //////////////////////////////////////////////////////////////////////////////
 
-#define HRTIME_FOREVER  (10*HRTIME_DECADE)
-#define HRTIME_DECADE   (10*HRTIME_YEAR)
-#define HRTIME_YEAR     (365*HRTIME_DAY+HRTIME_DAY/4)
-#define HRTIME_WEEK     (7*HRTIME_DAY)
-#define HRTIME_DAY      (24*HRTIME_HOUR)
-#define HRTIME_HOUR     (60*HRTIME_MINUTE)
-#define HRTIME_MINUTE   (60*HRTIME_SECOND)
-#define HRTIME_SECOND   (1000*HRTIME_MSECOND)
-#define HRTIME_MSECOND  (1000*HRTIME_USECOND)
-#define HRTIME_USECOND  (1000*HRTIME_NSECOND)
-#define HRTIME_NSECOND	(1LL)
-
-#define HRTIME_APPROX_SECONDS(_x) ((_x)>>30)    // off by 7.3%
-#define HRTIME_APPROX_FACTOR      (((float)(1<<30))/(((float)HRTIME_SECOND)))
+#define HRTIME_FOREVER (10 * HRTIME_DECADE)
+#define HRTIME_DECADE (10 * HRTIME_YEAR)
+#define HRTIME_YEAR (365 * HRTIME_DAY + HRTIME_DAY / 4)
+#define HRTIME_WEEK (7 * HRTIME_DAY)
+#define HRTIME_DAY (24 * HRTIME_HOUR)
+#define HRTIME_HOUR (60 * HRTIME_MINUTE)
+#define HRTIME_MINUTE (60 * HRTIME_SECOND)
+#define HRTIME_SECOND (1000 * HRTIME_MSECOND)
+#define HRTIME_MSECOND (1000 * HRTIME_USECOND)
+#define HRTIME_USECOND (1000 * HRTIME_NSECOND)
+#define HRTIME_NSECOND (1LL)
+
+#define HRTIME_APPROX_SECONDS(_x) ((_x) >> 30) // off by 7.3%
+#define HRTIME_APPROX_FACTOR (((float)(1 << 30)) / (((float)HRTIME_SECOND)))
 
 //////////////////////////////////////////////////////////////////////////////
 //
@@ -94,12 +95,12 @@ get_hrtime_rdtsc()
 
 // simple macros
 
-#define HRTIME_YEARS(_x)    ((_x)*HRTIME_YEAR)
-#define HRTIME_WEEKS(_x)    ((_x)*HRTIME_WEEK)
-#define HRTIME_DAYS(_x)     ((_x)*HRTIME_DAY)
-#define HRTIME_HOURS(_x)    ((_x)*HRTIME_HOUR)
-#define HRTIME_MINUTES(_x)  ((_x)*HRTIME_MINUTE)
-#define HRTIME_SECONDS(_x)  ((_x)*HRTIME_SECOND)
+#define HRTIME_YEARS(_x) ((_x)*HRTIME_YEAR)
+#define HRTIME_WEEKS(_x) ((_x)*HRTIME_WEEK)
+#define HRTIME_DAYS(_x) ((_x)*HRTIME_DAY)
+#define HRTIME_HOURS(_x) ((_x)*HRTIME_HOUR)
+#define HRTIME_MINUTES(_x) ((_x)*HRTIME_MINUTE)
+#define HRTIME_SECONDS(_x) ((_x)*HRTIME_SECOND)
 #define HRTIME_MSECONDS(_x) ((_x)*HRTIME_MSECOND)
 #define HRTIME_USECONDS(_x) ((_x)*HRTIME_USECOND)
 #define HRTIME_NSECONDS(_x) ((_x)*HRTIME_NSECOND)
@@ -148,13 +149,13 @@ ink_hrtime_from_nsec(unsigned int nsec)
 }
 
 static inline ink_hrtime
-ink_hrtime_from_timespec(const struct timespec * ts)
+ink_hrtime_from_timespec(const struct timespec *ts)
 {
   return ink_hrtime_from_sec(ts->tv_sec) + ink_hrtime_from_nsec(ts->tv_nsec);
 }
 
 static inline ink_hrtime
-ink_hrtime_from_timeval(const struct timeval * tv)
+ink_hrtime_from_timeval(const struct timeval *tv)
 {
   return ink_hrtime_from_sec(tv->tv_sec) + ink_hrtime_from_usec(tv->tv_usec);
 }
@@ -168,42 +169,42 @@ ink_hrtime_from_timeval(const struct timeval * tv)
 static inline ink_hrtime
 ink_hrtime_to_years(ink_hrtime t)
 {
-  return ((ink_hrtime) (t / HRTIME_YEAR));
+  return ((ink_hrtime)(t / HRTIME_YEAR));
 }
 static inline ink_hrtime
 ink_hrtime_to_weeks(ink_hrtime t)
 {
-  return ((ink_hrtime) (t / HRTIME_WEEK));
+  return ((ink_hrtime)(t / HRTIME_WEEK));
 }
 static inline ink_hrtime
 ink_hrtime_to_days(ink_hrtime t)
 {
-  return ((ink_hrtime) (t / HRTIME_DAY));
+  return ((ink_hrtime)(t / HRTIME_DAY));
 }
 static inline ink_hrtime
 ink_hrtime_to_mins(ink_hrtime t)
 {
-  return ((ink_hrtime) (t / HRTIME_MINUTE));
+  return ((ink_hrtime)(t / HRTIME_MINUTE));
 }
 static inline ink_hrtime
 ink_hrtime_to_sec(ink_hrtime t)
 {
-  return ((ink_hrtime) (t / HRTIME_SECOND));
+  return ((ink_hrtime)(t / HRTIME_SECOND));
 }
 static inline ink_hrtime
 ink_hrtime_to_msec(ink_hrtime t)
 {
-  return ((ink_hrtime) (t / HRTIME_MSECOND));
+  return ((ink_hrtime)(t / HRTIME_MSECOND));
 }
 static inline ink_hrtime
 ink_hrtime_to_usec(ink_hrtime t)
 {
-  return ((ink_hrtime) (t / HRTIME_USECOND));
+  return ((ink_hrtime)(t / HRTIME_USECOND));
 }
 static inline ink_hrtime
 ink_hrtime_to_nsec(ink_hrtime t)
 {
-  return ((ink_hrtime) (t / HRTIME_NSECOND));
+  return ((ink_hrtime)(t / HRTIME_NSECOND));
 }
 
 static inline struct timespec
@@ -247,7 +248,7 @@ ink_hrtime_to_timeval2(ink_hrtime t, struct timeval *tv)
 static inline ink_hrtime
 ink_get_hrtime_internal()
 {
-#if defined (USE_TIME_STAMP_COUNTER_HRTIME)
+#if defined(USE_TIME_STAMP_COUNTER_HRTIME)
   return get_hrtime_rdtsc();
 #elif defined(freebsd)
   timespec ts;
@@ -277,7 +278,6 @@ ink_get_based_hrtime_internal()
 }
 
 
-
 static inline struct timeval
 ink_gettimeofday()
 {
@@ -293,13 +293,13 @@ ink_gethrtimeofday(struct timeval *tp, void *)
 static inline int
 ink_time()
 {
-  return (int) ink_hrtime_to_sec(ink_get_based_hrtime_internal());
+  return (int)ink_hrtime_to_sec(ink_get_based_hrtime_internal());
 }
 
 static inline int
 ink_hrtime_diff_msec(ink_hrtime t1, ink_hrtime t2)
 {
-  return (int) ink_hrtime_to_msec(t1 - t2);
+  return (int)ink_hrtime_to_msec(t1 - t2);
 }
 
 static inline ink_hrtime