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 2019/07/13 17:02:16 UTC

[arrow] 21/43: ARROW-5849: [C++] Fix compiler warnings on mingw32

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

wesm pushed a commit to branch maint-0.14.x
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit a0f0f3712897f78e58351f3d217ebc3ffe49f2de
Author: Antoine Pitrou <an...@python.org>
AuthorDate: Fri Jul 5 09:02:01 2019 -0400

    ARROW-5849: [C++] Fix compiler warnings on mingw32
    
    Author: Antoine Pitrou <an...@python.org>
    
    Closes #4804 from pitrou/ARROW-5849-mingw-warnings and squashes the following commits:
    
    ff48a18f0 <Antoine Pitrou> ARROW-5849:  Fix compiler warnings on mingw32
---
 cpp/src/arrow/array-test.cc                |  3 +--
 cpp/src/arrow/compute/kernels/cast-test.cc |  2 +-
 cpp/src/arrow/io/mman.h                    | 25 ++++++++-----------------
 cpp/src/arrow/util/decimal.cc              |  2 +-
 cpp/src/arrow/util/io-util.cc              |  7 ++++---
 5 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/cpp/src/arrow/array-test.cc b/cpp/src/arrow/array-test.cc
index 2005a0d..df8b852 100644
--- a/cpp/src/arrow/array-test.cc
+++ b/cpp/src/arrow/array-test.cc
@@ -1300,7 +1300,6 @@ TEST_F(TestFWBinaryArray, ZeroSize) {
 
   ASSERT_OK(builder.Append(""));
   ASSERT_OK(builder.Append(std::string()));
-  ASSERT_OK(builder.Append(static_cast<const uint8_t*>(nullptr)));
   ASSERT_OK(builder.AppendNull());
   ASSERT_OK(builder.AppendNull());
   ASSERT_OK(builder.AppendNull());
@@ -1314,7 +1313,7 @@ TEST_F(TestFWBinaryArray, ZeroSize) {
   ASSERT_EQ(fw_array.values()->size(), 0);
   ASSERT_EQ(0, fw_array.byte_width());
 
-  ASSERT_EQ(6, array->length());
+  ASSERT_EQ(5, array->length());
   ASSERT_EQ(3, array->null_count());
 }
 
diff --git a/cpp/src/arrow/compute/kernels/cast-test.cc b/cpp/src/arrow/compute/kernels/cast-test.cc
index 510b9a4..6bf4f94 100644
--- a/cpp/src/arrow/compute/kernels/cast-test.cc
+++ b/cpp/src/arrow/compute/kernels/cast-test.cc
@@ -263,7 +263,7 @@ std::vector<O> UnsafeVectorCast(const std::vector<I>& v) {
 
   for (size_t i = 0; i < v.size(); i++) result[i] = static_cast<O>(v[i]);
 
-  return std::move(result);
+  return result;
 }
 
 TEST_F(TestCast, IntegerSignedToUnsigned) {
diff --git a/cpp/src/arrow/io/mman.h b/cpp/src/arrow/io/mman.h
index 6125492..5826891 100644
--- a/cpp/src/arrow/io/mman.h
+++ b/cpp/src/arrow/io/mman.h
@@ -14,6 +14,8 @@
 #include <io.h>
 #include <sys/types.h>
 
+#include <cstdint>
+
 #define PROT_NONE 0
 #define PROT_READ 1
 #define PROT_WRITE 2
@@ -75,28 +77,17 @@ static inline void* mmap(void* addr, size_t len, int prot, int flags, int fildes
   HANDLE fm, h;
 
   void* map = MAP_FAILED;
+  const uint64_t off64 = static_cast<uint64_t>(off);
+  const uint64_t maxSize = off64 + len;
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4293)
-#endif
+  const DWORD dwFileOffsetLow = static_cast<DWORD>(off64 & 0xFFFFFFFFUL);
+  const DWORD dwFileOffsetHigh = static_cast<DWORD>((off64 >> 32) & 0xFFFFFFFFUL);
+  const DWORD dwMaxSizeLow = static_cast<DWORD>(maxSize & 0xFFFFFFFFUL);
+  const DWORD dwMaxSizeHigh = static_cast<DWORD>((maxSize >> 32) & 0xFFFFFFFFUL);
 
-  const DWORD dwFileOffsetLow =
-      (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
-  const DWORD dwFileOffsetHigh =
-      (sizeof(off_t) <= sizeof(DWORD)) ? (DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
   const DWORD protect = __map_mmap_prot_page(prot);
   const DWORD desiredAccess = __map_mmap_prot_file(prot);
 
-  const size_t maxSize = off + len;
-
-  const DWORD dwMaxSizeLow = static_cast<DWORD>(maxSize & 0xFFFFFFFFL);
-  const DWORD dwMaxSizeHigh = static_cast<DWORD>((maxSize >> 32) & 0xFFFFFFFFL);
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
   errno = 0;
 
   if (len == 0
diff --git a/cpp/src/arrow/util/decimal.cc b/cpp/src/arrow/util/decimal.cc
index 46928b2..00beffd 100644
--- a/cpp/src/arrow/util/decimal.cc
+++ b/cpp/src/arrow/util/decimal.cc
@@ -214,7 +214,7 @@ namespace {
 struct DecimalComponents {
   util::string_view whole_digits;
   util::string_view fractional_digits;
-  int32_t exponent;
+  int32_t exponent = 0;
   char sign = 0;
   bool has_exponent = false;
 };
diff --git a/cpp/src/arrow/util/io-util.cc b/cpp/src/arrow/util/io-util.cc
index c092769..58072b6 100644
--- a/cpp/src/arrow/util/io-util.cc
+++ b/cpp/src/arrow/util/io-util.cc
@@ -564,8 +564,9 @@ Status MemoryMapRemap(void* addr, size_t old_size, size_t new_size, int fildes,
     return StatusFromErrno("Cannot get file handle: ");
   }
 
-  LONG new_size_low = static_cast<LONG>(new_size & 0xFFFFFFFFL);
-  LONG new_size_high = static_cast<LONG>((new_size >> 32) & 0xFFFFFFFFL);
+  uint64_t new_size64 = new_size;
+  LONG new_size_low = static_cast<LONG>(new_size64 & 0xFFFFFFFFUL);
+  LONG new_size_high = static_cast<LONG>((new_size64 >> 32) & 0xFFFFFFFFUL);
 
   SetFilePointer(h, new_size_low, &new_size_high, FILE_BEGIN);
   SetEndOfFile(h);
@@ -892,7 +893,7 @@ Status TemporaryDir::Make(const std::string& prefix, std::unique_ptr<TemporaryDi
   BOOST_FILESYSTEM_CATCH
 
   PlatformFilename fn(path.native());
-  bool created;
+  bool created = false;
   RETURN_NOT_OK(CreateDir(fn, &created));
   if (!created) {
     // XXX Should we retry?