You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by pc...@apache.org on 2019/02/02 00:12:29 UTC

[arrow] branch master updated: ARROW-4455: [Plasma] Suppress class-memaccess warnings

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

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


The following commit(s) were added to refs/heads/master by this push:
     new f08e109  ARROW-4455: [Plasma] Suppress class-memaccess warnings
f08e109 is described below

commit f08e109ff009e911bb772e5b0490c7cacf02140e
Author: Kouhei Sutou <ko...@clear-code.com>
AuthorDate: Fri Feb 1 16:12:12 2019 -0800

    ARROW-4455: [Plasma] Suppress class-memaccess warnings
    
        cpp/src/plasma/store.cc: In member function 'arrow::Status plasma::PlasmaStore::ProcessMessage(plasma::Client*)':
        cpp/src/plasma/store.cc:767:36: error: 'void* memset(void*, int, size_t)' clearing an object of type 'struct plasma::PlasmaObject' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess]
           memset(&object, 0, sizeof(object));
                                            ^
        In file included from cpp/src/plasma/eviction_policy.h:27,
                         from cpp/src/plasma/store.h:30,
                         from cpp/src/plasma/store.cc:29:
        cpp/src/plasma/plasma.h:75:8: note: 'struct plasma::PlasmaObject' declared here
         struct PlasmaObject {
                ^~~~~~~~~~~~
        cpp/src/plasma/test/serialization_tests.cc: In function 'plasma::PlasmaObject plasma::random_plasma_object()':
        cpp/src/plasma/test/serialization_tests.cc:68:36: error: 'void* memset(void*, int, size_t)' clearing an object of type 'struct plasma::PlasmaObject' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess]
           memset(&object, 0, sizeof(object));
                                            ^
        In file included from cpp/src/plasma/test/serialization_tests.cc:25:
        cpp/src/plasma/plasma.h:75:8: note: 'struct plasma::PlasmaObject' declared here
         struct PlasmaObject {
                ^~~~~~~~~~~~
        cpp/src/plasma/test/serialization_tests.cc: In member function 'virtual void plasma::PlasmaSerialization_CreateReply_Test::TestBody()':
        cpp/src/plasma/test/serialization_tests.cc:110:38: error: 'void* memset(void*, int, size_t)' clearing an object of type 'struct plasma::PlasmaObject' with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess]
           memset(&object2, 0, sizeof(object2));
                                              ^
        In file included from cpp/src/plasma/test/serialization_tests.cc:25:
        cpp/src/plasma/plasma.h:75:8: note: 'struct plasma::PlasmaObject' declared here
         struct PlasmaObject {
                ^~~~~~~~~~~~
    
    Author: Kouhei Sutou <ko...@clear-code.com>
    
    Closes #3543 from kou/plasma-suppress-class-memaccess-warning and squashes the following commits:
    
    34ce66c0c <Kouhei Sutou>  Suppress class-memaccess warnings
---
 cpp/src/plasma/store.cc                    | 4 +---
 cpp/src/plasma/test/serialization_tests.cc | 6 ++----
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/cpp/src/plasma/store.cc b/cpp/src/plasma/store.cc
index f84e890..745e336 100644
--- a/cpp/src/plasma/store.cc
+++ b/cpp/src/plasma/store.cc
@@ -762,9 +762,7 @@ Status PlasmaStore::ProcessMessage(Client* client) {
   uint8_t* input = input_buffer_.data();
   size_t input_size = input_buffer_.size();
   ObjectID object_id;
-  PlasmaObject object;
-  // TODO(pcm): Get rid of the following.
-  memset(&object, 0, sizeof(object));
+  PlasmaObject object = {};
 
   // Process the different types of requests.
   switch (type) {
diff --git a/cpp/src/plasma/test/serialization_tests.cc b/cpp/src/plasma/test/serialization_tests.cc
index 66d651d..4fb3f9a 100644
--- a/cpp/src/plasma/test/serialization_tests.cc
+++ b/cpp/src/plasma/test/serialization_tests.cc
@@ -64,8 +64,7 @@ std::vector<uint8_t> read_message_from_file(int fd, MessageType message_type) {
 PlasmaObject random_plasma_object(void) {
   unsigned int seed = static_cast<unsigned int>(time(NULL));
   int random = rand_r(&seed);
-  PlasmaObject object;
-  memset(&object, 0, sizeof(object));
+  PlasmaObject object = {};
   object.store_fd = random + 7;
   object.data_offset = random + 1;
   object.metadata_offset = random + 2;
@@ -106,8 +105,7 @@ TEST(PlasmaSerialization, CreateReply) {
   ARROW_CHECK_OK(SendCreateReply(fd, object_id1, &object1, PlasmaError::OK, mmap_size1));
   std::vector<uint8_t> data = read_message_from_file(fd, MessageType::PlasmaCreateReply);
   ObjectID object_id2;
-  PlasmaObject object2;
-  memset(&object2, 0, sizeof(object2));
+  PlasmaObject object2 = {};
   int store_fd;
   int64_t mmap_size2;
   ARROW_CHECK_OK(ReadCreateReply(data.data(), data.size(), &object_id2, &object2,