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

colinlee pushed a commit to branch fix_warning
in repository https://gitbox.apache.org/repos/asf/tsfile.git

commit a8ac23ade6a1fa608cf4043fc121f83dc3fb9f29
Author: ColinLee <[email protected]>
AuthorDate: Sun Jun 29 08:21:00 2025 +0800

    fix some warnning.
---
 cpp/CMakeLists.txt                                     | 2 +-
 cpp/src/common/global.h                                | 1 -
 cpp/src/common/tsfile_common.cc                        | 1 -
 cpp/src/common/tsfile_common.h                         | 2 +-
 cpp/src/encoding/bitpack_decoder.h                     | 6 ++++--
 cpp/test/writer/table_view/tsfile_writer_table_test.cc | 2 --
 6 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 75684ce0..6ab10f0b 100755
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -23,7 +23,7 @@ cmake_policy(SET CMP0079 NEW)
 set(TsFile_CPP_VERSION 2.1.0.dev)
 set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall")
 if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=maybe-uninitialized 
-D__STDC_FORMAT_MACROS")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused -Wuninitialized -Werror 
-Wshadow -D__STDC_FORMAT_MACROS")
 endif()
 
 message("cmake using: USE_CPP11=${USE_CPP11}")
diff --git a/cpp/src/common/global.h b/cpp/src/common/global.h
index 3f331460..50ca8c8a 100644
--- a/cpp/src/common/global.h
+++ b/cpp/src/common/global.h
@@ -58,7 +58,6 @@ FORCE_INLINE int set_global_time_compression(uint8_t 
compression) {
 }
 
 FORCE_INLINE int set_datatype_encoding(uint8_t data_type, uint8_t encoding) {
-    int code = E_OK;
     TSDataType dtype = static_cast<TSDataType>(data_type);
     ASSERT(dtype >= BOOLEAN && dtype <= STRING);
     TSEncoding encoding_type = static_cast<TSEncoding>(encoding);
diff --git a/cpp/src/common/tsfile_common.cc b/cpp/src/common/tsfile_common.cc
index 06c415bc..31c718b4 100644
--- a/cpp/src/common/tsfile_common.cc
+++ b/cpp/src/common/tsfile_common.cc
@@ -29,7 +29,6 @@ using namespace common;
 namespace storage {
 
 const char *MAGIC_STRING_TSFILE = "TsFile";
-const int MAGIC_STRING_TSFILE_LEN = 6;
 const char VERSION_NUM_BYTE = 0x04;  // 0x03;
 const char CHUNK_GROUP_HEADER_MARKER = 0;
 const char CHUNK_HEADER_MARKER = 1;
diff --git a/cpp/src/common/tsfile_common.h b/cpp/src/common/tsfile_common.h
index 3ad5bb1b..78089ec9 100644
--- a/cpp/src/common/tsfile_common.h
+++ b/cpp/src/common/tsfile_common.h
@@ -40,7 +40,7 @@
 namespace storage {
 
 extern const char *MAGIC_STRING_TSFILE;
-extern const int MAGIC_STRING_TSFILE_LEN;
+constexpr int MAGIC_STRING_TSFILE_LEN = 6;
 extern const char VERSION_NUM_BYTE;
 extern const char CHUNK_GROUP_HEADER_MARKER;
 extern const char CHUNK_HEADER_MARKER;
diff --git a/cpp/src/encoding/bitpack_decoder.h 
b/cpp/src/encoding/bitpack_decoder.h
index 099afc79..61c30d1a 100644
--- a/cpp/src/encoding/bitpack_decoder.h
+++ b/cpp/src/encoding/bitpack_decoder.h
@@ -124,17 +124,19 @@ class BitPackDecoder {
             delete[] current_buffer_;
         }
         current_buffer_ = new int64_t[bit_packed_group_count * 8];
-        unsigned char bytes[bit_packed_group_count * bit_width_];
         int bytes_to_read = bit_packed_group_count * bit_width_;
         if (bytes_to_read > (int)byte_cache_.remaining_size()) {
             bytes_to_read = byte_cache_.remaining_size();
         }
+        std::vector<unsigned char> bytes(bytes_to_read);
+
         for (int i = 0; i < bytes_to_read; i++) {
             common::SerializationUtil::read_ui8(bytes[i], byte_cache_);
         }
+
         // save all int values in currentBuffer
         packer_->unpack_all_values(
-            bytes, bytes_to_read,
+            bytes.data(), bytes_to_read,
             current_buffer_);  // decode from bytes, save in currentBuffer
     }
 
diff --git a/cpp/test/writer/table_view/tsfile_writer_table_test.cc 
b/cpp/test/writer/table_view/tsfile_writer_table_test.cc
index 4b353ca2..20c0bd8f 100644
--- a/cpp/test/writer/table_view/tsfile_writer_table_test.cc
+++ b/cpp/test/writer/table_view/tsfile_writer_table_test.cc
@@ -569,7 +569,6 @@ TEST_F(TsFileWriterTableTest, WriteWithNullAndEmptyTag) {
 
     auto table_result_set = (TableResultSet*)ret;
     bool has_next = false;
-    int cur_line = 0;
     auto schema = table_result_set->get_metadata();
     while (IS_SUCC(table_result_set->next(has_next)) && has_next) {
         int64_t timestamp = table_result_set->get_value<int64_t>(1);
@@ -744,7 +743,6 @@ TEST_F(TsFileWriterTableTest, WriteDataWithEmptyField) {
 
     auto table_result_set = (TableResultSet*)ret;
     bool has_next = false;
-    int cur_line = 0;
     auto schema = table_result_set->get_metadata();
     while (IS_SUCC(table_result_set->next(has_next)) && has_next) {
         int64_t timestamp = table_result_set->get_value<int64_t>(1);

Reply via email to