stoneatom / stonedb

StoneDB is an Open-Source MySQL HTAP and MySQL-Native DataBase for OLTP, Real-Time Analytics, a counterpart of MySQLHeatWave. (https://stonedb.io)
https://stonedb.io/
GNU General Public License v2.0
862 stars 139 forks source link

backport: fix warnings #1679

Open hustjieke opened 1 year ago

hustjieke commented 1 year ago

Is your feature request related to a problem? Please describe.

commit id: 00dac9644d194d8c30aee904130a8205f13f2d1f

check this pr and keep consistent with 8.0.

Describe the solution you'd like

Describe alternatives you've considered

Additional context

chenshengjiang commented 1 year ago

assigned me!

chenshengjiang commented 1 year ago

There are just 2 warnings when building stonedb8.0, and same kind use static_cast to transform the type of rcTables.size() from long unsigned int to int

/home/stonedb/storage/tianmu/core/parameterized_filter.cpp: In member function ‘void Tianmu::core::ParameterizedFilter::UpdateMultiIndex(bool, int64_t)’:
/home/stonedb/storage/tianmu/core/parameterized_filter.cpp:1024:41: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<Tianmu::core::JustATable*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
 1024 |     for (int tableIndex = 0; tableIndex < rcTables.size(); ++tableIndex) {
      |                              ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/stonedb/storage/tianmu/core/parameterized_filter.cpp: In member function ‘void Tianmu::core::ParameterizedFilter::FilterDeletedForSelectAll()’:
/home/stonedb/storage/tianmu/core/parameterized_filter.cpp:1562:41: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<Tianmu::core::JustATable*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
 1562 |     for (int tableIndex = 0; tableIndex < rcTables.size(); ++tableIndex) {
      |                              ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
chenshengjiang commented 1 year ago

There are 3 warnings when build type is release, above is debug type

/home/stonedb/storage/tianmu/core/column_share.cpp: In member function ‘int Tianmu::core::ColumnShare::alloc_dpn(Tianmu::common::TX_ID, const Tianmu::core::DPN*)’:
/home/stonedb/storage/tianmu/core/column_share.cpp:239:12: warning: ignoring return value of ‘int ftruncate(int, __off64_t)’, declared with attribute warn_unused_result [-Wunused-result]
  239 |   ftruncate(dn_fd, capacity * sizeof(DPN));
      |   ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/stonedb/storage/tianmu/system/channel.cpp: In member function ‘Tianmu::system::Channel& Tianmu::system::Channel::lock(uint)’:
/home/stonedb/storage/tianmu/system/channel.cpp:51:50: warning: ‘%02d’ directive writing between 2 and 11 bytes into a region of size between 0 and 17 [-Wformat-overflow=]
   51 |     std::sprintf(sdatetime, "[%4d-%02d-%02d %02d:%02d:%02d.%06d]", cdt->tm_year + 1900, cdt->tm_mon + 1, cdt->tm_mday,
      |                                                  ^~~~
/home/stonedb/storage/tianmu/system/channel.cpp:51:29: note: using the range [-2147483648, 2147483647] for directive argument
   51 |     std::sprintf(sdatetime, "[%4d-%02d-%02d %02d:%02d:%02d.%06d]", cdt->tm_year + 1900, cdt->tm_mon + 1, cdt->tm_mday,
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:867,
                 from /usr/include/c++/9/cstdio:42,
                 from /usr/include/c++/9/ext/string_conversions.h:43,
                 from /usr/include/c++/9/bits/basic_string.h:6496,
                 from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/stdexcept:39,
                 from /usr/include/c++/9/array:39,
                 from /usr/include/c++/9/tuple:39,
                 from /usr/include/c++/9/mutex:38,
                 from /home/stonedb/storage/tianmu/system/channel.cpp:20:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:36:34: note: ‘__builtin___sprintf_chk’ output between 29 and 86 bytes into a destination of size 32
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/stonedb/storage/tianmu/types/rc_num.cpp: In member function ‘virtual Tianmu::types::BString Tianmu::types::RCNum::ToBString() const’:
/home/stonedb/storage/tianmu/types/rc_num.cpp:249:11: warning: ignoring return value of ‘char* gcvt(double, int, char*)’, declared with attribute warn_unused_result [-Wunused-result]
  249 |       gcvt(*reinterpret_cast<double *>(const_cast<int64_t *>(&value_)), 15, buf);
      |       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~