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

xiaokang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-graphar.git


The following commit(s) were added to refs/heads/main by this push:
     new 15558156 fix(c++): fix compile warnings(comparison of int and  uint,  
unused result, catch value) (#849)
15558156 is described below

commit 155581565576dc7faad2f7833fe630071d79e87d
Author: 姚军 <[email protected]>
AuthorDate: Sat Feb 14 10:45:46 2026 +0800

    fix(c++): fix compile warnings(comparison of int and  uint,  unused result, 
catch value) (#849)
---
 cpp/src/graphar/arrow/chunk_reader.cc  |  4 ++-
 cpp/test/test_arrow_chunk_reader.cc    | 54 ++++++++++++++++++++++------------
 cpp/test/test_multi_property.cc        |  3 +-
 cpp/thirdparty/mini-yaml/yaml/Yaml.cpp |  4 +--
 4 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/cpp/src/graphar/arrow/chunk_reader.cc 
b/cpp/src/graphar/arrow/chunk_reader.cc
index 1b5200fc..f47d1374 100644
--- a/cpp/src/graphar/arrow/chunk_reader.cc
+++ b/cpp/src/graphar/arrow/chunk_reader.cc
@@ -433,6 +433,8 @@ VertexPropertyArrowChunkReader::Make(
   case SelectType::PROPERTIES:
     return MakeForProperties(graph_info, type, property_names_or_labels,
                              options);
+  default:
+    return Status::Invalid("Unsupported select type");
   }
 }
 
@@ -466,7 +468,7 @@ VertexPropertyArrowChunkReader::MakeForProperties(
         property_names_mutable[property_names_mutable.size() - 1],
         " doesn't exist in vertex type ", type, ".");
   }
-  for (int i = 0; i < property_names_mutable.size() - 1; i++) {
+  for (size_t i = 0; i < property_names_mutable.size() - 1; i++) {
     if (property_names_mutable[i] == graphar::GeneralParams::kVertexIndexCol) {
       hasIndexCol = true;
     }
diff --git a/cpp/test/test_arrow_chunk_reader.cc 
b/cpp/test/test_arrow_chunk_reader.cc
index 8fcdfb6a..2db69a81 100644
--- a/cpp/test/test_arrow_chunk_reader.cc
+++ b/cpp/test/test_arrow_chunk_reader.cc
@@ -61,7 +61,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(table->num_rows() == 100);
       std::cout << table->num_columns() << std::endl;
       std::cout << v_pg->GetProperties().size() << std::endl;
-      REQUIRE(table->num_columns() == v_pg->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
 
@@ -71,7 +72,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == v_pg->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       REQUIRE(reader->next_chunk().ok());
@@ -79,7 +81,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == v_pg->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       REQUIRE(reader->seek(900).ok());
@@ -87,7 +90,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 3);
-      REQUIRE(table->num_columns() == v_pg->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       REQUIRE(reader->GetChunkNum() == 10);
@@ -103,7 +107,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(table->num_rows() == 100);
       std::cout << table->num_columns() << std::endl;
       std::cout << v_pg->GetProperties().size() << std::endl;
-      REQUIRE(table->num_columns() == v_pg->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
 
@@ -113,7 +118,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == v_pg->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       REQUIRE(reader->next_chunk().ok());
@@ -121,7 +127,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == v_pg->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       REQUIRE(reader->seek(900).ok());
@@ -129,7 +136,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 3);
-      REQUIRE(table->num_columns() == v_pg->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       REQUIRE(reader->GetChunkNum() == 10);
@@ -148,7 +156,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       auto table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == v_pg_name->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg_name->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       // VERSION V1
@@ -160,7 +169,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 48);
-      REQUIRE(table->num_columns() == v_pg_name->GetProperties().size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(v_pg_name->GetProperties().size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
     }
@@ -329,7 +339,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(table->num_rows() == 100);
       std::cout << table->num_columns() << std::endl;
       std::cout << vertex_property_names.size() << std::endl;
-      REQUIRE(table->num_columns() == vertex_property_names.size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(vertex_property_names.size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       for (auto pn : vertex_property_names) {
@@ -341,7 +352,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == vertex_property_names.size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(vertex_property_names.size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       for (auto pn : vertex_property_names) {
@@ -352,7 +364,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == vertex_property_names.size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(vertex_property_names.size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       for (auto pn : vertex_property_names) {
@@ -363,7 +376,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 3);
-      REQUIRE(table->num_columns() == vertex_property_names.size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(vertex_property_names.size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       for (auto pn : vertex_property_names) {
@@ -381,7 +395,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(table->num_rows() == 100);
       std::cout << table->num_columns() << std::endl;
       std::cout << vertex_property_names.size() << std::endl;
-      REQUIRE(table->num_columns() == vertex_property_names.size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(vertex_property_names.size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       for (auto pn : vertex_property_names) {
@@ -393,7 +408,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == vertex_property_names.size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(vertex_property_names.size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       for (auto pn : vertex_property_names) {
@@ -404,7 +420,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 100);
-      REQUIRE(table->num_columns() == vertex_property_names.size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(vertex_property_names.size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       for (auto pn : vertex_property_names) {
@@ -415,7 +432,8 @@ TEST_CASE_METHOD(GlobalFixture, "ArrowChunkReader") {
       REQUIRE(!result.has_error());
       table = result.value();
       REQUIRE(table->num_rows() == 3);
-      REQUIRE(table->num_columns() == vertex_property_names.size() + 1);
+      REQUIRE(table->num_columns() ==
+              static_cast<int>(vertex_property_names.size()) + 1);
       REQUIRE(table->GetColumnByName(GeneralParams::kVertexIndexCol) !=
               nullptr);
       for (auto pn : vertex_property_names) {
diff --git a/cpp/test/test_multi_property.cc b/cpp/test/test_multi_property.cc
index 327f1bf5..95714b72 100644
--- a/cpp/test/test_multi_property.cc
+++ b/cpp/test/test_multi_property.cc
@@ -94,7 +94,8 @@ TEST_CASE_METHOD(GlobalFixture, "read multi-properties from 
csv file") {
     }
   }
   std::shared_ptr<arrow::Array> array;
-  builder.Finish(&array);
+  auto status = builder.Finish(&array);
+  REQUIRE(status.ok());
   auto person_emails_chunked_array = std::make_shared<arrow::ChunkedArray>(
       std::vector<std::shared_ptr<arrow::Array>>{array});
   int emailFieldIndex = person_schema->GetFieldIndex("emails");
diff --git a/cpp/thirdparty/mini-yaml/yaml/Yaml.cpp 
b/cpp/thirdparty/mini-yaml/yaml/Yaml.cpp
index 9a84975e..c41bca35 100644
--- a/cpp/thirdparty/mini-yaml/yaml/Yaml.cpp
+++ b/cpp/thirdparty/mini-yaml/yaml/Yaml.cpp
@@ -1375,7 +1375,7 @@ namespace Yaml
                 //Print();
                 ParseRoot(root);
             }
-            catch(Exception e)
+            catch(const Exception& e)
             {
                 root.Clear();
                 throw;
@@ -2250,7 +2250,7 @@ namespace Yaml
             pImp->Parse(root, stream);
             delete pImp;
         }
-        catch (const Exception e)
+        catch (const Exception& e)
         {
             delete pImp;
             throw;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to