From 76cc84f8d9611ca61280792ea866b7d2be11f94c Mon Sep 17 00:00:00 2001 From: Andrei Pavel Date: Tue, 10 Aug 2021 16:19:41 +0300 Subject: [PATCH] [#2025] simplify concatenating strings (minor) --- src/bin/dhcp4/tests/dhcp4_test_utils.cc | 2 +- src/bin/dhcp6/tests/dhcp6_test_utils.cc | 2 +- .../high_availability/tests/ha_service_unittest.cc | 2 +- src/lib/asiolink/tests/interval_timer_unittest.cc | 2 +- src/lib/cql/testutils/cql_schema.cc | 2 +- src/lib/dhcp/option6_client_fqdn.cc | 4 ++-- src/lib/dhcp/pkt_filter_lpf.cc | 4 ++-- src/lib/dhcpsrv/parsers/base_network_parser.cc | 8 ++++---- src/lib/dhcpsrv/parsers/dhcp_parsers.cc | 10 +++++----- src/lib/dhcpsrv/tests/alloc_engine_utils.cc | 4 ++-- src/lib/dhcpsrv/tests/srv_config_unittest.cc | 4 ++-- src/lib/dns/tests/master_loader_unittest.cc | 5 +++-- src/lib/hooks/hooks_config.cc | 4 ++-- src/lib/mysql/testutils/mysql_schema.cc | 2 +- src/lib/pgsql/pgsql_connection.cc | 4 ++-- 15 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.cc b/src/bin/dhcp4/tests/dhcp4_test_utils.cc index 1ae11ad888..c16df94e3a 100644 --- a/src/bin/dhcp4/tests/dhcp4_test_utils.cc +++ b/src/bin/dhcp4/tests/dhcp4_test_utils.cc @@ -46,7 +46,7 @@ BaseServerTest::BaseServerTest() BaseServerTest::~BaseServerTest() { // Remove default lease file. std::ostringstream s2; - s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases4.csv"; + s2 << CfgMgr::instance().getDataDir() << "/kea-leases4.csv"; static_cast(::remove(s2.str().c_str())); // Revert to original data directory. diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.cc b/src/bin/dhcp6/tests/dhcp6_test_utils.cc index 7c132a7567..670a65edbb 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.cc +++ b/src/bin/dhcp6/tests/dhcp6_test_utils.cc @@ -44,7 +44,7 @@ BaseServerTest::~BaseServerTest() { // Remove default lease file. std::ostringstream s2; - s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases6.csv"; + s2 << CfgMgr::instance().getDataDir() << "/kea-leases6.csv"; static_cast(::remove(s2.str().c_str())); // Revert to original data directory. diff --git a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc index 99588dd8cf..23f6655c2f 100644 --- a/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc +++ b/src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc @@ -5010,7 +5010,7 @@ public: EXPECT_EQ(final_state.state_, service_->getCurrState()) << "expected transition to the '" << service_->getStateLabel(final_state.state_) - << "' state" << ", but transitioned to the '" + << "' state, but transitioned to the '" << service_->getStateLabel(service_->getCurrState()) << "' state"; } diff --git a/src/lib/asiolink/tests/interval_timer_unittest.cc b/src/lib/asiolink/tests/interval_timer_unittest.cc index 95dfaf7f31..5b21b77848 100644 --- a/src/lib/asiolink/tests/interval_timer_unittest.cc +++ b/src/lib/asiolink/tests/interval_timer_unittest.cc @@ -184,7 +184,7 @@ TEST_F(IntervalTimerTest, startIntervalTimer) { // Allow 1% of clock skew EXPECT_TRUE(test_runtime >= boost::posix_time::milliseconds(99)) << "test runtime " << test_runtime.total_milliseconds() << - "msec " << ">= 100"; + "msec >= 100"; } TEST_F(IntervalTimerTest, destructIntervalTimer) { diff --git a/src/lib/cql/testutils/cql_schema.cc b/src/lib/cql/testutils/cql_schema.cc index ca4b244f08..dc525ec87b 100644 --- a/src/lib/cql/testutils/cql_schema.cc +++ b/src/lib/cql/testutils/cql_schema.cc @@ -80,7 +80,7 @@ bool wipeCqlData(bool show_err) { std::ostringstream version; version << CQL_SCHEMA_VERSION_MAJOR << "." << CQL_SCHEMA_VERSION_MINOR; - cmd << "cql/wipe_data.sh" << " " << version.str() + cmd << "cql/wipe_data.sh " << version.str() << " -u keatest -p keatest -k keatest --request-timeout=6000"; if (!show_err) { diff --git a/src/lib/dhcp/option6_client_fqdn.cc b/src/lib/dhcp/option6_client_fqdn.cc index 65b0c1b6ec..f1ed563b6a 100644 --- a/src/lib/dhcp/option6_client_fqdn.cc +++ b/src/lib/dhcp/option6_client_fqdn.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2021 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -427,7 +427,7 @@ std::string Option6ClientFqdn::toText(int indent) const { std::ostringstream stream; std::string in(indent, ' '); // base indentation - stream << in << "type=" << type_ << "(CLIENT_FQDN)" << ", " + stream << in << "type=" << type_ << "(CLIENT_FQDN), " << "flags: (" << "N=" << (getFlag(FLAG_N) ? "1" : "0") << ", " << "O=" << (getFlag(FLAG_O) ? "1" : "0") << ", " diff --git a/src/lib/dhcp/pkt_filter_lpf.cc b/src/lib/dhcp/pkt_filter_lpf.cc index ca700c47cf..791e8635d2 100644 --- a/src/lib/dhcp/pkt_filter_lpf.cc +++ b/src/lib/dhcp/pkt_filter_lpf.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2021 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -206,7 +206,7 @@ PktFilterLPF::openSocket(Iface& iface, close(fallback); isc_throw(SocketConfigError, "failed to set SO_NONBLOCK option on the" " LPF socket '" << sock << "' to interface '" - << iface.getName() << "'" << ", reason: " << errmsg); + << iface.getName() << "', reason: " << errmsg); } return (SocketInfo(addr, port, sock, fallback)); diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.cc b/src/lib/dhcpsrv/parsers/base_network_parser.cc index 8441c70174..88f5886169 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/base_network_parser.cc @@ -62,7 +62,7 @@ BaseNetworkParser::parseCommon(const ConstElementPtr& network_data, if (has_renew) { renew = getInteger(network_data, "renew-timer"); if (renew < 0) { - isc_throw(DhcpConfigError, "the value of renew-timer" << " (" + isc_throw(DhcpConfigError, "the value of renew-timer (" << renew << ") must be a positive number"); } network->setT1(renew); @@ -71,15 +71,15 @@ BaseNetworkParser::parseCommon(const ConstElementPtr& network_data, if (has_rebind) { rebind = getInteger(network_data, "rebind-timer"); if (rebind < 0) { - isc_throw(DhcpConfigError, "the value of rebind-timer" << " (" + isc_throw(DhcpConfigError, "the value of rebind-timer (" << rebind << ") must be a positive number"); } network->setT2(rebind); } if (has_renew && has_rebind && (renew > rebind)) { - isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew - << ") is greater than the value of rebind-timer" << " (" + isc_throw(DhcpConfigError, "the value of renew-timer (" << renew + << ") is greater than the value of rebind-timer (" << rebind << ")"); } diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc index 36903d6895..5e0bcc8a45 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc @@ -199,7 +199,7 @@ OptionDefParser::parse(ConstElementPtr option_def) { // Arrays can't be used together with sub-options. if (array_type) { isc_throw(DhcpConfigError, "option '" << space << "." - << "name" << "', comprising an array of data" + << name << "', comprising an array of data" << " fields may not encapsulate any option space (" << option_def->getPosition() << ")"); @@ -770,8 +770,8 @@ Subnet4ConfigParser::initSubnet(data::ConstElementPtr params, } if (has_renew && has_rebind && (renew > rebind)) { - isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew - << ") is greater than the value of rebind-timer" << " (" + isc_throw(DhcpConfigError, "the value of renew-timer (" << renew + << ") is greater than the value of rebind-timer (" << rebind << ")"); } @@ -1272,8 +1272,8 @@ Subnet6ConfigParser::initSubnet(data::ConstElementPtr params, } if (has_renew && has_rebind && (renew > rebind)) { - isc_throw(DhcpConfigError, "the value of renew-timer" << " (" << renew - << ") is greater than the value of rebind-timer" << " (" + isc_throw(DhcpConfigError, "the value of renew-timer (" << renew + << ") is greater than the value of rebind-timer (" << rebind << ")"); } diff --git a/src/lib/dhcpsrv/tests/alloc_engine_utils.cc b/src/lib/dhcpsrv/tests/alloc_engine_utils.cc index 2ca911578e..daa85e574b 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine_utils.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine_utils.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2021 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -49,7 +49,7 @@ bool testStatistics(const std::string& stat_name, const int64_t exp_value, if (observation->getInteger().first != exp_value) { ADD_FAILURE() << "value of the observed statistics '" - << name << "' " << "(" + << name << "' (" << observation->getInteger().first << ") " << "doesn't match expected value (" << exp_value << ")"; } diff --git a/src/lib/dhcpsrv/tests/srv_config_unittest.cc b/src/lib/dhcpsrv/tests/srv_config_unittest.cc index b4cac7d43d..7c2663f79f 100644 --- a/src/lib/dhcpsrv/tests/srv_config_unittest.cc +++ b/src/lib/dhcpsrv/tests/srv_config_unittest.cc @@ -142,7 +142,7 @@ void SrvConfigTest::addSubnet4(const unsigned int index) { if (index >= TEST_SUBNETS_NUM) { FAIL() << "Subnet index " << index << "out of range (0.." - << TEST_SUBNETS_NUM << "): " << "unable to add IPv4 subnet"; + << TEST_SUBNETS_NUM << "): unable to add IPv4 subnet"; } // std::advance is not available for this iterator. auto it = test_subnets4_.begin(); @@ -156,7 +156,7 @@ void SrvConfigTest::addSubnet6(const unsigned int index) { if (index >= TEST_SUBNETS_NUM) { FAIL() << "Subnet index " << index << "out of range (0.." - << TEST_SUBNETS_NUM << "): " << "unable to add IPv6 subnet"; + << TEST_SUBNETS_NUM << "): unable to add IPv6 subnet"; } // std::advance is not available for this iterator. auto it = test_subnets6_.begin(); diff --git a/src/lib/dns/tests/master_loader_unittest.cc b/src/lib/dns/tests/master_loader_unittest.cc index 544e48e131..74300d3171 100644 --- a/src/lib/dns/tests/master_loader_unittest.cc +++ b/src/lib/dns/tests/master_loader_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2021 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -1317,7 +1317,8 @@ TEST_F(MasterLoaderTest, ttlOverflow) { stringstream zone_stream; zone_stream << "example.org. IN SOA . . 0 0 0 0 2147483648\n"; zone_stream << "$TTL 3600\n"; // reset to an in-range value - zone_stream << "$TTL 2147483649\n" << "a.example.org. IN A 192.0.2.1\n"; + zone_stream << "$TTL 2147483649\n"; + zone_stream << "a.example.org. IN A 192.0.2.1\n"; zone_stream << "$TTL 3600\n"; // reset to an in-range value zone_stream << "b.example.org. 2147483650 IN A 192.0.2.2\n"; setLoader(zone_stream, Name("example.org."), RRClass::IN(), diff --git a/src/lib/hooks/hooks_config.cc b/src/lib/hooks/hooks_config.cc index ce0e268561..c6bf9a2268 100644 --- a/src/lib/hooks/hooks_config.cc +++ b/src/lib/hooks/hooks_config.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2021 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -47,7 +47,7 @@ HooksConfig::verifyLibraries(const Element::Position& position) const { isc_throw(InvalidHooksLibraries, "hooks libraries failed to validate - " "library or libraries in error are: " - << error_list << "(" << position << ")"); + << error_list << " (" << position << ")"); } } diff --git a/src/lib/mysql/testutils/mysql_schema.cc b/src/lib/mysql/testutils/mysql_schema.cc index d75b43d922..ddded67fdc 100644 --- a/src/lib/mysql/testutils/mysql_schema.cc +++ b/src/lib/mysql/testutils/mysql_schema.cc @@ -52,7 +52,7 @@ bool wipeMySQLData(bool show_err) { std::ostringstream version; version << MYSQL_SCHEMA_VERSION_MAJOR << "." << MYSQL_SCHEMA_VERSION_MINOR; - cmd << "mysql/wipe_data.sh" << " " << version.str() + cmd << "mysql/wipe_data.sh " << version.str() << " -N -B --user=keatest --password=keatest keatest"; if (!show_err) { cmd << " 2>/dev/null "; diff --git a/src/lib/pgsql/pgsql_connection.cc b/src/lib/pgsql/pgsql_connection.cc index b3b48bdb2a..046e4d928a 100644 --- a/src/lib/pgsql/pgsql_connection.cc +++ b/src/lib/pgsql/pgsql_connection.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2020 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2021 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -349,7 +349,7 @@ PgSqlConnection::checkStatementError(const PgSqlResult& r, // Apparently it wasn't fatal, so we throw with a helpful message. const char* error_message = PQerrorMessage(conn_); - isc_throw(DbOperationError, "Statement exec failed:" << " for: " + isc_throw(DbOperationError, "Statement exec failed for: " << statement.name << ", status: " << s << "sqlstate:[ " << (sqlstate ? sqlstate : "") << " ], reason: " << error_message);