Skip to content

Commit

Permalink
[refactor] fix warings when compile with clang (#8069)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzhg authored Feb 19, 2022
1 parent 8892780 commit 50864ac
Show file tree
Hide file tree
Showing 200 changed files with 1,753 additions and 2,620 deletions.
96 changes: 1 addition & 95 deletions be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,12 @@ check_function_exists(sched_getcpu HAVE_SCHED_GETCPU)
# -Wall: Enable all warnings.
# -Wno-sign-compare: suppress warnings for comparison between signed and unsigned
# integers
# -Wno-unknown-pragmas: suppress warnings for unknown (compiler specific) pragmas
# -Wno-deprecated: gutil contains deprecated headers
# -Wno-vla: we use C99-style variable-length arrays
# -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 -Wno-unknown-pragmas -pthread -Werror")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wall -Wno-sign-compare -pthread -Werror")
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} -Wno-deprecated -Wno-vla")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG")
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DBOOST_SYSTEM_NO_DEPRECATED")
# Enable the cpu and heap profile of brpc
Expand Down Expand Up @@ -364,96 +360,6 @@ if (COMPILER_CLANG)
if(MAKE_TEST STREQUAL "OFF")
add_compile_options(-Qunused-arguments)
endif()

# TODO: Fix all these warnings
add_compile_options(
-Wno-address-of-packed-member
-Wno-ambiguous-reversed-operator
-Wno-atomic-implicit-seq-cst
-Wno-cast-align
-Wno-cast-qual
-Wno-comma
-Wno-conditional-uninitialized
-Wno-constant-conversion
-Wno-covered-switch-default
-Wno-delete-abstract-non-virtual-dtor
-Wno-delete-non-abstract-non-virtual-dtor
-Wno-deprecated
-Wno-deprecated-copy-with-dtor
-Wno-deprecated-copy-with-user-provided-copy
-Wno-deprecated-copy-with-user-provided-dtor
-Wno-deprecated-declarations
-Wno-deprecated-this-capture
-Wno-documentation
-Wno-embedded-directive
-Wno-enum-compare-switch
-Wno-extra-semi
-Wno-extra-semi-stmt
-Wno-format-nonliteral
-Wno-frame-larger-than
-Wno-gnu-label-as-value
-Wno-gnu-redeclared-enum
-Wno-gnu-statement-expression
-Wno-gnu-zero-variadic-macro-arguments
-Wno-header-hygiene
-Wno-ignored-qualifiers
-Wno-implicit-const-int-float-conversion
-Wno-implicit-exception-spec-mismatch
-Wno-implicit-fallthrough
-Wno-inconsistent-missing-destructor-override
-Wno-inconsistent-missing-override
-Wno-instantiation-after-specialization
-Wno-macro-redefined
-Wno-mismatched-new-delete
-Wno-mismatched-tags
-Wno-missing-field-initializers
-Wno-missing-noreturn
-Wno-newline-eof
-Wno-non-virtual-dtor
-Wno-null-conversion
-Wno-null-dereference
-Wno-old-style-cast
-Wno-overloaded-virtual
-Wno-pedantic
-Wno-pessimizing-move
-Wno-pragma-once-outside-header
-Wno-reserved-identifier
-Wno-reserved-macro-identifier
-Wno-return-type
-Wno-shadow
-Wno-shadow-field
-Wno-shadow-field-in-constructor
-Wno-shadow-uncaptured-local
-Wno-shift-count-overflow
-Wno-sign-compare
-Wno-string-plus-int
-Wno-suggest-destructor-override
-Wno-suggest-override
-Wno-tautological-constant-out-of-range-compare
-Wno-tautological-unsigned-zero-compare
-Wno-undef
-Wno-uninitialized
-Wno-unknown-pragmas
-Wno-unknown-warning-option
-Wno-unreachable-code
-Wno-unreachable-code-break
-Wno-unreachable-code-return
-Wno-unused-but-set-variable
-Wno-unused-const-variable
-Wno-unused-exception-parameter
-Wno-unused-function
-Wno-unused-lambda-capture
-Wno-unused-local-typedef
-Wno-unused-macros
-Wno-unused-member-function
-Wno-unused-parameter
-Wno-unused-private-field
-Wno-unused-result
-Wno-unused-value
-Wno-unused-variable
-Wno-variadic-macros
-Wno-zero-as-null-pointer-constant
)
endif ()

# https://github.com/boostorg/uuid/issues/92
Expand Down
5 changes: 1 addition & 4 deletions be/src/agent/cgroups_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ std::map<TResourceType::type, std::string> CgroupsMgr::_s_resource_cgroups = {
{TResourceType::type::TRESOURCE_IO_SHARE, "blkio.weight"}};

CgroupsMgr::CgroupsMgr(ExecEnv* exec_env, const string& root_cgroups_path)
: _exec_env(exec_env),
_root_cgroups_path(root_cgroups_path),
_is_cgroups_init_success(false),
_cur_version(-1) {
: _root_cgroups_path(root_cgroups_path), _is_cgroups_init_success(false), _cur_version(-1) {
if (s_global_cg_mgr == nullptr) {
s_global_cg_mgr = this;
}
Expand Down
1 change: 0 additions & 1 deletion be/src/agent/cgroups_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ class CgroupsMgr {
const static std::string _s_system_group;

private:
ExecEnv* _exec_env;
std::string _root_cgroups_path;
int32_t _drop_retry_times = 10;
bool _is_cgroups_init_success;
Expand Down
21 changes: 11 additions & 10 deletions be/src/agent/task_worker_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ void TaskWorkerPool::start() {
break;
case TaskWorkerType::SUBMIT_TABLE_COMPACTION:
_worker_count = 1;
cb = std::bind<void>(&TaskWorkerPool::_submit_table_compaction_worker_thread_callback, this);
cb = std::bind<void>(&TaskWorkerPool::_submit_table_compaction_worker_thread_callback,
this);
break;
default:
// pass
Expand Down Expand Up @@ -298,8 +299,9 @@ void TaskWorkerPool::_finish_task(const TFinishTaskRequest& finish_task_request)
break;
} else {
DorisMetrics::instance()->finish_task_requests_failed->increment(1);
LOG(WARNING) << "finish task failed. type=" << to_string(finish_task_request.task_type) << ", signature="
<< finish_task_request.signature << ", status_code=" << result.status.status_code;
LOG(WARNING) << "finish task failed. type=" << to_string(finish_task_request.task_type)
<< ", signature=" << finish_task_request.signature
<< ", status_code=" << result.status.status_code;
try_time += 1;
}
sleep(config::sleep_one_second);
Expand Down Expand Up @@ -534,8 +536,7 @@ void TaskWorkerPool::_alter_tablet(const TAgentTaskRequest& agent_task_req, int6
if (status == DORIS_SUCCESS) {
new_tablet_id = agent_task_req.alter_tablet_req_v2.new_tablet_id;
new_schema_hash = agent_task_req.alter_tablet_req_v2.new_schema_hash;
EngineAlterTabletTask engine_task(agent_task_req.alter_tablet_req_v2, signature, task_type,
&error_msgs, process_name);
EngineAlterTabletTask engine_task(agent_task_req.alter_tablet_req_v2);
OLAPStatus sc_status = _env->storage_engine()->execute_task(&engine_task);
if (sc_status != OLAP_SUCCESS) {
if (sc_status == OLAP_ERR_DATA_QUALITY_ERR) {
Expand Down Expand Up @@ -1072,9 +1073,9 @@ void TaskWorkerPool::_check_consistency_worker_thread_callback() {
TStatus task_status;

uint32_t checksum = 0;
EngineChecksumTask engine_task(
check_consistency_req.tablet_id, check_consistency_req.schema_hash,
check_consistency_req.version, &checksum);
EngineChecksumTask engine_task(check_consistency_req.tablet_id,
check_consistency_req.schema_hash,
check_consistency_req.version, &checksum);
OLAPStatus res = _env->storage_engine()->execute_task(&engine_task);
if (res != OLAP_SUCCESS) {
LOG(WARNING) << "check consistency failed. status: " << res
Expand Down Expand Up @@ -1690,8 +1691,8 @@ void TaskWorkerPool::_submit_table_compaction_worker_thread_callback() {
continue;
}

Status status = StorageEngine::instance()->submit_compaction_task(
tablet_ptr, compaction_type);
Status status =
StorageEngine::instance()->submit_compaction_task(tablet_ptr, compaction_type);
if (!status.ok()) {
LOG(WARNING) << "failed to submit table compaction task. " << status.to_string();
}
Expand Down
5 changes: 1 addition & 4 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ CONF_mInt32(tablet_rowset_stale_sweep_time_sec, "1800");
CONF_Int32(max_garbage_sweep_interval, "3600");
CONF_Int32(min_garbage_sweep_interval, "180");
CONF_mInt32(snapshot_expire_time_sec, "172800");
// It is only a recommended value. When the disk space is insufficient,
// It is only a recommended value. When the disk space is insufficient,
// the file storage period under trash dose not have to comply with this parameter.
CONF_mInt32(trash_file_expire_time_sec, "259200");
// check row nums for BE/CE and schema change. true is open, false is closed.
Expand Down Expand Up @@ -409,9 +409,6 @@ CONF_Bool(enable_quadratic_probing, "false");
// for pprof
CONF_String(pprof_profile_dir, "${DORIS_HOME}/log");

// for partition
CONF_Bool(enable_partitioned_aggregation, "true");

// to forward compatibility, will be removed later
CONF_mBool(enable_token_check, "true");

Expand Down
2 changes: 1 addition & 1 deletion be/src/common/daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

namespace doris {

class StorePath;
struct StorePath;
class Thread;

class Daemon {
Expand Down
3 changes: 3 additions & 0 deletions be/src/common/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,8 @@ class Status {
} \
} while (false);
} // namespace doris
#ifdef WARN_UNUSED_RESULT
#undef WARN_UNUSED_RESULT
#endif

#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
12 changes: 6 additions & 6 deletions be/src/env/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <string>

#include "common/status.h"
#include "util/slice.h"
#include "gen_cpp/Types_types.h"
#include "util/slice.h"

namespace doris {

Expand Down Expand Up @@ -176,7 +176,8 @@ class Env {
virtual Status link_file(const std::string& /*old_path*/, const std::string& /*new_path*/) = 0;

// get space info for local and remote system
virtual Status get_space_info(const std::string& path, int64_t* capacity, int64_t* available) = 0;
virtual Status get_space_info(const std::string& path, int64_t* capacity,
int64_t* available) = 0;

virtual bool is_remote_env() = 0;

Expand All @@ -198,9 +199,7 @@ class Env {
};

struct FilePathDesc {
FilePathDesc(const std::string& path) {
filepath = path;
}
FilePathDesc(const std::string& path) { filepath = path; }
FilePathDesc() {}
TStorageMedium::type storage_medium = TStorageMedium::HDD;
std::string filepath;
Expand Down Expand Up @@ -268,6 +267,7 @@ class FilePathDescStream {
}
return path_desc;
}

private:
TStorageMedium::type _storage_medium = TStorageMedium::HDD;
std::stringstream _filepath_stream;
Expand Down Expand Up @@ -424,7 +424,7 @@ class RandomRWFile {
RandomRWFile() {}
virtual ~RandomRWFile() {}

virtual Status read_at(uint64_t offset, const Slice* result) const = 0;
virtual Status read_at(uint64_t offset, const Slice& result) const = 0;

virtual Status readv_at(uint64_t offset, const Slice* res, size_t res_cnt) const = 0;

Expand Down
36 changes: 18 additions & 18 deletions be/src/env/env_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.

#include "env/env_posix.h"

#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
Expand All @@ -23,13 +25,12 @@
#include <sys/uio.h>
#include <unistd.h>

#include <memory>
#include <filesystem>
#include <fstream>
#include <memory>

#include "common/logging.h"
#include "env/env.h"
#include "env/env_posix.h"
#include "gutil/gscoped_ptr.h"
#include "gutil/macros.h"
#include "gutil/port.h"
Expand Down Expand Up @@ -288,10 +289,9 @@ class PosixRandomAccessFile : public RandomAccessFile {
Status read_all(std::string* content) const override {
std::fstream fs(_filename.c_str(), std::fstream::in);
if (!fs.is_open()) {
RETURN_NOT_OK_STATUS_WITH_WARN(
Status::IOError(
strings::Substitute("failed to open cluster id file $0", _filename)),
"open file failed");
RETURN_NOT_OK_STATUS_WITH_WARN(Status::IOError(strings::Substitute(
"failed to open cluster id file $0", _filename)),
"open file failed");
}
std::string data;
fs >> data;
Expand All @@ -303,7 +303,8 @@ class PosixRandomAccessFile : public RandomAccessFile {
Status::Corruption(strings::Substitute(
"read_all from file $0 is corrupt. [eofbit=$1 failbit=$2 badbit=$3]",
_filename, fs.rdstate() & std::fstream::eofbit,
fs.rdstate() & std::fstream::failbit, fs.rdstate() & std::fstream::badbit)),
fs.rdstate() & std::fstream::failbit,
fs.rdstate() & std::fstream::badbit)),
"read_all is error");
}
return Status::OK();
Expand Down Expand Up @@ -449,8 +450,8 @@ class PosixRandomRWFile : public RandomRWFile {

~PosixRandomRWFile() { WARN_IF_ERROR(close(), "Failed to close " + _filename); }

Status read_at(uint64_t offset, const Slice* result) const override {
return readv_at(offset, result, 1);
Status read_at(uint64_t offset, const Slice& result) const override {
return readv_at(offset, &result, 1);
}

Status readv_at(uint64_t offset, const Slice* result, size_t res_cnt) const override {
Expand Down Expand Up @@ -531,8 +532,7 @@ Status PosixEnv::init_conf() {
return Status::OK();
}

Status PosixEnv::new_sequential_file(const string& fname,
std::unique_ptr<SequentialFile>* result) {
Status PosixEnv::new_sequential_file(const string& fname, std::unique_ptr<SequentialFile>* result) {
FILE* f;
POINTER_RETRY_ON_EINTR(f, fopen(fname.c_str(), "r"));
if (f == nullptr) {
Expand All @@ -544,12 +544,13 @@ Status PosixEnv::new_sequential_file(const string& fname,

// get a RandomAccessFile pointer without file cache
Status PosixEnv::new_random_access_file(const std::string& fname,
std::unique_ptr<RandomAccessFile>* result) {
std::unique_ptr<RandomAccessFile>* result) {
return new_random_access_file(RandomAccessFileOptions(), fname, result);
}

Status PosixEnv::new_random_access_file(const RandomAccessFileOptions& opts, const std::string& fname,
std::unique_ptr<RandomAccessFile>* result) {
Status PosixEnv::new_random_access_file(const RandomAccessFileOptions& opts,
const std::string& fname,
std::unique_ptr<RandomAccessFile>* result) {
int fd;
RETRY_ON_EINTR(fd, open(fname.c_str(), O_RDONLY));
if (fd < 0) {
Expand All @@ -564,7 +565,7 @@ Status PosixEnv::new_writable_file(const string& fname, std::unique_ptr<Writable
}

Status PosixEnv::new_writable_file(const WritableFileOptions& opts, const string& fname,
std::unique_ptr<WritableFile>* result) {
std::unique_ptr<WritableFile>* result) {
int fd;
RETURN_IF_ERROR(do_open(fname, opts.mode, &fd));

Expand All @@ -581,7 +582,7 @@ Status PosixEnv::new_random_rw_file(const string& fname, std::unique_ptr<RandomR
}

Status PosixEnv::new_random_rw_file(const RandomRWFileOptions& opts, const string& fname,
std::unique_ptr<RandomRWFile>* result) {
std::unique_ptr<RandomRWFile>* result) {
int fd;
RETURN_IF_ERROR(do_open(fname, opts.mode, &fd));
result->reset(new PosixRandomRWFile(fname, fd, opts.sync_on_close));
Expand Down Expand Up @@ -609,8 +610,7 @@ Status PosixEnv::get_children(const std::string& dir, std::vector<std::string>*
return Status::OK();
}

Status PosixEnv::iterate_dir(const std::string& dir,
const std::function<bool(const char*)>& cb) {
Status PosixEnv::iterate_dir(const std::string& dir, const std::function<bool(const char*)>& cb) {
DIR* d = opendir(dir.c_str());
if (d == nullptr) {
return io_error(dir, errno);
Expand Down
Loading

0 comments on commit 50864ac

Please sign in to comment.