Skip to content

Commit

Permalink
ARROW-4455: [Plasma] Suppress class-memaccess warnings
Browse files Browse the repository at this point in the history
    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 <[email protected]>

Closes #3543 from kou/plasma-suppress-class-memaccess-warning and squashes the following commits:

34ce66c <Kouhei Sutou>  Suppress class-memaccess warnings
  • Loading branch information
kou authored and pcmoritz committed Feb 2, 2019
1 parent fb11322 commit f08e109
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions cpp/src/plasma/store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions cpp/src/plasma/test/serialization_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f08e109

Please sign in to comment.