Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy: modernize-use-default-member-init #7745

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ WarningsAsErrors: 'abseil-duration-*,
modernize-make-shared,
modernize-make-unique,
modernize-return-braced-init-list,
modernize-use-default-member-init,
modernize-use-equals-default,
modernize-use-override,
modernize-use-using,
Expand Down
5 changes: 2 additions & 3 deletions source/common/filesystem/posix/directory_iterator_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ namespace Filesystem {
class DirectoryIteratorImpl : public DirectoryIterator {
public:
DirectoryIteratorImpl(const std::string& directory_path);
DirectoryIteratorImpl()
: directory_path_(""), dir_(nullptr), os_sys_calls_(Api::OsSysCallsSingleton::get()) {}
DirectoryIteratorImpl() : directory_path_(""), os_sys_calls_(Api::OsSysCallsSingleton::get()) {}

~DirectoryIteratorImpl() override;

Expand All @@ -32,7 +31,7 @@ class DirectoryIteratorImpl : public DirectoryIterator {
FileType fileType(const std::string& name) const;

std::string directory_path_;
DIR* dir_;
DIR* dir_{nullptr};
Api::OsSysCallsImpl& os_sys_calls_;
};

Expand Down
4 changes: 2 additions & 2 deletions source/common/grpc/google_async_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ class GoogleAsyncStreamImpl : public RawAsyncStream,
struct PendingMessage {
PendingMessage(Buffer::InstancePtr request, bool end_stream);
// End-of-stream with no additional message.
PendingMessage() : end_stream_(true) {}
PendingMessage() = default;

const absl::optional<grpc::ByteBuffer> buf_;
const bool end_stream_;
const bool end_stream_{true};
};

GoogleAsyncTag init_tag_{*this, GoogleAsyncTag::Operation::Init};
Expand Down
2 changes: 1 addition & 1 deletion source/common/signal/signal_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SignalAction : NonCopyable {
public:
SignalAction()
: guard_size_(sysconf(_SC_PAGE_SIZE)),
altstack_size_(std::max(guard_size_ * 4, static_cast<size_t>(MINSIGSTKSZ))), altstack_() {
altstack_size_(std::max(guard_size_ * 4, static_cast<size_t>(MINSIGSTKSZ))) {
mapAndProtectStackMemory();
installSigHandlers();
}
Expand Down
4 changes: 2 additions & 2 deletions source/common/stats/stats_matcher_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class StatsMatcherImpl : public StatsMatcher {
explicit StatsMatcherImpl(const envoy::config::metrics::v2::StatsConfig& config);

// Default constructor simply allows everything.
StatsMatcherImpl() : is_inclusive_(true) {}
StatsMatcherImpl() = default;

// StatsMatcher
bool rejects(const std::string& name) const override;
Expand All @@ -31,7 +31,7 @@ class StatsMatcherImpl : public StatsMatcher {
private:
// Bool indicating whether or not the StatsMatcher is including or excluding stats by default. See
// StatsMatcherImpl::rejects() for much more detail.
bool is_inclusive_;
bool is_inclusive_{true};

std::vector<Matchers::StringMatcher> matchers_;
};
Expand Down
4 changes: 2 additions & 2 deletions source/common/stats/symbol_table_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class StatName {
explicit StatName(const SymbolTable::Storage size_and_data) : size_and_data_(size_and_data) {}

// Constructs an empty StatName object.
StatName() : size_and_data_(nullptr) {}
StatName() = default;

// Constructs a StatName object with new storage, which must be of size
// src.size(). This is used in the a flow where we first construct a StatName
Expand Down Expand Up @@ -365,7 +365,7 @@ class StatName {
bool empty() const { return size_and_data_ == nullptr || dataSize() == 0; }

private:
const uint8_t* size_and_data_;
const uint8_t* size_and_data_{nullptr};
};

StatName StatNameStorage::statName() const { return StatName(bytes_.get()); }
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/filters/network/kafka/serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ template <typename T> class Deserializer {
*/
template <typename T> class IntDeserializer : public Deserializer<T> {
public:
IntDeserializer() : written_{0}, ready_(false){};
IntDeserializer() : written_{0} {};

uint32_t feed(absl::string_view& data) override {
const uint32_t available = std::min<uint32_t>(sizeof(buf_) - written_, data.size());
Expand Down
12 changes: 6 additions & 6 deletions source/extensions/tracers/zipkin/span_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SpanContext {
/**
* Default constructor. Creates an empty context.
*/
SpanContext() : trace_id_high_(0), trace_id_(0), id_(0), parent_id_(0), sampled_(false) {}
SpanContext() = default;

/**
* Constructor that creates a context object from the supplied trace, span and
Expand Down Expand Up @@ -75,11 +75,11 @@ class SpanContext {
bool sampled() const { return sampled_; }

private:
const uint64_t trace_id_high_;
const uint64_t trace_id_;
const uint64_t id_;
const uint64_t parent_id_;
const bool sampled_;
const uint64_t trace_id_high_{0};
const uint64_t trace_id_{0};
const uint64_t id_{0};
const uint64_t parent_id_{0};
const bool sampled_{false};
};

} // namespace Zipkin
Expand Down
4 changes: 2 additions & 2 deletions source/extensions/tracers/zipkin/zipkin_core_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Annotation : public ZipkinBase {
/**
* Default constructor. Creates an empty annotation.
*/
Annotation() : timestamp_(0) {}
Annotation() = default;

/**
* Constructor that creates an annotation based on the given parameters.
Expand Down Expand Up @@ -187,7 +187,7 @@ class Annotation : public ZipkinBase {
const std::string toJson() override;

private:
uint64_t timestamp_;
uint64_t timestamp_{0};
std::string value_;
absl::optional<Endpoint> endpoint_;
};
Expand Down
6 changes: 3 additions & 3 deletions test/common/common/lock_guard_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace Thread {

class ThreadTest : public testing::Test {
protected:
ThreadTest() : a_(0), b_(0) {}
int a_ GUARDED_BY(a_mutex_);
ThreadTest() = default;
int a_ GUARDED_BY(a_mutex_){0};
MutexBasicLockable a_mutex_;
int b_;
int b_{0};
};

TEST_F(ThreadTest, TestLockGuard) {
Expand Down
6 changes: 2 additions & 4 deletions test/common/event/dispatcher_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ TEST(DeferredDeleteTest, DeferredDelete) {

class DispatcherImplTest : public testing::Test {
protected:
DispatcherImplTest()
: api_(Api::createApiForTest()), dispatcher_(api_->allocateDispatcher()),
work_finished_(false) {
DispatcherImplTest() : api_(Api::createApiForTest()), dispatcher_(api_->allocateDispatcher()) {
dispatcher_thread_ = api_->threadFactory().createThread([this]() {
// Must create a keepalive timer to keep the dispatcher from exiting.
std::chrono::milliseconds time_interval(500);
Expand All @@ -93,7 +91,7 @@ class DispatcherImplTest : public testing::Test {
Thread::MutexBasicLockable mu_;
Thread::CondVar cv_;

bool work_finished_;
bool work_finished_{false};
TimerPtr keepalive_timer_;
};

Expand Down
4 changes: 2 additions & 2 deletions test/common/upstream/eds_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ TEST_F(EdsTest, MalformedIP) {

class EdsAssignmentTimeoutTest : public EdsTest {
public:
EdsAssignmentTimeoutTest() : interval_timer_(nullptr) {
EdsAssignmentTimeoutTest() {
EXPECT_CALL(dispatcher_, createTimer_(_))
.WillOnce(Invoke([this](Event::TimerCb cb) {
timer_cb_ = cb;
Expand All @@ -1671,7 +1671,7 @@ class EdsAssignmentTimeoutTest : public EdsTest {
resetCluster();
}

Event::MockTimer* interval_timer_;
Event::MockTimer* interval_timer_{nullptr};
Event::TimerCb timer_cb_;
};

Expand Down
16 changes: 6 additions & 10 deletions test/exe/main_common_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ INSTANTIATE_TEST_SUITE_P(IpVersions, MainCommonTest,

class AdminRequestTest : public MainCommonTest {
protected:
AdminRequestTest()
: envoy_return_(false), envoy_started_(false), envoy_finished_(false),
pause_before_run_(false), pause_after_run_(false) {
addArg("--disable-hot-restart");
}
AdminRequestTest() { addArg("--disable-hot-restart"); }

// Runs an admin request specified in path, blocking until completion, and
// returning the response body.
Expand Down Expand Up @@ -234,11 +230,11 @@ class AdminRequestTest : public MainCommonTest {
absl::Notification finished_;
absl::Notification resume_;
absl::Notification pause_point_;
bool envoy_return_;
bool envoy_started_;
bool envoy_finished_;
bool pause_before_run_;
bool pause_after_run_;
bool envoy_return_{false};
bool envoy_started_{false};
bool envoy_finished_{false};
bool pause_before_run_{false};
bool pause_after_run_{false};
};

TEST_P(AdminRequestTest, AdminRequestGetStatsAndQuit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Quic {

class TestDelegate : public quic::QuicAlarm::Delegate {
public:
TestDelegate() : fired_(false) {}
TestDelegate() = default;

// quic::QuicAlarm::Delegate
void OnAlarm() override { fired_ = true; }
Expand All @@ -25,7 +25,7 @@ class TestDelegate : public quic::QuicAlarm::Delegate {
void set_fired(bool fired) { fired_ = fired; }

private:
bool fired_;
bool fired_{false};
};

class EnvoyQuicAlarmTest : public ::testing::Test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace quic {
// destruction(or StopCapturingLogs()).
class QuicEnvoyMockLog : public QuicLogSink {
public:
QuicEnvoyMockLog() : is_capturing_(false) {}
QuicEnvoyMockLog() = default;

~QuicEnvoyMockLog() override {
if (is_capturing_) {
Expand All @@ -43,7 +43,7 @@ class QuicEnvoyMockLog : public QuicLogSink {

private:
QuicLogSink* original_sink_;
bool is_capturing_;
bool is_capturing_{false};
};

// ScopedDisableExitOnDFatal is used to disable exiting the program when we encounter a
Expand Down
4 changes: 2 additions & 2 deletions test/integration/sds_dynamic_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ TEST_P(SdsDynamicDownstreamIntegrationTest, WrongSecretFirst) {

class SdsDynamicDownstreamCertValidationContextTest : public SdsDynamicDownstreamIntegrationTest {
public:
SdsDynamicDownstreamCertValidationContextTest() : use_combined_validation_context_(false) {}
SdsDynamicDownstreamCertValidationContextTest() = default;

void initialize() override {
config_helper_.addConfigModifier([this](envoy::config::bootstrap::v2::Bootstrap& bootstrap) {
Expand Down Expand Up @@ -285,7 +285,7 @@ class SdsDynamicDownstreamCertValidationContextTest : public SdsDynamicDownstrea
void enableCombinedValidationContext(bool enable) { use_combined_validation_context_ = enable; }

private:
bool use_combined_validation_context_;
bool use_combined_validation_context_{false};
};

INSTANTIATE_TEST_SUITE_P(IpVersionsClientType, SdsDynamicDownstreamCertValidationContextTest,
Expand Down
4 changes: 2 additions & 2 deletions test/tools/router_check/router.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Envoy {
* input file.
*/
struct ToolConfig {
ToolConfig() : random_value_(0){};
ToolConfig() = default;

/**
* @param check_config tool config json object pointer.
Expand All @@ -49,7 +49,7 @@ struct ToolConfig {

std::unique_ptr<Http::TestHeaderMapImpl> headers_;
Router::RouteConstSharedPtr route_;
int random_value_;
int random_value_{0};

private:
ToolConfig(std::unique_ptr<Http::TestHeaderMapImpl> headers, int random_value);
Expand Down