JosiahWI commented on code in PR #11733:
URL: https://github.com/apache/trafficserver/pull/11733#discussion_r1732682841


##########
src/iocore/cache/CacheProcessor.cc:
##########
@@ -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 = reinterpret_cast<const rtable_pair *>(aa);
+  const rtable_pair *b = reinterpret_cast<const rtable_pair *>(bb);

Review Comment:
   `static_cast` should be enough because it's casting from a `void *`.



##########
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) - (size_t) & (static_cast<CacheVC 
*>(nullptr))->vio;

Review Comment:
   I agree. Region C extends starts at `vio` and goes all the way to the end of 
the struct, so the difference between the total size and the offset of `vio` is 
the size of the region. But is it safe to use `nullptr` this way? Is that 
dereference not undefined behavior?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to