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

masaori pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f06307131 Fix C-style cast in Cache subsystem (#11733)
6f06307131 is described below

commit 6f06307131614f3db6b965213262ba4b64af4e3c
Author: Masaori Koshiba <[email protected]>
AuthorDate: Wed Aug 28 10:02:56 2024 +0900

    Fix C-style cast in Cache subsystem (#11733)
    
    * Fix C-style cast in Cache subsystem
    
    * More C-style case fixes
    
    * Use static_cast as Josiah pointed out
    
    * Use reinterpret_cast for Region C size calculation of CacheVC
---
 include/iocore/cache/Cache.h                 | 11 ++++----
 src/iocore/cache/AggregateWriteBuffer.cc     |  2 +-
 src/iocore/cache/Cache.cc                    | 23 ++++++++--------
 src/iocore/cache/CacheDir.cc                 |  6 ++---
 src/iocore/cache/CacheDisk.cc                |  2 +-
 src/iocore/cache/CacheEvacuateDocVC.cc       | 17 ++++++------
 src/iocore/cache/CacheHosting.cc             |  2 +-
 src/iocore/cache/CacheHttp.cc                |  2 +-
 src/iocore/cache/CacheProcessor.cc           | 10 +++----
 src/iocore/cache/CacheRead.cc                | 40 ++++++++++++++--------------
 src/iocore/cache/CacheTest.cc                |  3 ++-
 src/iocore/cache/CacheVC.cc                  | 16 +++++------
 src/iocore/cache/CacheWrite.cc               |  8 +++---
 src/iocore/cache/P_CacheDir.h                |  4 +--
 src/iocore/cache/P_CacheHosting.h            |  5 +---
 src/iocore/cache/P_CacheInternal.h           | 20 +++++++-------
 src/iocore/cache/P_CacheTest.h               |  3 ++-
 src/iocore/cache/PreservationTable.cc        |  8 +++---
 src/iocore/cache/RamCacheCLFUS.cc            |  2 +-
 src/iocore/cache/Store.cc                    |  2 +-
 src/iocore/cache/Stripe.h                    |  4 +--
 src/iocore/cache/StripeSM.cc                 | 32 +++++++++++-----------
 src/iocore/cache/unit_tests/test_CacheDir.cc |  4 +--
 src/iocore/cache/unit_tests/test_CacheVol.cc |  2 +-
 24 files changed, 110 insertions(+), 118 deletions(-)

diff --git a/include/iocore/cache/Cache.h b/include/iocore/cache/Cache.h
index 953f476375..7e3a461ce1 100644
--- a/include/iocore/cache/Cache.h
+++ b/include/iocore/cache/Cache.h
@@ -79,16 +79,16 @@ struct CacheProcessor : public Processor {
   Action *open_read(Continuation *cont, const CacheKey *key, CacheFragType 
frag_type = CACHE_FRAG_TYPE_NONE,
                     const char *hostname = nullptr, int host_len = 0);
   Action *open_write(Continuation *cont, CacheKey *key, CacheFragType 
frag_type = CACHE_FRAG_TYPE_NONE,
-                     int expected_size = CACHE_EXPECTED_SIZE, int options = 0, 
time_t pin_in_cache = (time_t)0,
-                     char *hostname = nullptr, int host_len = 0);
+                     int expected_size = CACHE_EXPECTED_SIZE, int options = 0, 
time_t pin_in_cache = 0, char *hostname = nullptr,
+                     int host_len = 0);
   Action *remove(Continuation *cont, const CacheKey *key, CacheFragType 
frag_type = CACHE_FRAG_TYPE_NONE,
                  const char *hostname = nullptr, int host_len = 0);
   Action *scan(Continuation *cont, char *hostname = nullptr, int host_len = 0, 
int KB_per_second = SCAN_KB_PER_SECOND);
   Action *lookup(Continuation *cont, const HttpCacheKey *key, CacheFragType 
frag_type = CACHE_FRAG_TYPE_HTTP);
   Action *open_read(Continuation *cont, const HttpCacheKey *key, CacheHTTPHdr 
*request, const HttpConfigAccessor *params,
-                    time_t pin_in_cache = (time_t)0, CacheFragType frag_type = 
CACHE_FRAG_TYPE_HTTP);
+                    time_t pin_in_cache = 0, CacheFragType frag_type = 
CACHE_FRAG_TYPE_HTTP);
   Action *open_write(Continuation *cont, int expected_size, const HttpCacheKey 
*key, CacheHTTPHdr *request, CacheHTTPInfo *old_info,
-                     time_t pin_in_cache = (time_t)0, CacheFragType frag_type 
= CACHE_FRAG_TYPE_HTTP);
+                     time_t pin_in_cache = 0, CacheFragType frag_type = 
CACHE_FRAG_TYPE_HTTP);
   Action *remove(Continuation *cont, const HttpCacheKey *key, CacheFragType 
frag_type = CACHE_FRAG_TYPE_HTTP);
   Action *link(Continuation *cont, CacheKey *from, CacheKey *to, CacheFragType 
frag_type = CACHE_FRAG_TYPE_HTTP,
                char *hostname = nullptr, int host_len = 0);
@@ -175,9 +175,8 @@ struct CacheVConnection : public VConnection {
   void         reenable(VIO *avio) override                                    
                               = 0;
   void         reenable_re(VIO *avio) override                                 
                               = 0;
   void
-  do_io_shutdown(ShutdownHowTo_t howto) override
+  do_io_shutdown(ShutdownHowTo_t /* howto ATS_UNUSED */) override
   {
-    (void)howto;
     ink_assert(!"CacheVConnection::do_io_shutdown unsupported");
   }
 
diff --git a/src/iocore/cache/AggregateWriteBuffer.cc 
b/src/iocore/cache/AggregateWriteBuffer.cc
index 11f233c1cd..28a04340e3 100644
--- a/src/iocore/cache/AggregateWriteBuffer.cc
+++ b/src/iocore/cache/AggregateWriteBuffer.cc
@@ -65,6 +65,6 @@ AggregateWriteBuffer::flush(int fd, off_t write_pos) const
 void
 AggregateWriteBuffer::copy_from(char *dest, int offset, size_t nbytes) const
 {
-  ink_assert((offset + nbytes) <= (unsigned)this->_buffer_pos);
+  ink_assert((offset + nbytes) <= static_cast<size_t>(this->_buffer_pos));
   memcpy(dest, this->_buffer + offset, nbytes);
 }
diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc
index f8ba5f552f..169278ee08 100644
--- a/src/iocore/cache/Cache.cc
+++ b/src/iocore/cache/Cache.cc
@@ -273,8 +273,7 @@ Cache::open(bool clear, bool /* fix ATS_UNUSED */)
   total_good_nvol       = 0;
 
   REC_EstablishStaticConfigInt32(cache_config_min_average_object_size, 
"proxy.config.cache.min_average_object_size");
-  Dbg(dbg_ctl_cache_init, "Cache::open - 
proxy.config.cache.min_average_object_size = %d",
-      (int)cache_config_min_average_object_size);
+  Dbg(dbg_ctl_cache_init, "Cache::open - 
proxy.config.cache.min_average_object_size = %d", 
cache_config_min_average_object_size);
 
   CacheVol *cp = cp_list.head;
   for (; cp; cp = cp->link.next) {
@@ -348,7 +347,7 @@ Action *
 Cache::open_read(Continuation *cont, const CacheKey *key, CacheFragType type, 
const char *hostname, int host_len)
 {
   if (!CacheProcessor::IsCacheReady(type)) {
-    cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NOT_READY);
+    cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, reinterpret_cast<void 
*>(-ECACHE_NOT_READY));
     return ACTION_RESULT_DONE;
   }
   ink_assert(caches[type] == this);
@@ -396,7 +395,7 @@ Cache::open_read(Continuation *cont, const CacheKey *key, 
CacheFragType type, co
 Lmiss:
   
Metrics::Counter::increment(cache_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
   
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
-  cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC);
+  cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, reinterpret_cast<void 
*>(-ECACHE_NO_DOC));
   return ACTION_RESULT_DONE;
 Lwriter:
   SET_CONTINUATION_HANDLER(c, &CacheVC::openReadFromWriter);
@@ -417,7 +416,7 @@ Cache::open_write(Continuation *cont, const CacheKey *key, 
CacheFragType frag_ty
                   const char *hostname, int host_len)
 {
   if (!CacheProcessor::IsCacheReady(frag_type)) {
-    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void 
*)-ECACHE_NOT_READY);
+    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, reinterpret_cast<void 
*>(-ECACHE_NOT_READY));
     return ACTION_RESULT_DONE;
   }
 
@@ -456,7 +455,7 @@ Cache::open_write(Continuation *cont, const CacheKey *key, 
CacheFragType frag_ty
     // document currently being written, abort
     Metrics::Counter::increment(cache_rsb.status[c->op_type].failure);
     
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[c->op_type].failure);
-    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-res);
+    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, reinterpret_cast<void 
*>(-res));
     free_CacheVC(c);
     return ACTION_RESULT_DONE;
   }
@@ -551,7 +550,7 @@ Cache::open_read(Continuation *cont, const CacheKey *key, 
CacheHTTPHdr *request,
                  CacheFragType type, const char *hostname, int host_len)
 {
   if (!CacheProcessor::IsCacheReady(type)) {
-    cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NOT_READY);
+    cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, reinterpret_cast<void 
*>(-ECACHE_NOT_READY));
     return ACTION_RESULT_DONE;
   }
   ink_assert(caches[type] == this);
@@ -604,7 +603,7 @@ Cache::open_read(Continuation *cont, const CacheKey *key, 
CacheHTTPHdr *request,
 Lmiss:
   
Metrics::Counter::increment(cache_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
   
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
-  cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void *)-ECACHE_NO_DOC);
+  cont->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, reinterpret_cast<void 
*>(-ECACHE_NO_DOC));
   return ACTION_RESULT_DONE;
 Lwriter:
   cont->handleEvent(CACHE_EVENT_OPEN_READ_RWW, nullptr);
@@ -626,13 +625,13 @@ Cache::open_write(Continuation *cont, const CacheKey 
*key, CacheHTTPInfo *info,
                   const CacheKey * /* key1 ATS_UNUSED */, CacheFragType type, 
const char *hostname, int host_len)
 {
   if (!CacheProcessor::IsCacheReady(type)) {
-    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void 
*)-ECACHE_NOT_READY);
+    cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, reinterpret_cast<void 
*>(-ECACHE_NOT_READY));
     return ACTION_RESULT_DONE;
   }
 
   ink_assert(caches[type] == this);
   intptr_t err        = 0;
-  int      if_writers = (uintptr_t)info == CACHE_ALLOW_MULTIPLE_WRITES;
+  int      if_writers = reinterpret_cast<uintptr_t>(info) == 
CACHE_ALLOW_MULTIPLE_WRITES;
   CacheVC *c          = new_CacheVC(cont);
   c->vio.op           = VIO::WRITE;
   c->first_key        = *key;
@@ -651,7 +650,7 @@ Cache::open_write(Continuation *cont, const CacheKey *key, 
CacheHTTPInfo *info,
   c->stripe        = key_to_stripe(key, hostname, host_len);
   StripeSM *stripe = c->stripe;
   c->info          = info;
-  if (c->info && (uintptr_t)info != CACHE_ALLOW_MULTIPLE_WRITES) {
+  if (c->info && reinterpret_cast<uintptr_t>(info) != 
CACHE_ALLOW_MULTIPLE_WRITES) {
     /*
        Update has the following code paths :
        a) Update alternate header only :
@@ -744,7 +743,7 @@ Lmiss:
 Lfailure:
   Metrics::Counter::increment(cache_rsb.status[c->op_type].failure);
   
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[c->op_type].failure);
-  cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void *)-err);
+  cont->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, reinterpret_cast<void 
*>(-err));
   if (c->od) {
     c->openWriteCloseDir(EVENT_IMMEDIATE, nullptr);
     return ACTION_RESULT_DONE;
diff --git a/src/iocore/cache/CacheDir.cc b/src/iocore/cache/CacheDir.cc
index ebfc6f97a7..c6c4659e0b 100644
--- a/src/iocore/cache/CacheDir.cc
+++ b/src/iocore/cache/CacheDir.cc
@@ -777,8 +777,8 @@ int
 dir_lookaside_insert(EvacuationBlock *eblock, StripeSM *stripe, Dir *to)
 {
   CacheKey *key = &eblock->evac_frags.earliest_key;
-  DDbg(dbg_ctl_dir_lookaside, "insert %X %X, offset %d phase %d", 
key->slice32(0), key->slice32(1), (int)dir_offset(to),
-       (int)dir_phase(to));
+  DDbg(dbg_ctl_dir_lookaside, "insert %X %X, offset %" PRId64 " phase %d", 
key->slice32(0), key->slice32(1), dir_offset(to),
+       dir_phase(to));
   ink_assert(stripe->mutex->thread_holding == this_ethread());
   int              i         = key->slice32(3) % LOOKASIDE_SIZE;
   EvacuationBlock *b         = new_EvacuationBlock();
@@ -918,7 +918,7 @@ void
 sync_cache_dir_on_shutdown()
 {
   Dbg(dbg_ctl_cache_dir_sync, "sync started");
-  EThread *t = (EThread *)0xdeadbeef;
+  EThread *t = reinterpret_cast<EThread *>(0xdeadbeef);
   for (int i = 0; i < gnstripes; i++) {
     gstripes[i]->shutdown(t);
   }
diff --git a/src/iocore/cache/CacheDisk.cc b/src/iocore/cache/CacheDisk.cc
index df584460da..e81f8a71e6 100644
--- a/src/iocore/cache/CacheDisk.cc
+++ b/src/iocore/cache/CacheDisk.cc
@@ -80,7 +80,7 @@ CacheDisk::open(char *s, off_t blocks, off_t askip, int 
ahw_sector_size, int fil
   disk_stripes      = static_cast<DiskStripe **>(ats_calloc((l / 
MIN_STRIPE_SIZE + 1), sizeof(DiskStripe *)));
   header_len        = ROUND_TO_STORE_BLOCK(header_len);
   start             = skip + header_len;
-  num_usable_blocks = (off_t(len * STORE_BLOCK_SIZE) - (start - askip)) >> 
STORE_BLOCK_SHIFT;
+  num_usable_blocks = (static_cast<off_t>(len * STORE_BLOCK_SIZE) - (start - 
askip)) >> STORE_BLOCK_SHIFT;
 
   header = static_cast<DiskHeader *>(ats_memalign(ats_pagesize(), header_len));
   memset(header, 0, header_len);
diff --git a/src/iocore/cache/CacheEvacuateDocVC.cc 
b/src/iocore/cache/CacheEvacuateDocVC.cc
index c30c13a512..d9f0b4a4ba 100644
--- a/src/iocore/cache/CacheEvacuateDocVC.cc
+++ b/src/iocore/cache/CacheEvacuateDocVC.cc
@@ -52,9 +52,8 @@ CacheEvacuateDocVC::evacuateDocDone(int /* event ATS_UNUSED 
*/, Event * /* e ATS
 {
   ink_assert(this->stripe->mutex->thread_holding == this_ethread());
   Doc *doc = reinterpret_cast<Doc *>(this->buf->data());
-  DDbg(dbg_ctl_cache_evac, "evacuateDocDone %X o %d p %d new_o %d new_p %d", 
(int)key.slice32(0),
-       (int)dir_offset(&this->overwrite_dir), 
(int)dir_phase(&this->overwrite_dir), (int)dir_offset(&this->dir),
-       (int)dir_phase(&this->dir));
+  DDbg(dbg_ctl_cache_evac, "evacuateDocDone %X o %" PRId64 " p %d new_o %" 
PRId64 " new_p %d", key.slice32(0),
+       dir_offset(&this->overwrite_dir), dir_phase(&this->overwrite_dir), 
dir_offset(&this->dir), dir_phase(&this->dir));
   // nasty beeping race condition, need to have the EvacuationBlock here
   EvacuationBlock *b = 
this->stripe->get_preserved_dirs().find(this->overwrite_dir);
   if (b) {
@@ -97,16 +96,16 @@ CacheEvacuateDocVC::evacuateDocDone(int /* event ATS_UNUSED 
*/, Event * /* e ATS
     // Cache::open_write). Once we know its the vector, we can
     // safely overwrite the first_key in the directory.
     if (dir_head(&this->overwrite_dir) && b->f.evacuate_head) {
-      DDbg(dbg_ctl_cache_evac, "evacuateDocDone evacuate_head %X %X hlen %d 
offset %d", (int)key.slice32(0),
-           (int)doc->key.slice32(0), doc->hlen, 
(int)dir_offset(&this->overwrite_dir));
+      DDbg(dbg_ctl_cache_evac, "evacuateDocDone evacuate_head %X %X hlen %d 
offset %" PRId64, key.slice32(0), doc->key.slice32(0),
+           doc->hlen, dir_offset(&this->overwrite_dir));
 
       if (dir_compare_tag(&this->overwrite_dir, &doc->first_key)) {
         OpenDirEntry *cod;
-        DDbg(dbg_ctl_cache_evac, "evacuating vector: %X %d", 
(int)doc->first_key.slice32(0), (int)dir_offset(&this->overwrite_dir));
+        DDbg(dbg_ctl_cache_evac, "evacuating vector: %X %" PRId64, 
doc->first_key.slice32(0), dir_offset(&this->overwrite_dir));
         if ((cod = this->stripe->open_read(&doc->first_key))) {
           // writer  exists
-          DDbg(dbg_ctl_cache_evac, "overwriting the open directory %X %d %d", 
(int)doc->first_key.slice32(0),
-               (int)dir_offset(&cod->first_dir), (int)dir_offset(&this->dir));
+          DDbg(dbg_ctl_cache_evac, "overwriting the open directory %X %" 
PRId64 " %" PRId64, doc->first_key.slice32(0),
+               dir_offset(&cod->first_dir), dir_offset(&this->dir));
           cod->first_dir = this->dir;
         }
         if (dir_overwrite(&doc->first_key, this->stripe, &this->dir, 
&this->overwrite_dir)) {
@@ -114,7 +113,7 @@ CacheEvacuateDocVC::evacuateDocDone(int /* event ATS_UNUSED 
*/, Event * /* e ATS
           this->stripe->ram_cache->fixup(&doc->first_key, 
static_cast<uint64_t>(o), static_cast<uint64_t>(n));
         }
       } else {
-        DDbg(dbg_ctl_cache_evac, "evacuating earliest: %X %d", 
(int)doc->key.slice32(0), (int)dir_offset(&this->overwrite_dir));
+        DDbg(dbg_ctl_cache_evac, "evacuating earliest: %X %" PRId64, 
doc->key.slice32(0), dir_offset(&this->overwrite_dir));
         ink_assert(dir_compare_tag(&this->overwrite_dir, &doc->key));
         ink_assert(b->earliest_evacuator == this);
         this->total_len    += doc->data_len();
diff --git a/src/iocore/cache/CacheHosting.cc b/src/iocore/cache/CacheHosting.cc
index 97a1df6eb2..cc1daf61d4 100644
--- a/src/iocore/cache/CacheHosting.cc
+++ b/src/iocore/cache/CacheHosting.cc
@@ -523,7 +523,7 @@ CacheHostRecord::Init(matcher_line *line_info, CacheType 
typ)
               is_vol_present = 1;
               if (cachep->scheme == type) {
                 Dbg(dbg_ctl_cache_hosting, "Host Record: %p, Volume: %d, size: 
%ld", this, volume_number,
-                    (long)(cachep->size * STORE_BLOCK_SIZE));
+                    (static_cast<long>(cachep->size * STORE_BLOCK_SIZE)));
                 cp[num_cachevols] = cachep;
                 num_cachevols++;
                 num_vols += cachep->num_vols;
diff --git a/src/iocore/cache/CacheHttp.cc b/src/iocore/cache/CacheHttp.cc
index f5c245afa0..fd3621bbed 100644
--- a/src/iocore/cache/CacheHttp.cc
+++ b/src/iocore/cache/CacheHttp.cc
@@ -212,7 +212,7 @@ CacheHTTPInfoVector::unmarshal(const char *buf, int length, 
RefCountObj *block_p
     if (tmp < 0) {
       return -1;
     }
-    info.m_alt  = (HTTPCacheAlt *)buf;
+    info.m_alt  = reinterpret_cast<HTTPCacheAlt *>(const_cast<char *>(buf));
     buf        += tmp;
 
     data(xcount).alternate = info;
diff --git a/src/iocore/cache/CacheProcessor.cc 
b/src/iocore/cache/CacheProcessor.cc
index d1c80ba73c..916f4a66e1 100644
--- a/src/iocore/cache/CacheProcessor.cc
+++ b/src/iocore/cache/CacheProcessor.cc
@@ -586,7 +586,7 @@ build_vol_hash_table(CacheHostRecord *cp)
   }
   // generate random numbers proportional to allocation
   rtable_pair *rtable = static_cast<rtable_pair 
*>(ats_malloc(sizeof(rtable_pair) * rtable_size));
-  int          rindex = 0;
+  unsigned int rindex = 0;
   for (int i = 0; i < num_vols; i++) {
     for (int j = 0; j < static_cast<int>(rtable_entries[i]); j++) {
       rtable[rindex].rval = next_rand(&rnd[i]);
@@ -594,7 +594,7 @@ build_vol_hash_table(CacheHostRecord *cp)
       rindex++;
     }
   }
-  ink_assert(rindex == (int)rtable_size);
+  ink_assert(rindex == rtable_size);
   // sort (rand #, vol $ pairs)
   qsort(rtable, rtable_size, sizeof(rtable_pair), cmprtable);
   unsigned int width = (1LL << 32) / STRIPE_HASH_TABLE_SIZE;
@@ -630,8 +630,8 @@ build_vol_hash_table(CacheHostRecord *cp)
 int
 cmprtable(const void *aa, const void *bb)
 {
-  rtable_pair *a = (rtable_pair *)aa;
-  rtable_pair *b = (rtable_pair *)bb;
+  const rtable_pair *a = static_cast<const rtable_pair *>(aa);
+  const rtable_pair *b = static_cast<const rtable_pair *>(bb);
   if (a->rval < b->rval) {
     return -1;
   }
@@ -1072,7 +1072,7 @@ cplist_init()
       CacheVol *p = cp_list.head;
       while (p) {
         if (p->vol_number == dp[j]->vol_number) {
-          ink_assert(p->scheme == (int)dp[j]->dpb_queue.head->b->type);
+          ink_assert(p->scheme == 
static_cast<int>(dp[j]->dpb_queue.head->b->type));
           p->size            += dp[j]->size;
           p->num_vols        += dp[j]->num_volblocks;
           p->disk_stripes[i]  = dp[j];
diff --git a/src/iocore/cache/CacheRead.cc b/src/iocore/cache/CacheRead.cc
index feae1659a9..78d1e267b9 100644
--- a/src/iocore/cache/CacheRead.cc
+++ b/src/iocore/cache/CacheRead.cc
@@ -227,7 +227,7 @@ CacheVC::openReadFromWriter(int event, Event *e)
       if (writer_lock_retry < cache_config_read_while_writer_max_retries) {
         VC_SCHED_WRITER_RETRY();
       } else {
-        return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event 
*)-err);
+        return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, 
reinterpret_cast<Event *>(-err));
       }
     } else {
       ink_assert(write_vc);
@@ -259,7 +259,7 @@ CacheVC::openReadFromWriter(int event, Event *e)
     if (!cache_config_read_while_writer || frag_type != CACHE_FRAG_TYPE_HTTP ||
         writer_lock_retry >= cache_config_read_while_writer_max_retries) {
       MUTEX_RELEASE(lock);
-      return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event 
*)-err);
+      return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, 
reinterpret_cast<Event *>(-err));
     }
     DDbg(dbg_ctl_cache_read_agg, "%p: key: %X writer: closed:%d, fragment:%d, 
retry: %d", this, first_key.slice32(1),
          write_vc->closed, write_vc->fragment, writer_lock_retry);
@@ -274,13 +274,13 @@ CacheVC::openReadFromWriter(int event, Event *e)
   MUTEX_RELEASE(lock);
 
   if (!write_vc->io.ok()) {
-    return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event 
*)-err);
+    return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, 
reinterpret_cast<Event *>(-err));
   }
   if (frag_type == CACHE_FRAG_TYPE_HTTP) {
     DDbg(dbg_ctl_cache_read_agg, "%p: key: %X http passed stage 1, closed: %d, 
frag: %d", this, first_key.slice32(1),
          write_vc->closed, write_vc->fragment);
     if (!write_vc->alternate.valid()) {
-      return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, (Event 
*)-err);
+      return openReadFromWriterFailure(CACHE_EVENT_OPEN_READ_FAILED, 
reinterpret_cast<Event *>(-err));
     }
     alternate.copy(&write_vc->alternate);
     vector.insert(&alternate);
@@ -334,8 +334,8 @@ CacheVC::openReadFromWriter(int event, Event *e)
   if (write_vc->fragment) {
     doc_len        = write_vc->vio.nbytes;
     last_collision = nullptr;
-    DDbg(dbg_ctl_cache_read_agg, "%p: key: %X closed: %d, fragment: %d, len: 
%d starting first fragment", this,
-         first_key.slice32(1), write_vc->closed, write_vc->fragment, 
(int)doc_len);
+    DDbg(dbg_ctl_cache_read_agg, "%p: key: %X closed: %d, fragment: %d, len: 
%" PRIu64 " starting first fragment", this,
+         first_key.slice32(1), write_vc->closed, write_vc->fragment, doc_len);
     MUTEX_RELEASE(writer_lock);
     // either a header + body update or a new document
     SET_HANDLER(&CacheVC::openReadStartEarliest);
@@ -378,7 +378,7 @@ CacheVC::openReadFromWriterMain(int /* event ATS_UNUSED */, 
Event * /* e ATS_UNU
     if (is_action_tag_set("cache")) {
       ink_release_assert(false);
     }
-    Warning("Document %X truncated at %d of %d, reading from writer", 
first_key.slice32(1), (int)vio.ndone, (int)doc_len);
+    Warning("Document %X truncated at %" PRId64 " of %" PRIu64 ", reading from 
writer", first_key.slice32(1), vio.ndone, doc_len);
     return calluser(VC_EVENT_ERROR);
   }
   /* its possible that the user did a do_io_close before
@@ -483,20 +483,20 @@ CacheVC::openReadReadDone(int event, Event *e)
         last_collision = nullptr;
         while (dir_probe(&earliest_key, stripe, &dir, &last_collision)) {
           if (dir_offset(&dir) == dir_offset(&earliest_dir)) {
-            DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead complete: %d", 
this, first_key.slice32(1), (int)vio.ndone);
+            DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead complete: %" 
PRId64, this, first_key.slice32(1), vio.ndone);
             doc_len = vio.ndone;
             goto Ldone;
           }
         }
-        DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead writer aborted: 
%d", this, first_key.slice32(1), (int)vio.ndone);
+        DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead writer aborted: %" 
PRId64, this, first_key.slice32(1), vio.ndone);
         goto Lerror;
       }
       if (writer_lock_retry < cache_config_read_while_writer_max_retries) {
-        DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead retrying: %d", 
this, first_key.slice32(1), (int)vio.ndone);
+        DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead retrying: %" 
PRId64, this, first_key.slice32(1), vio.ndone);
         VC_SCHED_WRITER_RETRY(); // wait for writer
       } else {
-        DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead retries exhausted, 
bailing..: %d", this, first_key.slice32(1),
-             (int)vio.ndone);
+        DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadRead retries exhausted, 
bailing..: %" PRId64, this, first_key.slice32(1),
+             vio.ndone);
         goto Ldone;
       }
     }
@@ -710,22 +710,22 @@ Lread: {
       last_collision = nullptr;
       while (dir_probe(&earliest_key, stripe, &dir, &last_collision)) {
         if (dir_offset(&dir) == dir_offset(&earliest_dir)) {
-          DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadMain complete: %d", 
this, first_key.slice32(1), (int)vio.ndone);
+          DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadMain complete: %" 
PRId64, this, first_key.slice32(1), vio.ndone);
           doc_len = vio.ndone;
           goto Leos;
         }
       }
-      DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadMain writer aborted: %d", 
this, first_key.slice32(1), (int)vio.ndone);
+      DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadMain writer aborted: %" 
PRId64, this, first_key.slice32(1), vio.ndone);
       goto Lerror;
     }
-    DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadMain retrying: %d", this, 
first_key.slice32(1), (int)vio.ndone);
+    DDbg(dbg_ctl_cache_read_agg, "%p: key: %X ReadMain retrying: %" PRId64, 
this, first_key.slice32(1), vio.ndone);
     SET_HANDLER(&CacheVC::openReadMain);
     VC_SCHED_WRITER_RETRY();
   }
   if (is_action_tag_set("cache")) {
     ink_release_assert(false);
   }
-  Warning("Document %X truncated at %d of %d, missing fragment %X", 
first_key.slice32(1), (int)vio.ndone, (int)doc_len,
+  Warning("Document %X truncated at %" PRId64 " of %" PRIu64 ", missing 
fragment %X", first_key.slice32(1), vio.ndone, doc_len,
           key.slice32(1));
   // remove the directory entry
   dir_delete(&earliest_key, stripe, &earliest_dir);
@@ -878,7 +878,7 @@ CacheVC::openReadStartEarliest(int /* event ATS_UNUSED */, 
Event * /* e ATS_UNUS
   }
   
Metrics::Counter::increment(cache_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
   
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
-  _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void 
*)-ECACHE_NO_DOC);
+  _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, 
reinterpret_cast<void *>(-ECACHE_NO_DOC));
   return free_CacheVC(this);
 Lcallreturn:
   return handleEvent(AIO_EVENT_DONE, nullptr); // hopefully a tail call
@@ -938,7 +938,7 @@ CacheVC::openReadVecWrite(int /* event ATS_UNUSED */, Event 
* /* e ATS_UNUSED */
 
   
Metrics::Counter::increment(cache_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
   
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
-  _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void 
*)-ECACHE_ALT_MISS);
+  _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, 
reinterpret_cast<void *>(-ECACHE_ALT_MISS));
   return free_CacheVC(this);
 Lrestart:
   SET_HANDLER(&CacheVC::openReadStartHead);
@@ -1146,11 +1146,11 @@ Ldone:
   if (!f.lookup) {
     
Metrics::Counter::increment(cache_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
     
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[static_cast<int>(CacheOpType::Read)].failure);
-    _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, (void 
*)-err);
+    _action.continuation->handleEvent(CACHE_EVENT_OPEN_READ_FAILED, 
reinterpret_cast<void *>(-err));
   } else {
     
Metrics::Counter::increment(cache_rsb.status[static_cast<int>(CacheOpType::Lookup)].failure);
     
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[static_cast<int>(CacheOpType::Lookup)].failure);
-    _action.continuation->handleEvent(CACHE_EVENT_LOOKUP_FAILED, (void *)-err);
+    _action.continuation->handleEvent(CACHE_EVENT_LOOKUP_FAILED, 
reinterpret_cast<void *>(-err));
   }
   return free_CacheVC(this);
 Lcallreturn:
diff --git a/src/iocore/cache/CacheTest.cc b/src/iocore/cache/CacheTest.cc
index 0461991268..32d6c44942 100644
--- a/src/iocore/cache/CacheTest.cc
+++ b/src/iocore/cache/CacheTest.cc
@@ -24,6 +24,7 @@
 
 #include "P_Cache.h"
 #include "P_CacheTest.h"
+#include "proxy/RegressionSM.h"
 #include "tscore/Random.h"
 #include <vector>
 #include <cmath>
@@ -38,7 +39,7 @@ CacheTestSM::CacheTestSM(const CacheTestSM &ao) : 
RegressionSM(ao)
 {
   int o = static_cast<int>((reinterpret_cast<char *>(&start_memcpy_on_clone)) 
- (reinterpret_cast<char *>(this)));
   int s = static_cast<int>((reinterpret_cast<char *>(&end_memcpy_on_clone)) - 
(reinterpret_cast<char *>(&start_memcpy_on_clone)));
-  memcpy((reinterpret_cast<char *>(this)) + o, ((char *)&ao) + o, s);
+  memcpy((reinterpret_cast<char *>(this)) + o, (reinterpret_cast<const char 
*>(&ao)) + o, s);
   SET_HANDLER(&CacheTestSM::event_handler);
 }
 
diff --git a/src/iocore/cache/CacheVC.cc b/src/iocore/cache/CacheVC.cc
index 63442e05e2..4f2e09e52e 100644
--- a/src/iocore/cache/CacheVC.cc
+++ b/src/iocore/cache/CacheVC.cc
@@ -162,8 +162,9 @@ int CacheVC::size_to_init = -1;
 
 CacheVC::CacheVC()
 {
-  size_to_init = sizeof(CacheVC) - (size_t) & ((CacheVC *)nullptr)->vio;
-  memset((void *)&vio, 0, size_to_init);
+  // Initialize Region C
+  size_to_init = sizeof(CacheVC) - 
reinterpret_cast<size_t>(&(static_cast<CacheVC *>(nullptr))->vio);
+  memset(reinterpret_cast<void *>(&vio), 0, size_to_init);
 }
 
 VIO *
@@ -238,7 +239,6 @@ void
 CacheVC::reenable(VIO *avio)
 {
   DDbg(dbg_ctl_cache_reenable, "reenable %p", this);
-  (void)avio;
 #ifdef DEBUG
   ink_assert(avio->mutex->thread_holding);
 #endif
@@ -258,13 +258,12 @@ void
 CacheVC::reenable_re(VIO *avio)
 {
   DDbg(dbg_ctl_cache_reenable, "reenable_re %p", this);
-  (void)avio;
 #ifdef DEBUG
   ink_assert(avio->mutex->thread_holding);
 #endif
   if (!trigger) {
     if (!is_io_in_progress() && !recursive) {
-      handleEvent(EVENT_NONE, (void *)nullptr);
+      handleEvent(EVENT_NONE);
     } else {
       trigger = avio->mutex->thread_holding->schedule_imm_local(this);
     }
@@ -336,7 +335,7 @@ unmarshal_helper(Doc *doc, Ptr<IOBufferData> &buf, int 
&okay)
 
 // [amc] I think this is where all disk reads from cache funnel through here.
 int
-CacheVC::handleReadDone(int event, Event *e)
+CacheVC::handleReadDone(int event, Event * /* e ATS_UNUSED */)
 {
   cancel_trigger();
   ink_assert(this_ethread() == mutex->thread_holding);
@@ -407,7 +406,6 @@ CacheVC::handleReadDone(int event, Event *e)
           okay       = 0;
         }
       }
-      (void)e; // Avoid compiler warnings
       bool http_copy_hdr = false;
       http_copy_hdr =
         cache_config_ram_cache_compress && !f.doc_from_ram_cache && 
doc->doc_type == CACHE_FRAG_TYPE_HTTP && doc->hlen;
@@ -616,7 +614,7 @@ CacheVC::removeEvent(int /* event ATS_UNUSED */, Event * /* 
e ATS_UNUSED */)
     }
   }
   ink_assert(!stripe || this_ethread() != stripe->mutex->thread_holding);
-  _action.continuation->handleEvent(CACHE_EVENT_REMOVE_FAILED, (void 
*)-ECACHE_NO_DOC);
+  _action.continuation->handleEvent(CACHE_EVENT_REMOVE_FAILED, 
reinterpret_cast<void *>(-ECACHE_NO_DOC));
   goto Lfree;
 Lremoved:
   _action.continuation->handleEvent(CACHE_EVENT_REMOVE, nullptr);
@@ -709,7 +707,7 @@ CacheVC::scanObject(int /* event ATS_UNUSED */, Event * /* 
e ATS_UNUSED */)
   }
 
   if (!io.ok()) {
-    result = (void *)-ECACHE_READ_FAIL;
+    result = reinterpret_cast<void *>(-ECACHE_READ_FAIL);
     goto Ldone;
   }
 
diff --git a/src/iocore/cache/CacheWrite.cc b/src/iocore/cache/CacheWrite.cc
index 4fbfce8987..e31015032d 100644
--- a/src/iocore/cache/CacheWrite.cc
+++ b/src/iocore/cache/CacheWrite.cc
@@ -306,7 +306,7 @@ CacheVC::openWriteCloseDir(int /* event ATS_UNUSED */, 
Event * /* e ATS_UNUSED *
   if (f.close_complete) {
     recursive++;
     ink_assert(!stripe || this_ethread() != stripe->mutex->thread_holding);
-    vio.cont->handleEvent(VC_EVENT_WRITE_COMPLETE, (void *)&vio);
+    vio.cont->handleEvent(VC_EVENT_WRITE_COMPLETE, reinterpret_cast<void 
*>(&vio));
     recursive--;
   }
   return free_CacheVC(this);
@@ -718,7 +718,7 @@ CacheVC::openWriteStartDone(int event, Event *e)
     }
 
   Lcollision:
-    int if_writers = ((uintptr_t)info == CACHE_ALLOW_MULTIPLE_WRITES);
+    int if_writers = (reinterpret_cast<uintptr_t>(info) == 
CACHE_ALLOW_MULTIPLE_WRITES);
     if (!od) {
       if ((err = stripe->open_write(this, if_writers, 
cache_config_http_max_alts > 1 ? cache_config_http_max_alts : 0)) > 0) {
         goto Lfailure;
@@ -754,7 +754,7 @@ Lsuccess:
 Lfailure:
   Metrics::Counter::increment(cache_rsb.status[op_type].failure);
   
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[op_type].failure);
-  _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void 
*)-err);
+  _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, 
reinterpret_cast<void *>(-err));
 Lcancel:
   if (od) {
     od->reading_vec = false;
@@ -779,7 +779,7 @@ CacheVC::openWriteStartBegin(int /* event ATS_UNUSED */, 
Event * /* e ATS_UNUSED
     Metrics::Counter::increment(cache_rsb.status[op_type].failure);
     
Metrics::Counter::increment(stripe->cache_vol->vol_rsb.status[op_type].failure);
     free_CacheVC(this);
-    _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, (void 
*)-err);
+    _action.continuation->handleEvent(CACHE_EVENT_OPEN_WRITE_FAILED, 
reinterpret_cast<void *>(-err));
     return EVENT_DONE;
   }
   if (err < 0) {
diff --git a/src/iocore/cache/P_CacheDir.h b/src/iocore/cache/P_CacheDir.h
index e174308db0..a1efff1961 100644
--- a/src/iocore/cache/P_CacheDir.h
+++ b/src/iocore/cache/P_CacheDir.h
@@ -316,9 +316,9 @@ inline int64_t
 dir_to_offset(const Dir *d, const Dir *seg)
 {
 #if DIR_DEPTH < 5
-  return (((char *)d) - ((char *)seg)) / SIZEOF_DIR;
+  return (reinterpret_cast<const char *>(d) - reinterpret_cast<const char 
*>(seg)) / SIZEOF_DIR;
 #else
-  int64_t i = (int64_t)((((char *)d) - ((char *)seg)) / SIZEOF_DIR);
+  int64_t i = static_cast<int64_t>((reinterpret_cast<const char *>(d) - 
reinterpret_cast<const char *>(seg)) / SIZEOF_DIR);
   i         = i - (i / DIR_DEPTH);
   return i;
 #endif
diff --git a/src/iocore/cache/P_CacheHosting.h 
b/src/iocore/cache/P_CacheHosting.h
index 99a81de2b7..1802ba7665 100644
--- a/src/iocore/cache/P_CacheHosting.h
+++ b/src/iocore/cache/P_CacheHosting.h
@@ -267,11 +267,8 @@ struct CacheHostTableConfig : public Continuation {
   ~CacheHostTableConfig() {}
 
   int
-  mainEvent(int event, Event *e)
+  mainEvent(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
   {
-    (void)e;
-    (void)event;
-
     CacheType type  = CACHE_HTTP_TYPE;
     Cache    *cache = nullptr;
     {
diff --git a/src/iocore/cache/P_CacheInternal.h 
b/src/iocore/cache/P_CacheInternal.h
index 80e9f15634..8f3ffab880 100644
--- a/src/iocore/cache/P_CacheInternal.h
+++ b/src/iocore/cache/P_CacheInternal.h
@@ -222,7 +222,7 @@ free_CacheVCCommon(CacheVC *cont)
 
   ats_free(cont->scan_stripe_map);
 
-  memset((char *)&cont->vio, 0, cont->size_to_init);
+  memset(reinterpret_cast<char *>(&cont->vio), 0, cont->size_to_init);
 #ifdef DEBUG
   SET_CONTINUATION_HANDLER(cont, &CacheVC::dead);
 #endif
@@ -250,7 +250,7 @@ CacheVC::calluser(int event)
 {
   recursive++;
   ink_assert(!stripe || this_ethread() != stripe->mutex->thread_holding);
-  vio.cont->handleEvent(event, (void *)&vio);
+  vio.cont->handleEvent(event, &vio);
   recursive--;
   if (closed) {
     die();
@@ -316,7 +316,7 @@ CacheVC::die()
     return EVENT_CONT;
   } else {
     if (is_io_in_progress()) {
-      save_handler = (ContinuationHandler)&CacheVC::openReadClose;
+      save_handler = 
reinterpret_cast<ContinuationHandler>(&CacheVC::openReadClose);
     } else {
       SET_HANDLER(&CacheVC::openReadClose);
       if (!recursive) {
@@ -373,7 +373,7 @@ CacheVC::writer_done()
   // original writer, since we never choose a writer that started
   // after the reader. The original writer was deallocated and then
   // reallocated for the same first_key
-  for (; w && (w != write_vc || w->start_time > start_time); w = (CacheVC 
*)w->opendir_link.next) {
+  for (; w && (w != write_vc || w->start_time > start_time); w = 
w->opendir_link.next) {
     ;
   }
   if (!w) {
@@ -436,10 +436,8 @@ free_CacheRemoveCont(CacheRemoveCont *cache_rm)
 }
 
 inline int
-CacheRemoveCont::event_handler(int event, void *data)
+CacheRemoveCont::event_handler(int /* event ATS_UNUSED */, void * /* data 
ATS_UNUSED */)
 {
-  (void)event;
-  (void)data;
   free_CacheRemoveCont(this);
   return EVENT_DONE;
 }
@@ -464,15 +462,15 @@ struct Cache {
 
   Action *lookup(Continuation *cont, const CacheKey *key, CacheFragType type, 
const char *hostname, int host_len);
   Action *open_read(Continuation *cont, const CacheKey *key, CacheFragType 
type, const char *hostname, int len);
-  Action *open_write(Continuation *cont, const CacheKey *key, CacheFragType 
frag_type, int options = 0,
-                     time_t pin_in_cache = (time_t)0, const char *hostname = 
nullptr, int host_len = 0);
+  Action *open_write(Continuation *cont, const CacheKey *key, CacheFragType 
frag_type, int options = 0, time_t pin_in_cache = 0,
+                     const char *hostname = nullptr, int host_len = 0);
   Action *remove(Continuation *cont, const CacheKey *key, CacheFragType type = 
CACHE_FRAG_TYPE_HTTP, const char *hostname = nullptr,
                  int host_len = 0);
   Action *scan(Continuation *cont, const char *hostname = nullptr, int 
host_len = 0, int KB_per_second = 2500);
 
   Action     *open_read(Continuation *cont, const CacheKey *key, CacheHTTPHdr 
*request, const HttpConfigAccessor *params,
                         CacheFragType type, const char *hostname, int 
host_len);
-  Action     *open_write(Continuation *cont, const CacheKey *key, 
CacheHTTPInfo *old_info, time_t pin_in_cache = (time_t)0,
+  Action     *open_write(Continuation *cont, const CacheKey *key, 
CacheHTTPInfo *old_info, time_t pin_in_cache = 0,
                          const CacheKey *key1 = nullptr, CacheFragType type = 
CACHE_FRAG_TYPE_HTTP, const char *hostname = nullptr,
                          int host_len = 0);
   static void generate_key(CryptoHash *hash, CacheURL *url);
@@ -507,6 +505,6 @@ inline unsigned int
 cache_hash(const CryptoHash &hash)
 {
   uint64_t     f     = hash.fold();
-  unsigned int mhash = (unsigned int)(f >> 32);
+  unsigned int mhash = static_cast<unsigned int>(f >> 32);
   return mhash;
 }
diff --git a/src/iocore/cache/P_CacheTest.h b/src/iocore/cache/P_CacheTest.h
index 321e6dcb1a..cb4988f069 100644
--- a/src/iocore/cache/P_CacheTest.h
+++ b/src/iocore/cache/P_CacheTest.h
@@ -106,8 +106,9 @@ struct CacheTestSM : public RegressionSM {
   void
   cancel_timeout()
   {
-    if (timeout)
+    if (timeout) {
       timeout->cancel();
+    }
     timeout = nullptr;
   }
 
diff --git a/src/iocore/cache/PreservationTable.cc 
b/src/iocore/cache/PreservationTable.cc
index 67febf4bf4..c45deb2d95 100644
--- a/src/iocore/cache/PreservationTable.cc
+++ b/src/iocore/cache/PreservationTable.cc
@@ -56,8 +56,8 @@ PreservationTable::force_evacuate_head(Dir const *evac_dir, 
int pinned)
 {
   auto bucket = dir_evac_bucket(evac_dir);
   if (!evac_bucket_valid(bucket)) {
-    DDbg(dbg_ctl_cache_evac, "dir_evac_bucket out of bounds, skipping 
evacuate: %" PRId64 "(%d), %d, %d", bucket, evacuate_size,
-         (int)dir_offset(evac_dir), (int)dir_phase(evac_dir));
+    DDbg(dbg_ctl_cache_evac, "dir_evac_bucket out of bounds, skipping 
evacuate: %" PRId64 "(%d), %" PRId64 " , %d", bucket,
+         evacuate_size, dir_offset(evac_dir), dir_phase(evac_dir));
     return;
   }
 
@@ -72,7 +72,7 @@ PreservationTable::force_evacuate_head(Dir const *evac_dir, 
int pinned)
   if (!b) {
     b      = new_EvacuationBlock();
     b->dir = *evac_dir;
-    DDbg(dbg_ctl_cache_evac, "force: %d, %d", (int)dir_offset(evac_dir), 
(int)dir_phase(evac_dir));
+    DDbg(dbg_ctl_cache_evac, "force: %" PRId64 ", %d", dir_offset(evac_dir), 
dir_phase(evac_dir));
     evacuate[bucket].push(b);
   }
   b->f.pinned        = pinned;
@@ -194,7 +194,7 @@ PreservationTable::remove_finished_blocks(Stripe const 
*stripe, int bucket)
     if (b->f.done && ((stripe->header->phase != dir_phase(&b->dir) && 
stripe->header->write_pos > stripe->vol_offset(&b->dir)) ||
                       (stripe->header->phase == dir_phase(&b->dir) && 
stripe->header->write_pos <= stripe->vol_offset(&b->dir)))) {
       EvacuationBlock *x = b;
-      DDbg(dbg_ctl_cache_evac, "evacuate cleanup free %X offset %d", 
(int)b->evac_frags.key.slice32(0), (int)dir_offset(&b->dir));
+      DDbg(dbg_ctl_cache_evac, "evacuate cleanup free %X offset %" PRId64, 
b->evac_frags.key.slice32(0), dir_offset(&b->dir));
       b = b->link.next;
       evacuate[bucket].remove(x);
       free_EvacuationBlock(x);
diff --git a/src/iocore/cache/RamCacheCLFUS.cc 
b/src/iocore/cache/RamCacheCLFUS.cc
index cba3b863fd..56995cbb65 100644
--- a/src/iocore/cache/RamCacheCLFUS.cc
+++ b/src/iocore/cache/RamCacheCLFUS.cc
@@ -40,7 +40,7 @@
 // #define CHECK_ACOUNTING 1 // very expensive double checking of all sizes
 
 #define REQUEUE_HITS(_h)              ((_h) ? ((_h) - 1) : 0)
-#define CACHE_VALUE_HITS_SIZE(_h, _s) ((float)((_h) + 1) / ((_s) + 
ENTRY_OVERHEAD))
+#define CACHE_VALUE_HITS_SIZE(_h, _s) (static_cast<float>(((_h) + 1) / ((_s) + 
ENTRY_OVERHEAD)))
 #define CACHE_VALUE(_x)               CACHE_VALUE_HITS_SIZE((_x)->hits, 
(_x)->size)
 
 #define AVERAGE_VALUE_OVER 100
diff --git a/src/iocore/cache/Store.cc b/src/iocore/cache/Store.cc
index e24803fad9..96975661d1 100644
--- a/src/iocore/cache/Store.cc
+++ b/src/iocore/cache/Store.cc
@@ -234,7 +234,7 @@ Store::read_config()
   fd = ::open(storage_path, O_RDONLY);
   if (fd < 0) {
     Error("%s failed to load", ts::filename::STORAGE);
-    return Result::failure("open %s: %s", (const char *)storage_path, 
strerror(errno));
+    return Result::failure("open %s: %s", storage_path.get(), strerror(errno));
   }
 
   // For each line
diff --git a/src/iocore/cache/Stripe.h b/src/iocore/cache/Stripe.h
index c65715c377..086722d5e2 100644
--- a/src/iocore/cache/Stripe.h
+++ b/src/iocore/cache/Stripe.h
@@ -187,7 +187,7 @@ Stripe::direntries() const
 inline Dir *
 Stripe::dir_segment(int s) const
 {
-  return (Dir *)(((char *)this->dir) + (s * this->buckets) * DIR_DEPTH * 
SIZEOF_DIR);
+  return reinterpret_cast<Dir *>((reinterpret_cast<char *>(this->dir)) + (s * 
this->buckets) * DIR_DEPTH * SIZEOF_DIR);
 }
 
 inline size_t
@@ -255,7 +255,7 @@ Stripe::vol_in_phase_agg_buf_valid(Dir const *e) const
 inline off_t
 Stripe::vol_offset(Dir const *e) const
 {
-  return this->start + (off_t)dir_offset(e) * CACHE_BLOCK_SIZE - 
CACHE_BLOCK_SIZE;
+  return this->start + static_cast<off_t>(dir_offset(e)) * CACHE_BLOCK_SIZE - 
CACHE_BLOCK_SIZE;
 }
 
 inline off_t
diff --git a/src/iocore/cache/StripeSM.cc b/src/iocore/cache/StripeSM.cc
index d590f31e65..228ffa3979 100644
--- a/src/iocore/cache/StripeSM.cc
+++ b/src/iocore/cache/StripeSM.cc
@@ -183,7 +183,7 @@ StripeSM::init(char *s, off_t blocks, off_t dir_skip, bool 
clear)
   memset(static_cast<void *>(this->_preserved_dirs.evacuate), 0, evac_len);
 
   Dbg(dbg_ctl_cache_init, "Vol %s: allocating %zu directory bytes for a %lld 
byte volume (%lf%%)", hash_text.get(), dirlen(),
-      (long long)this->len, (double)dirlen() / (double)this->len * 100.0);
+      static_cast<long long>(this->len), static_cast<double>(dirlen()) / 
static_cast<double>(this->len) * 100.0);
 
   raw_dir = nullptr;
   if (ats_hugepage_enabled()) {
@@ -908,12 +908,12 @@ StripeSM::aggregate_pending_writes(Queue<CacheVC, 
Continuation::Link_link> &toca
          this->header->write_pos + this->_write_buffer.get_buffer_pos(), 
c->first_key.slice32(0));
     [[maybe_unused]] int wrotelen = this->_agg_copy(c);
     ink_assert(writelen == wrotelen);
-    CacheVC *n = (CacheVC *)c->link.next;
+    CacheVC *n = static_cast<CacheVC *>(c->link.next);
     this->_write_buffer.get_pending_writers().dequeue();
     if (c->f.sync && c->f.use_first_key) {
       CacheVC *last = this->sync.tail;
       while (last && UINT_WRAP_LT(c->write_serial, last->write_serial)) {
-        last = (CacheVC *)last->link.prev;
+        last = static_cast<CacheVC *>(last->link.prev);
       }
       this->sync.insert(c, last);
     } else if (c->f.evacuator) {
@@ -1144,7 +1144,7 @@ StripeSM::evac_range(off_t low, off_t high, int 
evac_phase)
       io.aiocb.aio_buf = doc_evacuator->buf->data();
       io.action        = this;
       io.thread        = AIO_CALLBACK_THREAD_ANY;
-      DDbg(dbg_ctl_cache_evac, "evac_range evacuating %X %d", 
(int)dir_tag(&first->dir), (int)dir_offset(&first->dir));
+      DDbg(dbg_ctl_cache_evac, "evac_range evacuating %X %" PRId64, 
dir_tag(&first->dir), dir_offset(&first->dir));
       SET_HANDLER(&StripeSM::evacuateDocReadDone);
       ink_assert(ink_aio_read(&io) >= 0);
       return -1;
@@ -1168,13 +1168,13 @@ StripeSM::evacuateDocReadDone(int event, Event *e)
   EvacuationBlock *b      = nullptr;
   auto             bucket = dir_evac_bucket(&doc_evacuator->overwrite_dir);
   if (doc->magic != DOC_MAGIC) {
-    Dbg(dbg_ctl_cache_evac, "DOC magic: %X %d", 
(int)dir_tag(&doc_evacuator->overwrite_dir),
-        (int)dir_offset(&doc_evacuator->overwrite_dir));
+    Dbg(dbg_ctl_cache_evac, "DOC magic: %X %" PRId64, 
dir_tag(&doc_evacuator->overwrite_dir),
+        dir_offset(&doc_evacuator->overwrite_dir));
     ink_assert(doc->magic == DOC_MAGIC);
     goto Ldone;
   }
-  DDbg(dbg_ctl_cache_evac, "evacuateDocReadDone %X offset %d", 
(int)doc->key.slice32(0),
-       (int)dir_offset(&doc_evacuator->overwrite_dir));
+  DDbg(dbg_ctl_cache_evac, "evacuateDocReadDone %X offset %" PRId64, 
doc->key.slice32(0),
+       dir_offset(&doc_evacuator->overwrite_dir));
 
   if (evac_bucket_valid(bucket)) {
     b = this->_preserved_dirs.evacuate[bucket].head;
@@ -1200,8 +1200,8 @@ StripeSM::evacuateDocReadDone(int event, Event *e)
     if (dir_compare_tag(&b->dir, &doc->first_key)) {
       doc_evacuator->key = doc->first_key;
       b->evac_frags.key  = doc->first_key;
-      DDbg(dbg_ctl_cache_evac, "evacuating vector %X offset %d", 
(int)doc->first_key.slice32(0),
-           (int)dir_offset(&doc_evacuator->overwrite_dir));
+      DDbg(dbg_ctl_cache_evac, "evacuating vector %X offset %" PRId64, 
doc->first_key.slice32(0),
+           dir_offset(&doc_evacuator->overwrite_dir));
       b->f.unused = 57;
     } else {
       // if its an earliest fragment (alternate) evacuation, things get
@@ -1213,8 +1213,8 @@ StripeSM::evacuateDocReadDone(int event, Event *e)
       b->evac_frags.key           = doc->key;
       b->evac_frags.earliest_key  = doc->key;
       b->earliest_evacuator       = doc_evacuator;
-      DDbg(dbg_ctl_cache_evac, "evacuating earliest %X %X evac: %p offset: 
%d", (int)b->evac_frags.key.slice32(0),
-           (int)doc->key.slice32(0), doc_evacuator, 
(int)dir_offset(&doc_evacuator->overwrite_dir));
+      DDbg(dbg_ctl_cache_evac, "evacuating earliest %X %X evac: %p offset: %" 
PRId64, b->evac_frags.key.slice32(0),
+           doc->key.slice32(0), doc_evacuator, 
dir_offset(&doc_evacuator->overwrite_dir));
       b->f.unused = 67;
     }
   } else {
@@ -1229,7 +1229,7 @@ StripeSM::evacuateDocReadDone(int event, Event *e)
     }
     doc_evacuator->key          = ek->key;
     doc_evacuator->earliest_key = ek->earliest_key;
-    DDbg(dbg_ctl_cache_evac, "evacuateDocReadDone key: %X earliest: %X", 
(int)ek->key.slice32(0), (int)ek->earliest_key.slice32(0));
+    DDbg(dbg_ctl_cache_evac, "evacuateDocReadDone key: %X earliest: %X", 
ek->key.slice32(0), ek->earliest_key.slice32(0));
     b->f.unused = 87;
   }
   // if the tag in the c->dir does match the first_key in the
@@ -1279,8 +1279,8 @@ evacuate_fragments(CacheKey *key, CacheKey *earliest_key, 
int force, StripeSM *s
     if (force) {
       b->readers = 0;
     }
-    DDbg(dbg_ctl_cache_evac, "next fragment %X Earliest: %X offset %d phase %d 
force %d", (int)key->slice32(0),
-         (int)earliest_key->slice32(0), (int)dir_offset(&dir), 
(int)dir_phase(&dir), force);
+    DDbg(dbg_ctl_cache_evac, "next fragment %X Earliest: %X offset %" PRId64 " 
phase %d force %d", key->slice32(0),
+         earliest_key->slice32(0), dir_offset(&dir), dir_phase(&dir), force);
   }
   return i;
 }
@@ -1295,7 +1295,7 @@ StripeSM::evacuateWrite(CacheEvacuateDocVC *evacuator, 
int event, Event *e)
   /* insert the evacuator after all the other evacuators */
   CacheVC *cur   = static_cast<CacheVC 
*>(this->_write_buffer.get_pending_writers().head);
   CacheVC *after = nullptr;
-  for (; cur && cur->f.evacuator; cur = (CacheVC *)cur->link.next) {
+  for (; cur && cur->f.evacuator; cur = static_cast<CacheVC 
*>(cur->link.next)) {
     after = cur;
   }
   ink_assert(evacuator->agg_len <= AGG_SIZE);
diff --git a/src/iocore/cache/unit_tests/test_CacheDir.cc 
b/src/iocore/cache/unit_tests/test_CacheDir.cc
index 1524f87ad7..98baabaa96 100644
--- a/src/iocore/cache/unit_tests/test_CacheDir.cc
+++ b/src/iocore/cache/unit_tests/test_CacheDir.cc
@@ -45,9 +45,9 @@ regress_rand_init(unsigned int i)
 }
 
 static void
-regress_rand_CacheKey(const CacheKey *key)
+regress_rand_CacheKey(CacheKey *key)
 {
-  unsigned int *x = (unsigned int *)key;
+  unsigned int *x = reinterpret_cast<unsigned int *>(key);
   for (int i = 0; i < 4; i++) {
     x[i] = next_rand(&regress_rand_seed);
   }
diff --git a/src/iocore/cache/unit_tests/test_CacheVol.cc 
b/src/iocore/cache/unit_tests/test_CacheVol.cc
index fb35ef4aba..c0f6203d7d 100644
--- a/src/iocore/cache/unit_tests/test_CacheVol.cc
+++ b/src/iocore/cache/unit_tests/test_CacheVol.cc
@@ -188,7 +188,7 @@ create_config(int num)
       CacheType scheme = (random_size % 2) ? CACHE_HTTP_TYPE : CACHE_RTSP_TYPE;
       random_size      = ROUND_TO_VOL_SIZE(random_size);
       off_t blocks     = random_size / STORE_BLOCK_SIZE;
-      ink_assert(blocks <= (int)total_space);
+      ink_assert(blocks <= total_space);
       total_space -= blocks;
 
       ConfigVol *cp = new ConfigVol();

Reply via email to