From 6f672df326feb295621a1fe0218616099f9c64e1 Mon Sep 17 00:00:00 2001 From: JackyWoo Date: Thu, 28 Oct 2021 16:01:30 +0800 Subject: [PATCH] fix PVS check error --- src/Coordination/CoordinationSettings.cpp | 15 ++++++++++++--- src/Coordination/CoordinationSettings.h | 8 ++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Coordination/CoordinationSettings.cpp b/src/Coordination/CoordinationSettings.cpp index 949d0f71c5a..9b316dca5ab 100644 --- a/src/Coordination/CoordinationSettings.cpp +++ b/src/Coordination/CoordinationSettings.cpp @@ -34,6 +34,16 @@ void CoordinationSettings::loadFromConfig(const String & config_elem, const Poco } } +KeeperSettings::KeeperSettings() + : server_id(NOT_EXIST) + , tcp_port(NOT_EXIST) + , tcp_port_secure(NOT_EXIST) + , standalone_keeper(false) + , coordination_settings(std::make_shared()) +{ +} + + void KeeperSettings::dump(WriteBufferFromOwnString & buf) const { auto write = [&buf](const String & content) { buf.write(content.data(), content.size()); }; @@ -55,12 +65,12 @@ void KeeperSettings::dump(WriteBufferFromOwnString & buf) const write("server_id="); write_int(server_id); - if (tcp_port != NO_PORT) + if (tcp_port != NOT_EXIST) { write("tcp_port="); write_int(tcp_port); } - if (tcp_port_secure != NO_PORT) + if (tcp_port_secure != NOT_EXIST) { write("tcp_port_secure="); write_int(tcp_port_secure); @@ -162,7 +172,6 @@ KeeperSettings::loadFromConfig(const Poco::Util::AbstractConfiguration & config, ret->log_storage_path = getLogsPathFromConfig(config, standalone_keeper_); ret->snapshot_storage_path = getSnapshotsPathFromConfig(config, standalone_keeper_); - ret->coordination_settings = std::make_shared(); ret->coordination_settings->loadFromConfig("keeper_server.coordination_settings", config); return ret; diff --git a/src/Coordination/CoordinationSettings.h b/src/Coordination/CoordinationSettings.h index 9e3a281b0e1..74ca3744340 100644 --- a/src/Coordination/CoordinationSettings.h +++ b/src/Coordination/CoordinationSettings.h @@ -54,13 +54,13 @@ using CoordinationSettingsPtr = std::shared_ptr; struct KeeperSettings { - static constexpr int NO_PORT = -1; + static constexpr int NOT_EXIST = -1; - KeeperSettings() = default; + KeeperSettings(); int server_id; - int tcp_port{NO_PORT}; - int tcp_port_secure{NO_PORT}; + int tcp_port; + int tcp_port_secure; String super_digest;