[Chore](build) enable -Wextra and remove some -Wno (#15760)

enable -Wextra and remove some -Wno
This commit is contained in:
Pxl
2023-01-15 10:40:35 +08:00
committed by GitHub
parent fd0c352144
commit b727033906
28 changed files with 60 additions and 75 deletions

View File

@ -453,12 +453,13 @@ check_function_exists(sched_getcpu HAVE_SCHED_GETCPU)
# compiler flags that are common across debug/release builds
# -Wall: Enable all warnings.
# -Wno-sign-compare: suppress warnings for comparison between signed and unsigned
# integers
# -pthread: enable multithreaded malloc
# -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG: enable nanosecond precision for boost
# -fno-omit-frame-pointers: Keep frame pointer for functions in register
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall -Wno-sign-compare -pthread -Werror")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -g -Wall -Wextra -pthread -Werror")
# TODO: resolve and remove those wno
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-implicit-fallthrough -Wno-sign-compare")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -fstrict-aliasing -fno-omit-frame-pointer")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -std=gnu++17 -D__STDC_FORMAT_MACROS")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG")
@ -482,9 +483,7 @@ endfunction()
# In terms of performance, mold> lld> gold> ld
set(CUSTUM_LINKER_COMMAND "ld")
# TODO: mold will link fail on thirdparty brpc now, waiting for investigation.
# TRY_TO_CHANGE_LINKER("mold" "mold")
TRY_TO_CHANGE_LINKER("mold" "mold")
TRY_TO_CHANGE_LINKER("lld" "LLD")
TRY_TO_CHANGE_LINKER("gold" "GNU gold")
if (NOT CUSTUM_LINKER_COMMAND STREQUAL "ld")
@ -523,7 +522,7 @@ if ("${CMAKE_BUILD_TARGET_ARCH}" STREQUAL "x86" OR "${CMAKE_BUILD_TARGET_ARCH}"
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -mavx2")
endif()
endif()
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-attributes -DS2_USE_GFLAGS -DS2_USE_GLOG")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DS2_USE_GFLAGS -DS2_USE_GLOG")
if (WITH_MYSQL)
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DDORIS_WITH_MYSQL")
@ -563,11 +562,6 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -faligned-new")
endif()
# For any gcc builds:
# -g: Enable symbols for profiler tools. Produce debugging information in the operating system’s native formt
# -Wno-unused-local-typedefs: Do not warn for local typedefs that are unused.
set(CXX_GCC_FLAGS "${CXX_GCC_FLAGS} -g -Wno-unused-local-typedefs")
if (USE_DWARF)
set(CXX_GCC_FLAGS "${CXX_GCC_FLAGS} -gdwarf-5")
endif()

View File

@ -262,7 +262,7 @@ arrow::Result<std::shared_ptr<arrow::Buffer>> ArrowFile::Read(int64_t nbytes) {
ARROW_RETURN_NOT_OK(bytes_read);
// If bytes_read is equal with read_buf's capacity, we just assign
if (bytes_read.ValueOrDie() == nbytes) {
return std::move(read_buf);
return read_buf;
} else {
return arrow::SliceBuffer(read_buf, 0, bytes_read.ValueOrDie());
}

View File

@ -69,7 +69,7 @@ GzipDecompressor::~GzipDecompressor() {
}
Status GzipDecompressor::init() {
_z_strm = {nullptr};
_z_strm = {};
_z_strm.zalloc = Z_NULL;
_z_strm.zfree = Z_NULL;
_z_strm.opaque = Z_NULL;

View File

@ -85,7 +85,7 @@ void PlainTextLineReader::close() {
inline bool PlainTextLineReader::update_eof() {
if (done()) {
_eof = true;
} else if (_decompressor == nullptr && (_min_length >= 0 && _total_read_bytes >= _min_length)) {
} else if (_decompressor == nullptr && _total_read_bytes >= _min_length) {
_eof = true;
}
return _eof;

View File

@ -17,7 +17,6 @@
#include "exec/schema_scanner/schema_charsets_scanner.h"
#include "runtime/primitive_type.h"
#include "runtime/string_value.h"
namespace doris {
@ -32,7 +31,7 @@ SchemaScanner::ColumnDesc SchemaCharsetsScanner::_s_css_columns[] = {
SchemaCharsetsScanner::CharsetStruct SchemaCharsetsScanner::_s_charsets[] = {
{"utf8", "utf8_general_ci", "UTF-8 Unicode", 3},
{nullptr, nullptr, 0},
{nullptr, nullptr, nullptr, 0},
};
SchemaCharsetsScanner::SchemaCharsetsScanner()

View File

@ -227,12 +227,16 @@ void CmdlineAction::handle(HttpRequest* req) {
HttpChannel::send_reply(req, str);
return;
}
std::string str;
char buf[1024];
// Ignore unused return value
if (fscanf(fp, "%1023s ", buf))
;
if (fscanf(fp, "%1023s ", buf) == 1) {
str = buf;
} else {
str = "Unable to read file: /proc/self/cmdline";
}
fclose(fp);
std::string str = buf;
HttpChannel::send_reply(req, str);
}

View File

@ -239,7 +239,6 @@ void ArrayColumnVectorBatch::put_item_ordinal(segment_v2::ordinal_t* ordinals, s
}
void ArrayColumnVectorBatch::get_offset_by_length(size_t start_idx, size_t size) {
DCHECK(start_idx >= 0);
DCHECK(start_idx + size < _offsets->capacity());
for (size_t i = start_idx; i < start_idx + size; ++i) {

View File

@ -47,8 +47,8 @@ struct WriteRequest {
// slots are in order of tablet's schema
const std::vector<SlotDescriptor*>* slots;
bool is_high_priority = false;
POlapTableSchemaParam ptable_schema_param;
int64_t index_id;
POlapTableSchemaParam ptable_schema_param = {};
int64_t index_id = 0;
};
// Writer for a particular (load, index, tablet).

View File

@ -47,7 +47,7 @@ Status BitmapIndexIterator::seek_dictionary(const void* value, bool* exact_match
}
Status BitmapIndexIterator::read_bitmap(rowid_t ordinal, roaring::Roaring* result) {
DCHECK(0 <= ordinal && ordinal < _reader->bitmap_nums());
DCHECK(ordinal < _reader->bitmap_nums());
size_t num_to_read = 1;
auto data_type = vectorized::DataTypeFactory::instance().create_data_type(
@ -65,7 +65,7 @@ Status BitmapIndexIterator::read_bitmap(rowid_t ordinal, roaring::Roaring* resul
}
Status BitmapIndexIterator::read_union_bitmap(rowid_t from, rowid_t to, roaring::Roaring* result) {
DCHECK(0 <= from && from <= to && to <= _reader->bitmap_nums());
DCHECK(from <= to && to <= _reader->bitmap_nums());
for (rowid_t pos = from; pos < to; pos++) {
roaring::Roaring bitmap;

View File

@ -52,7 +52,7 @@ uint32_t BloomFilter::optimal_bit_num(uint64_t n, double fpp) {
// ref parquet bloom_filter branch(BlockSplitBloomFilter.java)
uint32_t num_bits = -8 * (double)n / log(1 - pow(fpp, 1.0 / 8));
uint32_t max_bits = MAXIMUM_BYTES << 3;
if (num_bits > max_bits || num_bits < 0) {
if (num_bits > max_bits) {
num_bits = max_bits;
}

View File

@ -536,28 +536,26 @@ Status ArrayFileColumnIterator::next_batch(size_t* n, ColumnBlockView* dst, bool
// read item
size_t item_size = ordinals[*n] - ordinals[0];
if (item_size >= 0) {
bool item_has_null = false;
ColumnVectorBatch* item_vector_batch = array_batch->elements();
bool item_has_null = false;
ColumnVectorBatch* item_vector_batch = array_batch->elements();
bool rebuild_array_from0 = false;
if (item_vector_batch->capacity() < array_batch->item_offset(dst->current_offset() + *n)) {
item_vector_batch->resize(array_batch->item_offset(dst->current_offset() + *n));
rebuild_array_from0 = true;
}
ColumnBlock item_block = ColumnBlock(item_vector_batch, dst->pool());
ColumnBlockView item_view =
ColumnBlockView(&item_block, array_batch->item_offset(dst->current_offset()));
size_t real_read = item_size;
RETURN_IF_ERROR(_item_iterator->next_batch(&real_read, &item_view, &item_has_null));
DCHECK(item_size == real_read);
size_t rebuild_start_offset = rebuild_array_from0 ? 0 : dst->current_offset();
size_t rebuild_size = rebuild_array_from0 ? dst->current_offset() + *n : *n;
array_batch->prepare_for_read(rebuild_start_offset, rebuild_size, item_has_null);
bool rebuild_array_from0 = false;
if (item_vector_batch->capacity() < array_batch->item_offset(dst->current_offset() + *n)) {
item_vector_batch->resize(array_batch->item_offset(dst->current_offset() + *n));
rebuild_array_from0 = true;
}
ColumnBlock item_block = ColumnBlock(item_vector_batch, dst->pool());
ColumnBlockView item_view =
ColumnBlockView(&item_block, array_batch->item_offset(dst->current_offset()));
size_t real_read = item_size;
RETURN_IF_ERROR(_item_iterator->next_batch(&real_read, &item_view, &item_has_null));
DCHECK(item_size == real_read);
size_t rebuild_start_offset = rebuild_array_from0 ? 0 : dst->current_offset();
size_t rebuild_size = rebuild_array_from0 ? dst->current_offset() + *n : *n;
array_batch->prepare_for_read(rebuild_start_offset, rebuild_size, item_has_null);
dst->advance(*n);
return Status::OK();
}

View File

@ -124,7 +124,7 @@ Status IndexedColumnIterator::_read_data_page(const PagePointer& pp) {
}
Status IndexedColumnIterator::seek_to_ordinal(ordinal_t idx) {
DCHECK(idx >= 0 && idx <= _reader->num_values());
DCHECK(idx <= _reader->num_values());
if (!_reader->support_ordinal_seek()) {
return Status::NotSupported("no ordinal index");

View File

@ -2010,8 +2010,8 @@ Status Tablet::lookup_row_key(const Slice& encoded_key, const RowsetIdUnorderedS
return s;
}
loc.rowset_id = rs.first->rowset_id();
if (version >= 0 && _tablet_meta->delete_bitmap().contains_agg(
{loc.rowset_id, loc.segment_id, version}, loc.row_id)) {
if (_tablet_meta->delete_bitmap().contains_agg({loc.rowset_id, loc.segment_id, version},
loc.row_id)) {
// if has sequence col, we continue to compare the sequence_id of
// all rowsets, util we find an existing key.
if (_schema->has_sequence_col()) {

View File

@ -243,7 +243,6 @@ static std::pair<double, double> quadratic_equation_naive(__uint128_t a, __uint1
__uint128_t dis = b * b - 4 * a * c;
// assert(dis >= 0);
// not handling complex root
if (dis < 0) return std::make_pair(0, 0);
double sqrtdis = std::sqrt(static_cast<double>(dis));
double a_r = static_cast<double>(a);
double b_r = static_cast<double>(b);

View File

@ -102,9 +102,12 @@ BfdParser* BfdParser::create() {
}
char prog_name[1024];
// Ignore unused return value
if (fscanf(file, "%1023s ", prog_name))
;
if (fscanf(file, "%1023s ", prog_name) != 1) {
fclose(file);
return nullptr;
}
fclose(file);
std::unique_ptr<BfdParser> parser(new BfdParser(prog_name));
if (parser->parse()) {

View File

@ -817,7 +817,7 @@ public:
~GzipBlockCompression() override = default;
Status decompress(const Slice& input, Slice* output) override {
z_stream z_strm = {nullptr};
z_stream z_strm = {};
z_strm.zalloc = Z_NULL;
z_strm.zfree = Z_NULL;
z_strm.opaque = Z_NULL;

View File

@ -235,9 +235,6 @@ bool ForDecoder<T>::init() {
_last_frame_size = _max_frame_size - (_max_frame_size * _frame_count - _values_num);
size_t bit_width_offset = _buffer_len - 5 - _frame_count * 2;
if (bit_width_offset < 0) {
return false;
}
// read _storage_formats, bit_widths and compute frame_offsets
u_int32_t frame_start_offset = 0;
@ -398,7 +395,7 @@ bool ForDecoder<T>::get_batch(T* val, size_t count) {
template <typename T>
bool ForDecoder<T>::skip(int32_t skip_num) {
if (_current_index + skip_num >= _values_num || _current_index + skip_num < 0) {
if (_current_index + skip_num >= _values_num) {
return false;
}
_current_index = _current_index + skip_num;

View File

@ -66,12 +66,15 @@ Status PprofUtils::get_self_cmdline(std::string* cmd) {
return Status::InternalError("Unable to open file: /proc/self/cmdline");
}
char buf[1024];
// Ignore unused return value
if (fscanf(fp, "%1023s ", buf))
;
Status res = Status::OK();
if (fscanf(fp, "%1023s ", buf) != 1) {
res = Status::InternalError("get_self_cmdline read buffer failed");
}
fclose(fp);
*cmd = buf;
return Status::OK();
return res;
}
Status PprofUtils::get_readable_profile(const std::string& file_or_content, bool is_file,

View File

@ -123,10 +123,6 @@ Status ZipFile::extract_file(const std::string& target_path) {
size_t size = 0;
do {
size = unzReadCurrentFile(_zip_file, (voidp)file_data.get(), file_size);
if (size < 0) {
return Status::IOError("unzip file {} failed", file_name);
}
RETURN_IF_ERROR(wfile->append(Slice(file_data.get(), size)));
} while (size > 0);

View File

@ -128,7 +128,7 @@ public:
LOG(FATAL) << fmt::format("Precision {} is out of bounds", precision);
}
if (UNLIKELY(scale < 0 || static_cast<UInt32>(scale) > max_precision())) {
if (UNLIKELY(static_cast<UInt32>(scale) > max_precision())) {
LOG(FATAL) << fmt::format("Scale {} is out of bounds", scale);
}
}

View File

@ -88,7 +88,7 @@ void NewPlainTextLineReader::close() {
inline bool NewPlainTextLineReader::update_eof() {
if (done()) {
_eof = true;
} else if (_decompressor == nullptr && (_min_length >= 0 && _total_read_bytes >= _min_length)) {
} else if (_decompressor == nullptr && (_total_read_bytes >= _min_length)) {
_eof = true;
}
return _eof;

View File

@ -81,7 +81,6 @@ struct HashTableProbe {
Status mark_data_in_hashtable(HashTableContext& hash_table_ctx) {
using KeyGetter = typename HashTableContext::State;
using Mapped = typename HashTableContext::Mapped;
KeyGetter key_getter(_probe_raw_ptrs, _operation_node->_probe_key_sz, nullptr);
if constexpr (ColumnsHashing::IsPreSerializedKeysHashMethodTraits<KeyGetter>::value) {

View File

@ -206,7 +206,6 @@ public:
auto call = [&](const auto& types) -> bool {
using Types = std::decay_t<decltype(types)>;
using T0 = typename Types::LeftType;
using T1 = typename Types::RightType;
using result_type = typename Types::LeftType;
// for doris, args type and return type must be sanme beacause of type cast has already done before, so here just need one type;

View File

@ -257,7 +257,6 @@ void VerticalMergeIteratorContext::copy_rows(Block* block, bool advanced) {
// copy a row to dst block column by column
size_t start = _index_in_block - _cur_batch_num + 1 - advanced;
DCHECK(start >= 0);
for (size_t i = 0; i < _ori_return_cols; ++i) {
auto& s_col = src.get_by_position(i);

View File

@ -138,7 +138,6 @@ void VMergeIteratorContext::copy_rows(Block* block, bool advanced) {
// copy a row to dst block column by column
size_t start = _index_in_block - _cur_batch_num + 1 - advanced;
DCHECK(start >= 0);
for (size_t i = 0; i < _num_columns; ++i) {
auto& s_col = src.get_by_position(i);
@ -159,7 +158,6 @@ void VMergeIteratorContext::copy_rows(BlockView* view, bool advanced) {
return;
}
size_t start = _index_in_block - _cur_batch_num + 1 - advanced;
DCHECK(start >= 0);
const auto& tmp_pre_ctx_same_bit = get_pre_ctx_same();
for (size_t i = 0; i < _cur_batch_num; ++i) {

View File

@ -311,7 +311,6 @@ void test_replace() {
template <FieldType field_type>
void test_replace_string() {
using CppType = typename CppTypeTraits<field_type>::CppType;
constexpr size_t string_field_size = sizeof(bool) + sizeof(Slice);
char dst[string_field_size];

View File

@ -51,7 +51,7 @@ uint64_t str_to_datetime_v2(std::string datetime_str, std::string datetime_forma
size_t type_index_to_data_type(const std::vector<AnyType>& input_types, size_t index,
ut_type::UTDataTypeDesc& ut_desc, DataTypePtr& type) {
doris_udf::FunctionContext::TypeDesc& desc = ut_desc.type_desc;
if (index < 0 || index >= input_types.size()) {
if (index >= input_types.size()) {
return -1;
}

View File

@ -389,7 +389,6 @@ void test_arrow_to_decimal_column(std::shared_ptr<arrow::Decimal128Type> type,
template <bool is_nullable>
void test_decimalv2(std::shared_ptr<arrow::Decimal128Type> type,
const std::vector<std::string>& test_cases, size_t num_elements) {
using ArrowCppType = typename arrow::TypeTraits<arrow::Decimal128Type>::CType;
size_t counter = 0;
auto pt = arrow_type_to_primitive_type(type->id());
ASSERT_NE(pt, INVALID_TYPE);