You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2022/04/28 13:18:06 UTC

[arrow] branch master updated: ARROW-16387: [C++] Add -Wshorten-64-to-32 to list of CHECKIN warnings tested by clang

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

apitrou 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 a713e7fa5d ARROW-16387: [C++] Add -Wshorten-64-to-32 to list of CHECKIN warnings tested by clang
a713e7fa5d is described below

commit a713e7fa5dbd4997cfdac928cf868f38c31ac3d0
Author: Weston Pace <we...@gmail.com>
AuthorDate: Thu Apr 28 15:17:52 2022 +0200

    ARROW-16387: [C++] Add -Wshorten-64-to-32 to list of CHECKIN warnings tested by clang
    
    Closes #13016 from westonpace/feature/ARROW--16387-add-64-to-32-warning-clang
    
    Authored-by: Weston Pace <we...@gmail.com>
    Signed-off-by: Antoine Pitrou <an...@python.org>
---
 cpp/cmake_modules/SetupCxxFlags.cmake             |  1 +
 cpp/src/arrow/adapters/orc/adapter_test.cc        | 10 +++++-----
 cpp/src/arrow/adapters/orc/util.cc                |  5 +++--
 cpp/src/arrow/compute/exec/hash_join_node_test.cc |  5 +++--
 cpp/src/arrow/vendored/musl/strptime.c            |  2 +-
 cpp/src/plasma/client.cc                          |  2 +-
 cpp/src/plasma/protocol.cc                        |  2 +-
 7 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake
index 0111d1f9db..a11f37dd4d 100644
--- a/cpp/cmake_modules/SetupCxxFlags.cmake
+++ b/cpp/cmake_modules/SetupCxxFlags.cmake
@@ -282,6 +282,7 @@ if("${BUILD_WARNING_LEVEL}" STREQUAL "CHECKIN")
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall")
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wextra")
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wdocumentation")
+    set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wshorten-64-to-32")
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-missing-braces")
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-unused-parameter")
     set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-constant-logical-operand")
diff --git a/cpp/src/arrow/adapters/orc/adapter_test.cc b/cpp/src/arrow/adapters/orc/adapter_test.cc
index 6b9aa4740b..6914d6b9c1 100644
--- a/cpp/src/arrow/adapters/orc/adapter_test.cc
+++ b/cpp/src/arrow/adapters/orc/adapter_test.cc
@@ -543,7 +543,7 @@ class TestORCWriterWithConversion : public ::testing::Test {
       EXPECT_OK_AND_ASSIGN(av[i], compute::Cast(*(input_table->column(i)->chunk(0)),
                                                 output_schema->field(i)->type()));
     }
-    for (int i = num_cols - 2; i < num_cols; i++) {
+    for (int i = static_cast<int>(num_cols - 2); i < static_cast<int>(num_cols); i++) {
       av[i] = CastFixedSizeBinaryArrayToBinaryArray(input_table->column(i)->chunk(0));
     }
     std::shared_ptr<Table> expected_output_table = Table::Make(output_schema, av);
@@ -569,9 +569,9 @@ class TestORCWriterSingleArray : public ::testing::Test {
 TEST_F(TestORCWriterSingleArray, WriteStruct) {
   std::vector<std::shared_ptr<Field>> subfields{field("int32", boolean())};
   const int64_t num_rows = 1234;
-  int num_subcols = subfields.size();
+  std::size_t num_subcols = subfields.size();
   ArrayVector av0(num_subcols);
-  for (int i = 0; i < num_subcols; i++) {
+  for (int i = 0; i < static_cast<int>(num_subcols); i++) {
     av0[i] = rand.ArrayOf(subfields[i]->type(), num_rows, 0.4);
   }
   std::shared_ptr<Buffer> bitmap = rand.NullBitmap(num_rows, 0.5);
@@ -592,9 +592,9 @@ TEST_F(TestORCWriterSingleArray, WriteStructOfStruct) {
       field("string", utf8()),
       field("binary", binary())};
   const int64_t num_rows = 1234;
-  int num_subsubcols = subsubfields.size();
+  std::size_t num_subsubcols = subsubfields.size();
   ArrayVector av00(num_subsubcols), av0(1);
-  for (int i = 0; i < num_subsubcols; i++) {
+  for (int i = 0; i < static_cast<int>(num_subsubcols); i++) {
     av00[i] = rand.ArrayOf(subsubfields[i]->type(), num_rows, 0);
   }
   std::shared_ptr<Buffer> bitmap0 = rand.NullBitmap(num_rows, 0);
diff --git a/cpp/src/arrow/adapters/orc/util.cc b/cpp/src/arrow/adapters/orc/util.cc
index f7fe35eab6..14931752bf 100644
--- a/cpp/src/arrow/adapters/orc/util.cc
+++ b/cpp/src/arrow/adapters/orc/util.cc
@@ -357,7 +357,7 @@ Result<std::shared_ptr<Array>> NormalizeArray(const std::shared_ptr<Array>& arra
         std::size_t size = struct_type->fields().size();
         std::vector<std::shared_ptr<Array>> new_children(size, nullptr);
         for (std::size_t i = 0; i < size; i++) {
-          std::shared_ptr<Array> child = struct_array->field(i);
+          std::shared_ptr<Array> child = struct_array->field(static_cast<int>(i));
           const std::shared_ptr<Buffer> child_bitmap = child->null_bitmap();
           std::shared_ptr<Buffer> final_child_bitmap;
           if (child_bitmap == nullptr) {
@@ -649,7 +649,8 @@ Status WriteStructBatch(const Array& array, int64_t orc_offset,
   // Fill the fields
   for (std::size_t i = 0; i < size; i++) {
     batch->fields[i]->resize(orc_offset + arrow_length);
-    RETURN_NOT_OK(WriteBatch(*(struct_array->field(i)), orc_offset, batch->fields[i]));
+    RETURN_NOT_OK(WriteBatch(*(struct_array->field(static_cast<int>(i))), orc_offset,
+                             batch->fields[i]));
   }
   return Status::OK();
 }
diff --git a/cpp/src/arrow/compute/exec/hash_join_node_test.cc b/cpp/src/arrow/compute/exec/hash_join_node_test.cc
index e4e0bb2443..99a8fc01e0 100644
--- a/cpp/src/arrow/compute/exec/hash_join_node_test.cc
+++ b/cpp/src/arrow/compute/exec/hash_join_node_test.cc
@@ -346,8 +346,9 @@ struct RandomDataType {
           }
         }
       } else {
-        result.fixed_length =
-            ((1ULL << log_type) == constraints.kBool) ? 0 : (1ULL << log_type);
+        result.fixed_length = ((1ULL << log_type) == constraints.kBool)
+                                  ? 0
+                                  : static_cast<int>(1ULL << log_type);
       }
     } else {
       // Pick parameters for string
diff --git a/cpp/src/arrow/vendored/musl/strptime.c b/cpp/src/arrow/vendored/musl/strptime.c
index e8111f5767..41912fd1bb 100644
--- a/cpp/src/arrow/vendored/musl/strptime.c
+++ b/cpp/src/arrow/vendored/musl/strptime.c
@@ -47,7 +47,7 @@ char *strptime(const char *__restrict s, const char *__restrict f, struct tm *__
 		if (*f == '+') f++;
 		if (isdigit(*f)) {
 			char *new_f;
-			w=strtoul(f, &new_f, 10);
+			w=(int)(strtoul(f, &new_f, 10));
 			f = new_f;
 		} else {
 			w=-1;
diff --git a/cpp/src/plasma/client.cc b/cpp/src/plasma/client.cc
index 260999922f..852cdda784 100644
--- a/cpp/src/plasma/client.cc
+++ b/cpp/src/plasma/client.cc
@@ -1038,7 +1038,7 @@ Status PlasmaClient::Impl::DecodeNotifications(const uint8_t* buffer,
   std::lock_guard<std::recursive_mutex> guard(client_mutex_);
   auto object_info = flatbuffers::GetRoot<fb::PlasmaNotification>(buffer);
 
-  for (size_t i = 0; i < object_info->object_info()->size(); ++i) {
+  for (flatbuffers::uoffset_t i = 0; i < object_info->object_info()->size(); ++i) {
     auto info = object_info->object_info()->Get(i);
     ObjectID id = ObjectID::from_binary(info->object_id()->str());
     object_ids->push_back(id);
diff --git a/cpp/src/plasma/protocol.cc b/cpp/src/plasma/protocol.cc
index 735636cda9..a3fe87de82 100644
--- a/cpp/src/plasma/protocol.cc
+++ b/cpp/src/plasma/protocol.cc
@@ -94,7 +94,7 @@ void ConvertToVector(const FlatbufferVectorPointer fbvector, std::vector<T>* out
                      const Converter& converter) {
   out->clear();
   out->reserve(fbvector->size());
-  for (size_t i = 0; i < fbvector->size(); ++i) {
+  for (flatbuffers::uoffset_t i = 0; i < fbvector->size(); ++i) {
     out->push_back(converter(*fbvector->Get(i)));
   }
 }