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/09/27 12:19:58 UTC

[arrow] 19/24: PARQUET-1177: Add PARQUET_BUILD_WARNING_LEVEL option and more rigorous Clang 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

commit eefd36eba3e33fc5df570905c8d85162fd1728db
Author: Wes McKinney <we...@twosigma.com>
AuthorDate: Wed Dec 13 17:19:22 2017 -0500

    PARQUET-1177: Add PARQUET_BUILD_WARNING_LEVEL option and more rigorous Clang warnings
    
    These warnings will catch a number of things that have bitten us in the past, like missing virtual destructors. This brings Parquet's compiler warnings up to the same quality as Arrow's
    
    Author: Wes McKinney <we...@twosigma.com>
    Author: Wes McKinney <we...@gmail.com>
    
    Closes #425 from wesm/PARQUET-1177 and squashes the following commits:
    
    3769a8c [Wes McKinney] Add -Wno-missing-noreturn
    5b6cd80 [Wes McKinney] Compile with /bigobj in MSVC
    cc5bca0 [Wes McKinney] Add noreturn to static methods in ParquetException
    e3ffb71 [Wes McKinney] Fix -Wconversion warnings in decode_benchmark.cc
    758a216 [Wes McKinney] Fix warnings on macOS Clang
    3aef3b4 [Wes McKinney] Do not pass -Werror via PARQUET_CXXFLAGS
    5a98e81 [Wes McKinney] Fix usage of PrimitiveArray::raw_values
    c848855 [Wes McKinney] Fix compiler warnings with gcc 4.9
    ca9a374 [Wes McKinney] Add SetupCxxFlags.cmake from Apache Arrow. Add PARQUET_BUILD_WARNING_LEVEL flag. Fix Clang compiler warnings
    
    Change-Id: I428d1d90bc4eb3dab8b56a538d1eb58656664b74
---
 cpp/examples/parquet/reader-writer.cc | 16 ++++++++--------
 cpp/tools/parquet/parquet-scan.cc     |  3 ++-
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/cpp/examples/parquet/reader-writer.cc b/cpp/examples/parquet/reader-writer.cc
index 7136b28..fb2ec77 100644
--- a/cpp/examples/parquet/reader-writer.cc
+++ b/cpp/examples/parquet/reader-writer.cc
@@ -170,7 +170,7 @@ int main(int argc, char** argv) {
     parquet::FloatWriter* float_writer =
         static_cast<parquet::FloatWriter*>(rg_writer->NextColumn());
     for (int i = 0; i < NUM_ROWS_PER_ROW_GROUP; i++) {
-      float value = i * 1.1f;
+      float value = static_cast<float>(i) * 1.1f;
       float_writer->WriteBatch(1, nullptr, nullptr, &value);
     }
 
@@ -188,9 +188,9 @@ int main(int argc, char** argv) {
     for (int i = 0; i < NUM_ROWS_PER_ROW_GROUP; i++) {
       parquet::ByteArray value;
       char hello[FIXED_LENGTH] = "parquet";
-      hello[7] = '0' + i / 100;
-      hello[8] = '0' + (i / 10) % 10;
-      hello[9] = '0' + i % 10;
+      hello[7] = static_cast<char>(static_cast<int>('0') + i / 100);
+      hello[8] = static_cast<char>(static_cast<int>('0') + (i / 10) % 10);
+      hello[9] = static_cast<char>(static_cast<int>('0') + i % 10);
       if (i % 2 == 0) {
         int16_t definition_level = 1;
         value.ptr = reinterpret_cast<const uint8_t*>(&hello[0]);
@@ -369,7 +369,7 @@ int main(int argc, char** argv) {
         // There are no NULL values in the rows written
         assert(values_read == 1);
         // Verify the value written
-        float expected_value = i * 1.1f;
+        float expected_value = static_cast<float>(i) * 1.1f;
         assert(value == expected_value);
         i++;
       }
@@ -411,9 +411,9 @@ int main(int argc, char** argv) {
         assert(rows_read == 1);
         // Verify the value written
         char expected_value[FIXED_LENGTH] = "parquet";
-        expected_value[7] = '0' + i / 100;
-        expected_value[8] = '0' + (i / 10) % 10;
-        expected_value[9] = '0' + i % 10;
+        expected_value[7] = static_cast<char>('0' + i / 100);
+        expected_value[8] = static_cast<char>('0' + (i / 10) % 10);
+        expected_value[9] = static_cast<char>('0' + i % 10);
         if (i % 2 == 0) {  // only alternate values exist
           // There are no NULL values in the rows written
           assert(values_read == 1);
diff --git a/cpp/tools/parquet/parquet-scan.cc b/cpp/tools/parquet/parquet-scan.cc
index fdc73d7..ab9363b 100644
--- a/cpp/tools/parquet/parquet-scan.cc
+++ b/cpp/tools/parquet/parquet-scan.cc
@@ -65,7 +65,8 @@ int main(int argc, char** argv) {
 
     int64_t total_rows = parquet::ScanFileContents(columns, batch_size, reader.get());
 
-    total_time = (std::clock() - start_time) / static_cast<double>(CLOCKS_PER_SEC);
+    total_time = static_cast<double>(std::clock() - start_time) /
+      static_cast<double>(CLOCKS_PER_SEC);
     std::cout << total_rows << " rows scanned in " << total_time << " seconds."
               << std::endl;
   } catch (const std::exception& e) {