Skip to content

Commit

Permalink
Fix some more compiler warnings
Browse files Browse the repository at this point in the history
Change-Id: I942ece689faf641ca9988984f283e6660d9d896a
  • Loading branch information
wesm committed Sep 30, 2017
1 parent cae05fb commit 1bec4a7
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 35 deletions.
7 changes: 3 additions & 4 deletions cpp/cmake_modules/SetupCxxFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,16 @@ if ("${UPPERCASE_BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN")
elseif ("${COMPILER_FAMILY}" STREQUAL "clang")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Weverything -Wno-c++98-compat \
-Wno-c++98-compat-pedantic -Wno-deprecated -Wno-weak-vtables -Wno-padded \
-Wno-missing-field-initializers \
-Wno-unused-parameter -Wno-undef \
-Wno-shadow -Wno-switch-enum -Wno-exit-time-destructors \
-Wno-global-constructors -Wno-weak-template-vtables -Wno-undefined-reinterpret-cast \
-Wno-implicit-fallthrough -Wno-old-style-cast -Wno-unreachable-code-return \
-Wno-implicit-fallthrough -Wno-unreachable-code-return \
-Wno-float-equal -Wno-missing-prototypes \
-Wno-covered-switch-default \
-Wno-old-style-cast -Wno-covered-switch-default \
-Wno-cast-align -Wno-vla-extension -Wno-shift-sign-overflow \
-Wno-used-but-marked-unused -Wno-missing-variable-declarations \
-Wno-gnu-zero-variadic-macro-arguments -Wconversion -Wno-sign-conversion \
-Wno-disabled-macro-expansion -Wc++11-narrowing -Wnarrowing -Wno-shorten-64-to-32")
-Wno-disabled-macro-expansion -Wno-shorten-64-to-32")

# Version numbers where warnings are introduced
if ("${COMPILER_VERSION}" VERSION_GREATER "3.3")
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Status AllocateBuffer(MemoryPool* pool, const int64_t size,
return Status::OK();
}

#ifndef ARROW_NO_DEPRECATED_API

Status AllocateBuffer(MemoryPool* pool, const int64_t size,
std::shared_ptr<MutableBuffer>* out) {
std::shared_ptr<Buffer> buffer;
Expand All @@ -140,6 +142,8 @@ Status AllocateBuffer(MemoryPool* pool, const int64_t size,
return Status::OK();
}

#endif

Status AllocateResizableBuffer(MemoryPool* pool, const int64_t size,
std::shared_ptr<ResizableBuffer>* out) {
auto buffer = std::make_shared<PoolBuffer>(pool);
Expand Down
13 changes: 9 additions & 4 deletions cpp/src/arrow/python/util/datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ static inline Status PyTime_from_int(int64_t val, const TimeUnit::type unit,
}

static inline int64_t PyDate_to_ms(PyDateTime_Date* pydate) {
struct tm date = {0};
struct tm date;
memset(&date, 0, sizeof(struct tm));
date.tm_year = PyDateTime_GET_YEAR(pydate) - 1900;
date.tm_mon = PyDateTime_GET_MONTH(pydate) - 1;
date.tm_mday = PyDateTime_GET_DAY(pydate);
struct tm epoch = {0};
struct tm epoch;
memset(&epoch, 0, sizeof(struct tm));

epoch.tm_year = 70;
epoch.tm_mday = 1;
#ifdef _MSC_VER
Expand All @@ -88,15 +91,17 @@ static inline int64_t PyDate_to_ms(PyDateTime_Date* pydate) {
}

static inline int64_t PyDateTime_to_us(PyDateTime_DateTime* pydatetime) {
struct tm datetime = {0};
struct tm datetime;
memset(&datetime, 0, sizeof(struct tm));
datetime.tm_year = PyDateTime_GET_YEAR(pydatetime) - 1900;
datetime.tm_mon = PyDateTime_GET_MONTH(pydatetime) - 1;
datetime.tm_mday = PyDateTime_GET_DAY(pydatetime);
datetime.tm_hour = PyDateTime_DATE_GET_HOUR(pydatetime);
datetime.tm_min = PyDateTime_DATE_GET_MINUTE(pydatetime);
datetime.tm_sec = PyDateTime_DATE_GET_SECOND(pydatetime);
int us = PyDateTime_DATE_GET_MICROSECOND(pydatetime);
struct tm epoch = {0};
struct tm epoch;
memset(&epoch, 0, sizeof(struct tm));
epoch.tm_year = 70;
epoch.tm_mday = 1;
#ifdef _MSC_VER
Expand Down
7 changes: 0 additions & 7 deletions cpp/src/arrow/table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ Status Column::ValidateData() {
// ----------------------------------------------------------------------
// RecordBatch methods

void AssertBatchValid(const RecordBatch& batch) {
Status s = batch.Validate();
if (!s.ok()) {
DCHECK(false) << s.ToString();
}
}

RecordBatch::RecordBatch(const std::shared_ptr<Schema>& schema, int64_t num_rows)
: schema_(schema), num_rows_(num_rows) {
boxed_columns_.resize(schema->num_fields());
Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/util/cpu-info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static struct {
};
static const int64_t num_flags = sizeof(flag_mappings) / sizeof(flag_mappings[0]);

namespace {

// Helper function to parse for hardware flags.
// values contains a list of space-seperated flags. check to see if the flags we
// care about are present.
Expand All @@ -90,6 +92,8 @@ int64_t ParseCPUFlags(const string& values) {
return flags;
}

} // namespace

#ifdef _WIN32
bool RetrieveCacheSize(int64_t* cache_sizes) {
if (!cache_sizes) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/util/hash-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class HashUtil {
static uint32_t FnvHash64to32(const void* data, int32_t bytes, uint32_t hash) {
// IMPALA-2270: this function should never be used for zero-byte inputs.
DCHECK_GT(bytes, 0);
uint64_t hash_u64 = hash | ((uint64_t)hash << 32);
uint64_t hash_u64 = hash | (static_cast<uint64_t>(hash) << 32);
hash_u64 = FnvHash64(data, bytes, hash_u64);
return static_cast<uint32_t>((hash_u64 >> 32) ^ (hash_u64 & 0xFFFFFFFF));
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/plasma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ if ("${COMPILER_FAMILY}" STREQUAL "clang")
PROPERTY COMPILE_FLAGS
" -Wno-parentheses-equality \
-Wno-shorten-64-to-32 \
-Wno-unused-macros")
-Wno-unused-macros ")

set_property(SOURCE thirdparty/xxhash.cc
APPEND_STRING
Expand Down
11 changes: 7 additions & 4 deletions cpp/src/plasma/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,20 +400,23 @@ static inline bool compute_object_hash_parallel(XXH64_state_t* hash_state,
}
}

XXH64_update(hash_state, (unsigned char*)threadhash, sizeof(threadhash));
XXH64_update(hash_state, reinterpret_cast<unsigned char*>(threadhash),
sizeof(threadhash));
return true;
}

static uint64_t compute_object_hash(const ObjectBuffer& obj_buffer) {
XXH64_state_t hash_state;
XXH64_reset(&hash_state, XXH64_DEFAULT_SEED);
if (obj_buffer.data_size >= kBytesInMB) {
compute_object_hash_parallel(&hash_state, (unsigned char*)obj_buffer.data,
compute_object_hash_parallel(&hash_state,
reinterpret_cast<unsigned char*>(obj_buffer.data),
obj_buffer.data_size);
} else {
XXH64_update(&hash_state, (unsigned char*)obj_buffer.data, obj_buffer.data_size);
XXH64_update(&hash_state, reinterpret_cast<unsigned char*>(obj_buffer.data),
obj_buffer.data_size);
}
XXH64_update(&hash_state, (unsigned char*)obj_buffer.metadata,
XXH64_update(&hash_state, reinterpret_cast<unsigned char*>(obj_buffer.metadata),
obj_buffer.metadata_size);
return XXH64_digest(&hash_state);
}
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/plasma/fling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ int recv_fd(int conn) {
for (struct cmsghdr* header = CMSG_FIRSTHDR(&msg); header != NULL;
header = CMSG_NXTHDR(&msg, header))
if (header->cmsg_level == SOL_SOCKET && header->cmsg_type == SCM_RIGHTS) {
ssize_t count =
(header->cmsg_len - (CMSG_DATA(header) - (unsigned char*)header)) / sizeof(int);
ssize_t count = (header->cmsg_len -
(CMSG_DATA(header) - reinterpret_cast<unsigned char*>(header))) /
sizeof(int);
for (int i = 0; i < count; ++i) {
int fd = (reinterpret_cast<int*>(CMSG_DATA(header)))[i];
if (found_fd == -1) {
Expand Down
7 changes: 4 additions & 3 deletions cpp/src/plasma/io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ int bind_ipc_sock(const std::string& pathname, bool shall_listen) {
}
strncpy(socket_address.sun_path, pathname.c_str(), pathname.size() + 1);

if (bind(socket_fd, (struct sockaddr*)&socket_address, sizeof(socket_address)) != 0) {
if (bind(socket_fd, reinterpret_cast<struct sockaddr*>(&socket_address),
sizeof(socket_address)) != 0) {
ARROW_LOG(ERROR) << "Bind failed for pathname " << pathname;
close(socket_fd);
return -1;
Expand Down Expand Up @@ -193,8 +194,8 @@ int connect_ipc_sock(const std::string& pathname) {
}
strncpy(socket_address.sun_path, pathname.c_str(), pathname.size() + 1);

if (connect(socket_fd, (struct sockaddr*)&socket_address, sizeof(socket_address)) !=
0) {
if (connect(socket_fd, reinterpret_cast<struct sockaddr*>(&socket_address),
sizeof(socket_address)) != 0) {
close(socket_fd);
return -1;
}
Expand Down
15 changes: 8 additions & 7 deletions cpp/src/plasma/protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ Status SendCreateReply(int sock, ObjectID object_id, PlasmaObject* object,
PlasmaObjectSpec plasma_object(object->handle.store_fd, object->handle.mmap_size,
object->data_offset, object->data_size,
object->metadata_offset, object->metadata_size);
auto message = CreatePlasmaCreateReply(fbb, fbb.CreateString(object_id.binary()),
&plasma_object, (PlasmaError)error_code);
auto message =
CreatePlasmaCreateReply(fbb, fbb.CreateString(object_id.binary()), &plasma_object,
static_cast<PlasmaError>(error_code));
return PlasmaSend(sock, MessageType_PlasmaCreateReply, &fbb, message);
}

Expand Down Expand Up @@ -123,7 +124,7 @@ Status ReadSealRequest(uint8_t* data, size_t size, ObjectID* object_id,
Status SendSealReply(int sock, ObjectID object_id, int error) {
flatbuffers::FlatBufferBuilder fbb;
auto message = CreatePlasmaSealReply(fbb, fbb.CreateString(object_id.binary()),
(PlasmaError)error);
static_cast<PlasmaError>(error));
return PlasmaSend(sock, MessageType_PlasmaSealReply, &fbb, message);
}

Expand Down Expand Up @@ -154,7 +155,7 @@ Status ReadReleaseRequest(uint8_t* data, size_t size, ObjectID* object_id) {
Status SendReleaseReply(int sock, ObjectID object_id, int error) {
flatbuffers::FlatBufferBuilder fbb;
auto message = CreatePlasmaReleaseReply(fbb, fbb.CreateString(object_id.binary()),
(PlasmaError)error);
static_cast<PlasmaError>(error));
return PlasmaSend(sock, MessageType_PlasmaReleaseReply, &fbb, message);
}

Expand Down Expand Up @@ -185,7 +186,7 @@ Status ReadDeleteRequest(uint8_t* data, size_t size, ObjectID* object_id) {
Status SendDeleteReply(int sock, ObjectID object_id, int error) {
flatbuffers::FlatBufferBuilder fbb;
auto message = CreatePlasmaDeleteReply(fbb, fbb.CreateString(object_id.binary()),
(PlasmaError)error);
static_cast<PlasmaError>(error));
return PlasmaSend(sock, MessageType_PlasmaDeleteReply, &fbb, message);
}

Expand Down Expand Up @@ -526,8 +527,8 @@ Status ReadDataReply(uint8_t* data, size_t size, ObjectID* object_id,
auto message = flatbuffers::GetRoot<PlasmaDataReply>(data);
DCHECK(verify_flatbuffer(message, data, size));
*object_id = ObjectID::from_binary(message->object_id()->str());
*object_size = (int64_t)message->object_size();
*metadata_size = (int64_t)message->metadata_size();
*object_size = static_cast<int64_t>(message->object_size());
*metadata_size = static_cast<int64_t>(message->metadata_size());
return Status::OK();
}

Expand Down
6 changes: 4 additions & 2 deletions cpp/src/plasma/thirdparty/ae/ae_epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ static void aeApiFree(aeEventLoop *eventLoop) {

static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
aeApiState *state = eventLoop->apidata;
struct epoll_event ee = {0}; /* avoid valgrind warning */
struct epoll_event ee;
memset(&ee, 0, sizeof(struct epoll_event)); // avoid valgrind warning
/* If the fd was already monitored for some event, we need a MOD
* operation. Otherwise we need an ADD operation. */
int op = eventLoop->events[fd].mask == AE_NONE ?
Expand All @@ -89,7 +90,8 @@ static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {

static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int delmask) {
aeApiState *state = eventLoop->apidata;
struct epoll_event ee = {0}; /* avoid valgrind warning */
struct epoll_event ee;
memset(&ee, 0, sizeof(struct epoll_event)); // avoid valgrind warning
int mask = eventLoop->events[fd].mask & (~delmask);

ee.events = 0;
Expand Down

0 comments on commit 1bec4a7

Please sign in to comment.