Skip to content

Commit 3e4dedd

Browse files
committed
[#3256] fix common warnings across compilers
``` io_service_thread_pool_unittests.cc:24:12: warning: unused variable 'TEST_TIMEOUT' [-Wunused-const-variable] mysql_connection_unittest.cc:217:75: warning: declaration of ‘out_bindings’ shadows a previous local [-Wshadow] mysql_host_data_source.cc:171:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:202:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:220:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:254:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:422:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:554:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:579:30: warning: useless cast to type ‘isc::dhcp::SubnetID’ {aka ‘unsigned int’} [-Wuseless-cast] mysql_host_data_source.cc:586:30: warning: useless cast to type ‘isc::dhcp::SubnetID’ {aka ‘unsigned int’} [-Wuseless-cast] mysql_host_data_source.cc:674:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:714:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:1313:18: warning: 'processFetchedData' overrides a member function but is not marked 'override' [-Wsuggest-override] mysql_host_data_source.cc:1353:37: warning: 'createBindForReceive' overrides a member function but is not marked 'override' [-Wsuggest-override] mysql_host_data_source.cc:1371:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:1456:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:1487:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:1508:18: warning: 'processFetchedData' overrides a member function but is not marked 'override' [-Wsuggest-override] mysql_host_data_source.cc:1542:37: warning: 'createBindForReceive' overrides a member function but is not marked 'override' [-Wsuggest-override] mysql_host_data_source.cc:1583:6: warning: extra ';' after member function definition [-Wextra-semi] mysql_host_data_source.cc:1803:25: warning: unused variable 'OPTION_ID_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1804:25: warning: unused variable 'CODE_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1805:25: warning: unused variable 'VALUE_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1806:25: warning: unused variable 'FORMATTED_VALUE_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1807:25: warning: unused variable 'SPACE_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1808:25: warning: unused variable 'PERSISTENT_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1809:25: warning: unused variable 'CANCELLED_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1810:25: warning: unused variable 'USER_CONTEXT_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1811:25: warning: unused variable 'DHCP_SUBNET_ID_COL' [-Wunused-const-variable] mysql_host_data_source.cc:1812:25: warning: unused variable 'HOST_ID_COL' [-Wunused-const-variable] mysql_host_data_source.cc:3222:24: warning: useless cast to type ‘char*’ [-Wuseless-cast] mysql_host_data_source.cc:3385:24: warning: useless cast to type ‘char*’ [-Wuseless-cast] mysql_host_data_source.cc:3426:24: warning: useless cast to type ‘char*’ [-Wuseless-cast] mysql_lease_mgr.cc:89:14: warning: unused variable 'HOSTNAME_MAX_LEN' [-Wunused-const-variable] mysql_lease_mgr.cc:95:14: warning: unused variable 'ADDRESS6_TEXT_MAX_LEN' [-Wunused-const-variable] mysql_lease_mgr.cc:98:14: warning: unused variable 'USER_CONTEXT_MAX_LEN' [-Wunused-const-variable] mysql_lease_mgr.cc:544:29: warning: useless cast to type ‘isc::db::my_bool*’ {aka ‘bool*’} [-Wuseless-cast] mysql_lease_mgr.cc:1929:10: warning: 'start' overrides a member function but is not marked 'override' [-Wsuggest-override] mysql_lease_mgr.cc:2010:30: warning: useless cast to type ‘isc::dhcp::SubnetID’ {aka ‘unsigned int’} [-Wuseless-cast] mysql_lease_mgr.cc:2020:10: warning: 'getNextRow' overrides a member function but is not marked 'override' [-Wsuggest-override] mysql_lease_mgr.cc:3427:13: warning: useless cast to type ‘uint64_t’ {aka ‘long unsigned int’} [-Wuseless-cast] mysql_lease_mgr.cc:4114:23: warning: variable length arrays are a C99 feature [-Wvla-extension] mysql_lease_mgr.cc:4226:23: warning: variable length arrays are a C99 feature [-Wvla-extension] option_opaque_data_tuples_unittest.cc:533:32: warning: zero size arrays are an extension [-Wzero-length-array] option_opaque_data_tuples_unittest.cc:552:32: warning: zero size arrays are an extension [-Wzero-length-array] option_opaque_data_tuples_unittest.cc:572:32: warning: zero size arrays are an extension [-Wzero-length-array] tcp_connection.cc:28:14: warning: unused variable 'MAX_LOGGED_MESSAGE_SIZE' [-Wunused-const-variable] test_control.cc:1826:23: warning: useless cast to type ‘class isc::asiolink::IOAddress’ [-Wuseless-cast] test_control.cc:1830:24: warning: useless cast to type ‘class isc::asiolink::IOAddress’ [-Wuseless-cast] test_control.cc:1871:34: warning: useless cast to type ‘class isc::asiolink::IOAddress’ [-Wuseless-cast] test_control.cc:1873:30: warning: useless cast to type ‘class isc::asiolink::IOAddress’ [-Wuseless-cast] ../../../src/lib/http/http_message_parser_base.h:26:45: warning: extra ‘;’ after in-class function definition [-Wextra-semi] ../../../src/lib/http/http_message_parser_base.h:174:18: warning: ‘virtual void isc::http::HttpMessageParserBase::defineEvents()’ can be marked override [-Wsuggest-override] ../../../src/lib/http/http_message_parser_base.h:177:18: warning: ‘virtual void isc::http::HttpMessageParserBase::verifyEvents()’ can be marked override [-Wsuggest-override] ../../../src/lib/http/http_message_parser_base.h:180:18: warning: ‘virtual void isc::http::HttpMessageParserBase::defineStates()’ can be marked override [-Wsuggest-override] ../../../src/lib/http/http_message_parser_base.h:233:18: warning: ‘virtual void isc::http::HttpMessageParserBase::onModelFailure(const string&)’ can be marked override [-Wsuggest-override] ```
1 parent bceff40 commit 3e4dedd

8 files changed

+70
-105
lines changed

src/bin/perfdhcp/test_control.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,11 +1823,11 @@ TestControl::setDefaults4(const Pkt4Ptr& pkt) {
18231823
// The remote server's name or IP.
18241824
pkt->setRemoteAddr(IOAddress(options_.getServerName()));
18251825
// Set local address.
1826-
pkt->setLocalAddr(IOAddress(socket_.addr_));
1826+
pkt->setLocalAddr(socket_.addr_);
18271827
// Set relay (GIADDR) address to local address if multiple
18281828
// subnet mode is not enabled
18291829
if (!options_.checkMultiSubnet()) {
1830-
pkt->setGiaddr(IOAddress(socket_.addr_));
1830+
pkt->setGiaddr(socket_.addr_);
18311831
} else {
18321832
pkt->setGiaddr(IOAddress(options_.getRandRelayAddr()));
18331833
}
@@ -1868,9 +1868,9 @@ TestControl::setDefaults6(const Pkt6Ptr& pkt) {
18681868
if (options_.checkMultiSubnet()) {
18691869
relay_info.linkaddr_ = IOAddress(options_.getRandRelayAddr());
18701870
} else {
1871-
relay_info.linkaddr_ = IOAddress(socket_.addr_);
1871+
relay_info.linkaddr_ = socket_.addr_;
18721872
}
1873-
relay_info.peeraddr_ = IOAddress(socket_.addr_);
1873+
relay_info.peeraddr_ = socket_.addr_;
18741874
relay_info.options_.insert(options_.getRelayOpts().begin(), options_.getRelayOpts().end());
18751875
pkt->addRelayInfo(relay_info);
18761876
}

src/lib/asiolink/tests/io_service_thread_pool_unittests.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2021-2022 Internet Systems Consortium, Inc. ("ISC")
1+
// Copyright (C) 2021-2024 Internet Systems Consortium, Inc. ("ISC")
22
//
33
// This Source Code Form is subject to the terms of the Mozilla Public
44
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -20,9 +20,6 @@ using namespace isc::asiolink;
2020

2121
namespace {
2222

23-
/// @brief Test timeout (ms).
24-
const long TEST_TIMEOUT = 10000;
25-
2623
/// @brief Simple test fixture for testing IoServiceThreadPool.
2724
class IoServiceThreadPoolTest : public ::testing::Test {
2825
public:

src/lib/dhcp/tests/option_opaque_data_tuples_unittest.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ TEST(OptionOpaqueDataTuples, unpack6Truncated) {
530530
// data is parsed correctly.
531531
TEST(OptionOpaqueDataTuples, unpack4NoTuple) {
532532
// Prepare data to decode.
533-
const uint8_t buf_data[] = {
534-
};
535-
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
533+
std::vector<uint8_t> buf_vector;
534+
const uint8_t* buf_data = buf_vector.data();
535+
OptionBuffer buf(buf_data, buf_data + buf_vector.size());
536536

537537
OptionOpaqueDataTuplesPtr data_tuple;
538538
ASSERT_NO_THROW(
@@ -549,9 +549,9 @@ TEST(OptionOpaqueDataTuples, unpack4NoTuple) {
549549
// data is parsed correctly when tuple's length field is coded on 2 octets.
550550
TEST(OptionOpaqueDataTuples, unpack4NoTuple_with_ltf) {
551551
// Prepare data to decode.
552-
const uint8_t buf_data[] = {
553-
};
554-
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
552+
std::vector<uint8_t> buf_vector;
553+
const uint8_t* buf_data = buf_vector.data();
554+
OptionBuffer buf(buf_data, buf_data + buf_vector.size());
555555

556556
OptionOpaqueDataTuplesPtr data_tuple;
557557
ASSERT_NO_THROW(
@@ -569,9 +569,9 @@ TEST(OptionOpaqueDataTuples, unpack4NoTuple_with_ltf) {
569569
// data is parsed correctly.
570570
TEST(OptionOpaqueDataTuples, unpack6NoTuple) {
571571
// Prepare data to decode.
572-
const uint8_t buf_data[] = {
573-
};
574-
OptionBuffer buf(buf_data, buf_data + sizeof(buf_data));
572+
std::vector<uint8_t> buf_vector;
573+
const uint8_t* buf_data = buf_vector.data();
574+
OptionBuffer buf(buf_data, buf_data + buf_vector.size());
575575

576576
OptionOpaqueDataTuplesPtr data_tuple;
577577
ASSERT_NO_THROW(

src/lib/dhcpsrv/mysql_host_data_source.cc

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class MySqlHostExchange {
168168
columns_[AUTH_KEY_COL] = "auth_key";
169169

170170
BOOST_STATIC_ASSERT(13 < HOST_COLUMNS);
171-
};
171+
}
172172

173173
/// @brief Virtual destructor.
174174
virtual ~MySqlHostExchange() {
@@ -199,7 +199,7 @@ class MySqlHostExchange {
199199
/// This method is used by derived classes.
200200
uint64_t getHostId() const {
201201
return (host_id_);
202-
};
202+
}
203203

204204
/// @brief Set error indicators
205205
///
@@ -217,7 +217,7 @@ class MySqlHostExchange {
217217
error[i] = MLM_FALSE;
218218
bind[i].error = reinterpret_cast<my_bool*>(&error[i]);
219219
}
220-
};
220+
}
221221

222222
/// @brief Return columns in error
223223
///
@@ -251,7 +251,7 @@ class MySqlHostExchange {
251251
}
252252

253253
return (result);
254-
};
254+
}
255255

256256
/// @brief Create MYSQL_BIND objects for Host Pointer
257257
///
@@ -419,7 +419,7 @@ class MySqlHostExchange {
419419
vec.push_back(bind_[3]); // subnet_id
420420
}
421421
return (vec);
422-
};
422+
}
423423

424424
/// @brief Create BIND array to receive Host data.
425425
///
@@ -551,7 +551,7 @@ class MySqlHostExchange {
551551
// Add the data to the vector. Note the end element is one after the
552552
// end of the array.
553553
return (bind_);
554-
};
554+
}
555555

556556
/// @brief Copy received data into Host object
557557
///
@@ -576,14 +576,14 @@ class MySqlHostExchange {
576576
// set to 0.
577577
SubnetID ipv4_subnet_id(SUBNET_ID_UNUSED);
578578
if (dhcp4_subnet_id_null_ == MLM_FALSE) {
579-
ipv4_subnet_id = static_cast<SubnetID>(dhcp4_subnet_id_);
579+
ipv4_subnet_id = dhcp4_subnet_id_;
580580
}
581581

582582
// Set DHCPv6 subnet ID to the value returned. If NULL returned,
583583
// set to 0.
584584
SubnetID ipv6_subnet_id(SUBNET_ID_UNUSED);
585585
if (dhcp6_subnet_id_null_ == MLM_FALSE) {
586-
ipv6_subnet_id = static_cast<SubnetID>(dhcp6_subnet_id_);
586+
ipv6_subnet_id = dhcp6_subnet_id_;
587587
}
588588

589589
// Set IPv4 address reservation if it was given, if not, set IPv4 zero
@@ -671,7 +671,7 @@ class MySqlHostExchange {
671671
}
672672

673673
return (h);
674-
};
674+
}
675675

676676
/// @brief Processes one row of data fetched from a database.
677677
///
@@ -711,7 +711,7 @@ class MySqlHostExchange {
711711
/// "(None)".
712712
std::string getErrorColumns() {
713713
return (getColumnsInError(error_, columns_));
714-
};
714+
}
715715

716716
protected:
717717

@@ -1310,7 +1310,7 @@ class MySqlHostWithOptionsExchange : public MySqlHostExchange {
13101310
/// detects duplicated information and discards such entries.
13111311
///
13121312
/// @param [out] hosts Container holding parsed hosts and options.
1313-
virtual void processFetchedData(ConstHostCollection& hosts) {
1313+
virtual void processFetchedData(ConstHostCollection& hosts) override {
13141314
// Holds pointer to the previously parsed host.
13151315
HostPtr most_recent_host;
13161316
if (!hosts.empty()) {
@@ -1350,7 +1350,7 @@ class MySqlHostWithOptionsExchange : public MySqlHostExchange {
13501350
/// @brief Bind variables for receiving option data.
13511351
///
13521352
/// @return Vector of MYSQL_BIND object representing data to be retrieved.
1353-
virtual std::vector<MYSQL_BIND> createBindForReceive() {
1353+
virtual std::vector<MYSQL_BIND> createBindForReceive() override {
13541354
// The following call sets bind_ values between 0 and 8.
13551355
static_cast<void>(MySqlHostExchange::createBindForReceive());
13561356

@@ -1368,7 +1368,7 @@ class MySqlHostWithOptionsExchange : public MySqlHostExchange {
13681368
setErrorIndicators(bind_, error_);
13691369

13701370
return (bind_);
1371-
};
1371+
}
13721372

13731373
private:
13741374

@@ -1453,7 +1453,7 @@ class MySqlHostIPv6Exchange : public MySqlHostWithOptionsExchange {
14531453
return (reservation_id_);
14541454
}
14551455
return (0);
1456-
};
1456+
}
14571457

14581458
/// @brief Creates IPv6 reservation from the data contained in the
14591459
/// currently processed row.
@@ -1484,7 +1484,7 @@ class MySqlHostIPv6Exchange : public MySqlHostWithOptionsExchange {
14841484
IOAddress addr6 = IOAddress::fromBytes(AF_INET6, ipv6_address_buffer_);
14851485
IPv6Resrv r(type, addr6, prefix_len_);
14861486
return (r);
1487-
};
1487+
}
14881488

14891489
/// @brief Processes one row of data fetched from a database.
14901490
///
@@ -1505,7 +1505,7 @@ class MySqlHostIPv6Exchange : public MySqlHostWithOptionsExchange {
15051505
///
15061506
/// @param [out] hosts Collection of hosts to which a new host created
15071507
/// from the processed data should be inserted.
1508-
virtual void processFetchedData(ConstHostCollection& hosts) {
1508+
virtual void processFetchedData(ConstHostCollection& hosts) override {
15091509

15101510
// Call parent class to fetch host information and options.
15111511
MySqlHostWithOptionsExchange::processFetchedData(hosts);
@@ -1539,7 +1539,7 @@ class MySqlHostIPv6Exchange : public MySqlHostWithOptionsExchange {
15391539
/// objects with associated IPv6 reservations.
15401540
///
15411541
/// @return Vector of MYSQL_BIND objects representing data to be retrieved.
1542-
virtual std::vector<MYSQL_BIND> createBindForReceive() {
1542+
virtual std::vector<MYSQL_BIND> createBindForReceive() override {
15431543
// Reset most recent reservation id value because we're now making
15441544
// a new SELECT query.
15451545
most_recent_reservation_id_ = 0;
@@ -1580,7 +1580,7 @@ class MySqlHostIPv6Exchange : public MySqlHostWithOptionsExchange {
15801580
setErrorIndicators(bind_, error_);
15811581

15821582
return (bind_);
1583-
};
1583+
}
15841584

15851585
private:
15861586

@@ -1798,18 +1798,6 @@ class MySqlIPv6ReservationExchange {
17981798
///
17991799
/// This class supports inserting both DHCPv4 and DHCPv6 options.
18001800
class MySqlOptionExchange {
1801-
private:
1802-
1803-
static const size_t OPTION_ID_COL = 0;
1804-
static const size_t CODE_COL = 1;
1805-
static const size_t VALUE_COL = 2;
1806-
static const size_t FORMATTED_VALUE_COL = 3;
1807-
static const size_t SPACE_COL = 4;
1808-
static const size_t PERSISTENT_COL = 5;
1809-
static const size_t CANCELLED_COL = 6;
1810-
static const size_t USER_CONTEXT_COL = 7;
1811-
static const size_t DHCP_SUBNET_ID_COL = 8;
1812-
static const size_t HOST_ID_COL = 9;
18131801
/// @brief Number of columns in the option tables holding bindable values.
18141802
static const size_t OPTION_COLUMNS = 10;
18151803

@@ -3231,7 +3219,7 @@ MySqlHostDataSourceImpl::getHost(MySqlHostContextPtr& ctx,
32313219
// Identifier type.
32323220
char identifier_type_copy = static_cast<char>(identifier_type);
32333221
inbind[1].buffer_type = MYSQL_TYPE_TINY;
3234-
inbind[1].buffer = reinterpret_cast<char*>(&identifier_type_copy);
3222+
inbind[1].buffer = &identifier_type_copy;
32353223
inbind[1].is_unsigned = MLM_TRUE;
32363224

32373225
ConstHostCollection collection;
@@ -3394,7 +3382,7 @@ MySqlHostDataSource::del4(const SubnetID& subnet_id,
33943382
// identifier type
33953383
char identifier_type_copy = static_cast<char>(identifier_type);
33963384
inbind[1].buffer_type = MYSQL_TYPE_TINY;
3397-
inbind[1].buffer = reinterpret_cast<char*>(&identifier_type_copy);
3385+
inbind[1].buffer = &identifier_type_copy;
33983386
inbind[1].is_unsigned = MLM_TRUE;
33993387

34003388
// identifier value
@@ -3435,7 +3423,7 @@ MySqlHostDataSource::del6(const SubnetID& subnet_id,
34353423
// identifier type
34363424
char identifier_type_copy = static_cast<char>(identifier_type);
34373425
inbind[1].buffer_type = MYSQL_TYPE_TINY;
3438-
inbind[1].buffer = reinterpret_cast<char*>(&identifier_type_copy);
3426+
inbind[1].buffer = &identifier_type_copy;
34393427
inbind[1].is_unsigned = MLM_TRUE;
34403428

34413429
// identifier value

0 commit comments

Comments
 (0)