You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/01/30 16:29:41 UTC

[arrow] branch master updated: ARROW-2054: [C++] Fix compilation warnings

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

wesm 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 673125f  ARROW-2054: [C++] Fix compilation warnings
673125f is described below

commit 673125fd416cbd2e5c2cb9cb6a4c925adecdaf2c
Author: Antoine Pitrou <an...@python.org>
AuthorDate: Tue Jan 30 11:29:37 2018 -0500

    ARROW-2054: [C++] Fix compilation warnings
    
    One of them is a pointer aliasing offense (thus a real bug), the other ones could merely be ignored.
    
    Author: Antoine Pitrou <an...@python.org>
    
    Closes #1533 from pitrou/ARROW-2054-cpp-warnings and squashes the following commits:
    
    2c0d17eb [Antoine Pitrou] ARROW-2054: [C++] Fix compilation warnings
---
 cpp/src/arrow/ipc/json-internal.cc      |  4 ++--
 cpp/src/arrow/python/builtin_convert.cc |  2 ++
 cpp/src/arrow/python/io.cc              | 16 ++++++++++------
 cpp/src/plasma/fling.cc                 |  2 +-
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/cpp/src/arrow/ipc/json-internal.cc b/cpp/src/arrow/ipc/json-internal.cc
index 4088a8f..204bbc4 100644
--- a/cpp/src/arrow/ipc/json-internal.cc
+++ b/cpp/src/arrow/ipc/json-internal.cc
@@ -866,7 +866,7 @@ static Status GetField(const rj::Value& obj, const DictionaryMemo* dictionary_me
   if (dictionary_memo != nullptr && it_dictionary != json_field.MemberEnd()) {
     // Field is dictionary encoded. We must have already
     RETURN_NOT_OBJECT("dictionary", it_dictionary, json_field);
-    int64_t dictionary_id;
+    int64_t dictionary_id = -1;
     bool is_ordered;
     std::shared_ptr<DataType> index_type;
     RETURN_NOT_OK(ParseDictionary(it_dictionary->value.GetObject(), &dictionary_id,
@@ -1346,7 +1346,7 @@ static Status ReadDictionaries(const rj::Value& doc, const DictionaryTypeMap& id
 
   for (const rj::Value& val : dictionary_array) {
     DCHECK(val.IsObject());
-    int64_t dictionary_id;
+    int64_t dictionary_id = -1;
     std::shared_ptr<Array> dictionary;
     RETURN_NOT_OK(
         ReadDictionary(val.GetObject(), id_to_field, pool, &dictionary_id, &dictionary));
diff --git a/cpp/src/arrow/python/builtin_convert.cc b/cpp/src/arrow/python/builtin_convert.cc
index b41c55d..63d3889 100644
--- a/cpp/src/arrow/python/builtin_convert.cc
+++ b/cpp/src/arrow/python/builtin_convert.cc
@@ -582,6 +582,8 @@ class TimestampConverter
         case TimeUnit::NANO:
           t = PyDateTime_to_ns(pydatetime);
           break;
+        default:
+          return Status::UnknownError("Invalid time unit");
       }
     } else if (PyArray_CheckAnyScalarExact(item.obj())) {
       // numpy.datetime64
diff --git a/cpp/src/arrow/python/io.cc b/cpp/src/arrow/python/io.cc
index 9d32ead..2cff046 100644
--- a/cpp/src/arrow/python/io.cc
+++ b/cpp/src/arrow/python/io.cc
@@ -26,6 +26,7 @@
 #include "arrow/io/memory.h"
 #include "arrow/memory_pool.h"
 #include "arrow/status.h"
+#include "arrow/util/logging.h"
 
 #include "arrow/python/common.h"
 
@@ -133,12 +134,14 @@ Status PyReadableFile::Tell(int64_t* position) const {
 
 Status PyReadableFile::Read(int64_t nbytes, int64_t* bytes_read, void* out) {
   PyAcquireGIL lock;
-  PyObject* bytes_obj;
+
+  PyObject* bytes_obj = NULL;
   ARROW_RETURN_NOT_OK(file_->Read(nbytes, &bytes_obj));
+  DCHECK(bytes_obj != NULL);
 
   *bytes_read = PyBytes_GET_SIZE(bytes_obj);
   std::memcpy(out, PyBytes_AS_STRING(bytes_obj), *bytes_read);
-  Py_DECREF(bytes_obj);
+  Py_XDECREF(bytes_obj);
 
   return Status::OK();
 }
@@ -146,11 +149,12 @@ Status PyReadableFile::Read(int64_t nbytes, int64_t* bytes_read, void* out) {
 Status PyReadableFile::Read(int64_t nbytes, std::shared_ptr<Buffer>* out) {
   PyAcquireGIL lock;
 
-  PyObject* bytes_obj;
+  PyObject* bytes_obj = NULL;
   ARROW_RETURN_NOT_OK(file_->Read(nbytes, &bytes_obj));
+  DCHECK(bytes_obj != NULL);
 
   *out = std::make_shared<PyBuffer>(bytes_obj);
-  Py_DECREF(bytes_obj);
+  Py_XDECREF(bytes_obj);
 
   return Status::OK();
 }
@@ -172,13 +176,13 @@ Status PyReadableFile::ReadAt(int64_t position, int64_t nbytes,
 Status PyReadableFile::GetSize(int64_t* size) {
   PyAcquireGIL lock;
 
-  int64_t current_position;
+  int64_t current_position = -1;
 
   ARROW_RETURN_NOT_OK(file_->Tell(&current_position));
 
   ARROW_RETURN_NOT_OK(file_->Seek(0, 2));
 
-  int64_t file_size;
+  int64_t file_size = -1;
   ARROW_RETURN_NOT_OK(file_->Tell(&file_size));
 
   // Restore previous file position
diff --git a/cpp/src/plasma/fling.cc b/cpp/src/plasma/fling.cc
index 819ec16..26afd87 100644
--- a/cpp/src/plasma/fling.cc
+++ b/cpp/src/plasma/fling.cc
@@ -43,7 +43,7 @@ int send_fd(int conn, int fd) {
   header->cmsg_level = SOL_SOCKET;
   header->cmsg_type = SCM_RIGHTS;
   header->cmsg_len = CMSG_LEN(sizeof(int));
-  *reinterpret_cast<int*>(CMSG_DATA(header)) = fd;
+  memcpy(CMSG_DATA(header), reinterpret_cast<void*>(&fd), sizeof(int));
 
   // Send file descriptor.
   ssize_t r = sendmsg(conn, &msg, 0);

-- 
To stop receiving notification emails like this one, please contact
wesm@apache.org.