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

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

commit c6765fd08b67509cdab6815debb969b67b7d523f
Author: Masakazu Kitajo <[email protected]>
AuthorDate: Thu Apr 12 16:45:10 2018 +0900

    Explicitly cast to void * when initializing a memory with a pointer for a 
class object
    
    (cherry picked from commit 9b0c94684a2e8e5ccfad51ac1fe8f711ceec808f)
    
     Conflicts:
        cmd/traffic_cache_tool/CacheTool.cc
        iocore/cache/Cache.cc
        lib/ts/Map.h
---
 iocore/cache/Cache.cc         |  6 +++---
 iocore/cache/CacheDir.cc      |  4 ++--
 iocore/cache/CacheHosting.cc  |  6 +++---
 iocore/cache/CacheWrite.cc    |  2 +-
 iocore/cache/RamCacheCLFUS.cc |  2 +-
 iocore/cache/RamCacheLRU.cc   |  2 +-
 iocore/net/I_NetVConnection.h |  2 +-
 lib/ts/Vec.h                  | 16 ++++++++--------
 lib/ts/ink_memory.h           |  2 +-
 tools/jtest/jtest.cc          |  2 +-
 10 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 6a85b42..2640546 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -1372,7 +1372,7 @@ Vol::init(char *s, off_t blocks, off_t dir_skip, bool 
clear)
   evacuate_size = (int)(len / EVACUATION_BUCKET_SIZE) + 2;
   int evac_len  = (int)evacuate_size * sizeof(DLL<EvacuationBlock>);
   evacuate      = (DLL<EvacuationBlock> *)ats_malloc(evac_len);
-  memset(evacuate, 0, evac_len);
+  memset(static_cast<void *>(evacuate), 0, evac_len);
 
   Debug("cache_init", "allocating %zu directory bytes for a %lld byte volume 
(%lf%%)", vol_dirlen(this), (long long)this->len,
         (double)vol_dirlen(this) / (double)this->len * 100.0);
@@ -3444,7 +3444,7 @@ HTTPInfo_v21::copy_and_upgrade_unmarshalled_to_v23(char 
*&dst, char *&src, size_
   hdr_size = ROUND(s_hdr->unmarshal_size(), HDR_PTR_SIZE);
   if (hdr_size > length)
     return false;
-  memcpy(d_hdr, s_hdr, hdr_size);
+  memcpy(static_cast<void *>(d_hdr), s_hdr, hdr_size);
   d_alt->m_request_hdr.m_heap = reinterpret_cast<HdrHeap_v23 
*>(reinterpret_cast<char *>(d_hdr) - reinterpret_cast<char *>(d_alt));
   dst += hdr_size;
   length -= hdr_size;
@@ -3455,7 +3455,7 @@ HTTPInfo_v21::copy_and_upgrade_unmarshalled_to_v23(char 
*&dst, char *&src, size_
   hdr_size = ROUND(s_hdr->unmarshal_size(), HDR_PTR_SIZE);
   if (hdr_size > length)
     return false;
-  memcpy(d_hdr, s_hdr, hdr_size);
+  memcpy(static_cast<void *>(d_hdr), s_hdr, hdr_size);
   d_alt->m_response_hdr.m_heap = reinterpret_cast<HdrHeap_v23 
*>(reinterpret_cast<char *>(d_hdr) - reinterpret_cast<char *>(d_alt));
   dst += hdr_size;
   length -= hdr_size;
diff --git a/iocore/cache/CacheDir.cc b/iocore/cache/CacheDir.cc
index 7e058fd..6c471e2 100644
--- a/iocore/cache/CacheDir.cc
+++ b/iocore/cache/CacheDir.cc
@@ -208,7 +208,7 @@ dir_init_segment(int s, Vol *d)
   d->header->freelist[s] = 0;
   Dir *seg               = dir_segment(s, d);
   int l, b;
-  memset(seg, 0, SIZEOF_DIR * DIR_DEPTH * d->buckets);
+  memset(static_cast<void *>(seg), 0, SIZEOF_DIR * DIR_DEPTH * d->buckets);
   for (l = 1; l < DIR_DEPTH; l++) {
     for (b = 0; b < d->buckets; b++) {
       Dir *bucket = dir_bucket(b, seg);
@@ -1447,7 +1447,7 @@ EXCLUSIVE_REGRESSION_TEST(Cache_dir)(RegressionTest *t, 
int /* atype ATS_UNUSED
   }
 
   Dir dir1;
-  memset(&dir1, 0, sizeof(dir1));
+  memset(static_cast<void *>(&dir1), 0, sizeof(dir1));
   int s1, b1;
 
   rprintf(t, "corrupt_bucket test\n");
diff --git a/iocore/cache/CacheHosting.cc b/iocore/cache/CacheHosting.cc
index b18b287..b44cb8f 100644
--- a/iocore/cache/CacheHosting.cc
+++ b/iocore/cache/CacheHosting.cc
@@ -164,7 +164,7 @@ CacheHostMatcher::NewEntry(matcher_line *line_info)
 
   if (errNo) {
     // There was a problem so undo the effects this function
-    memset(cur_d, 0, sizeof(CacheHostRecord));
+    memset(static_cast<void *>(cur_d), 0, sizeof(CacheHostRecord));
     return;
   }
   Debug("cache_hosting", "hostname: %s, host record: %p", match_data, cur_d);
@@ -1076,8 +1076,8 @@ save_state()
   saved_cp_list_len = cp_list_len;
   memcpy(&saved_config_volumes, &config_volumes, sizeof(ConfigVolumes));
   saved_gnvol = gnvol;
-  memset(&cp_list, 0, sizeof(Queue<CacheVol>));
-  memset(&config_volumes, 0, sizeof(ConfigVolumes));
+  memset(static_cast<void *>(&cp_list), 0, sizeof(Queue<CacheVol>));
+  memset(static_cast<void *>(&config_volumes), 0, sizeof(ConfigVolumes));
   gnvol = 0;
 }
 
diff --git a/iocore/cache/CacheWrite.cc b/iocore/cache/CacheWrite.cc
index a9c5a26..78f9786 100644
--- a/iocore/cache/CacheWrite.cc
+++ b/iocore/cache/CacheWrite.cc
@@ -1018,7 +1018,7 @@ Lagain:
     int l       = round_to_approx_size(sizeof(Doc));
     agg_buf_pos = l;
     Doc *d      = (Doc *)agg_buffer;
-    memset(d, 0, sizeof(Doc));
+    memset(static_cast<void *>(d), 0, sizeof(Doc));
     d->magic        = DOC_MAGIC;
     d->len          = l;
     d->sync_serial  = header->sync_serial;
diff --git a/iocore/cache/RamCacheCLFUS.cc b/iocore/cache/RamCacheCLFUS.cc
index eb6d6d5..19bfdab 100644
--- a/iocore/cache/RamCacheCLFUS.cc
+++ b/iocore/cache/RamCacheCLFUS.cc
@@ -182,7 +182,7 @@ RamCacheCLFUS::resize_hashtable()
   DDebug("ram_cache", "resize hashtable %d", anbuckets);
   int64_t s = anbuckets * sizeof(DList(RamCacheCLFUSEntry, hash_link));
   DList(RamCacheCLFUSEntry, hash_link) *new_bucket = 
(DList(RamCacheCLFUSEntry, hash_link) *)ats_malloc(s);
-  memset(new_bucket, 0, s);
+  memset(static_cast<void *>(new_bucket), 0, s);
   if (bucket) {
     for (int64_t i = 0; i < nbuckets; i++) {
       RamCacheCLFUSEntry *e = nullptr;
diff --git a/iocore/cache/RamCacheLRU.cc b/iocore/cache/RamCacheLRU.cc
index 31c3d8e..6f744c7 100644
--- a/iocore/cache/RamCacheLRU.cc
+++ b/iocore/cache/RamCacheLRU.cc
@@ -87,7 +87,7 @@ RamCacheLRU::resize_hashtable()
   DDebug("ram_cache", "resize hashtable %d", anbuckets);
   int64_t s = anbuckets * sizeof(DList(RamCacheLRUEntry, hash_link));
   DList(RamCacheLRUEntry, hash_link) *new_bucket = (DList(RamCacheLRUEntry, 
hash_link) *)ats_malloc(s);
-  memset(new_bucket, 0, s);
+  memset(static_cast<void *>(new_bucket), 0, s);
   if (bucket) {
     for (int64_t i = 0; i < nbuckets; i++) {
       RamCacheLRUEntry *e = nullptr;
diff --git a/iocore/net/I_NetVConnection.h b/iocore/net/I_NetVConnection.h
index 4821ffc..92d82e6 100644
--- a/iocore/net/I_NetVConnection.h
+++ b/iocore/net/I_NetVConnection.h
@@ -222,7 +222,7 @@ struct NetVCOptions {
     if (&that != this) {
       sni_servername    = nullptr; // release any current name.
       clientCertificate = nullptr;
-      memcpy(this, &that, sizeof(self));
+      memcpy(static_cast<void *>(this), &that, sizeof(self));
       if (that.sni_servername) {
         sni_servername.release(); // otherwise we'll free the source string.
         this->sni_servername = ats_strdup(that.sni_servername);
diff --git a/lib/ts/Vec.h b/lib/ts/Vec.h
index 00da28f..08257c3 100644
--- a/lib/ts/Vec.h
+++ b/lib/ts/Vec.h
@@ -233,7 +233,7 @@ extern const uintptr_t open_hash_primes[256];
 
 template <class C, class A, int S> inline Vec<C, A, S>::Vec() : n(0), i(0), 
v(0)
 {
-  memset(&e[0], 0, sizeof(e));
+  memset(static_cast<void *>(&e[0]), 0, sizeof(e));
 }
 
 template <class C, class A, int S> inline Vec<C, A, S>::Vec(const Vec<C, A, S> 
&vv)
@@ -763,8 +763,8 @@ Vec<C, A, S>::copy_internal(const Vec<C, A, S> &vv)
   }
   nl = 1 << nl;
   v  = (C *)A::alloc(nl * sizeof(C));
-  memcpy(v, vv.v, n * sizeof(C));
-  memset(v + n, 0, (nl - n) * sizeof(C));
+  memcpy(static_cast<void *>(v), vv.v, n * sizeof(C));
+  memset(static_cast<void *>(v + n), 0, (nl - n) * sizeof(C));
   if (i > n) // reset reserve
     i = 0;
 }
@@ -779,7 +779,7 @@ Vec<C, A, S>::set_expand()
     i = i + 1;
   n   = prime2[i];
   v   = (C *)A::alloc(n * sizeof(C));
-  memset(v, 0, n * sizeof(C));
+  memset(static_cast<void *>(v), 0, n * sizeof(C));
 }
 
 template <class C, class A, int S>
@@ -811,9 +811,9 @@ Vec<C, A, S>::addx()
   }
   if (v == e) {
     v = (C *)A::alloc(VEC_INITIAL_SIZE * sizeof(C));
-    memcpy(v, &e[0], n * sizeof(C));
+    memcpy(static_cast<void *>(v), &e[0], n * sizeof(C));
     ink_assert(n < VEC_INITIAL_SIZE);
-    memset(&v[n], 0, (VEC_INITIAL_SIZE - n) * sizeof(C));
+    memset(static_cast<void *>(&v[n]), 0, (VEC_INITIAL_SIZE - n) * sizeof(C));
   } else {
     if ((n & (n - 1)) == 0) {
       size_t nl = n * 2;
@@ -824,8 +824,8 @@ Vec<C, A, S>::addx()
       }
       void *vv = (void *)v;
       v        = (C *)A::alloc(nl * sizeof(C));
-      memcpy(v, vv, n * sizeof(C));
-      memset(&v[n], 0, n * sizeof(C));
+      memcpy(static_cast<void *>(v), vv, n * sizeof(C));
+      memset(static_cast<void *>(&v[n]), 0, n * sizeof(C));
       A::free(vv);
     }
   }
diff --git a/lib/ts/ink_memory.h b/lib/ts/ink_memory.h
index 0c2e117..45edd4f 100644
--- a/lib/ts/ink_memory.h
+++ b/lib/ts/ink_memory.h
@@ -184,7 +184,7 @@ template <typename T>
 inline void
 ink_zero(T &t)
 {
-  memset(&t, 0, sizeof(t));
+  memset(static_cast<void *>(&t), 0, sizeof(t));
 }
 
 /** Scoped resources.
diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index d9e57d3..718663d 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -3230,7 +3230,7 @@ main(int argc __attribute__((unused)), const char *argv[])
   setvbuf(stdout, (char *)NULL, _IOLBF, 0);
 
   fd = (FD *)malloc(MAXFDS * sizeof(FD));
-  memset(fd, 0, MAXFDS * sizeof(FD));
+  memset(static_cast<void *>(fd), 0, MAXFDS * sizeof(FD));
   process_args(&appVersionInfo, argument_descriptions, 
n_argument_descriptions, argv);
 
   if (!drand_seed) {

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to