Skip to content

Commit 05362b1

Browse files
committed
[#3256] attempt to fix nonsense Wstringop-overread
``` warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ reading 1 or more bytes from a region of size 0 [-Wstringop-overread] ``` and Wsign-compare in the same file: ``` test_control.cc:116:35: warning: comparison of integers of different signs: 'uint64_t' (aka 'unsigned long') and 'int' [-Wsign-compare] 338ms test_control.cc:491:43: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'const int' [-Wsign-compare] test_control.cc:529:50: warning: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'const int' [-Wsign-compare] ```
1 parent 934d827 commit 05362b1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/bin/perfdhcp/test_control.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ TestControl::cleanCachedPackets() {
113113
// since we want to randomize leases to be renewed so leave 5
114114
// times more packets to randomize from.
115115
/// @todo The cache size might be controlled from the command line.
116-
if (reply_storage_.size() > 5 * options_.getRenewRate()) {
116+
if (reply_storage_.size() > 5 * size_t(options_.getRenewRate())) {
117117
reply_storage_.clear(reply_storage_.size() -
118118
5 * options_.getRenewRate());
119119
}
@@ -404,9 +404,11 @@ TestControl::generateMacAddress(uint8_t& randomized) {
404404

405405
OptionPtr
406406
TestControl::generateClientId(const dhcp::HWAddrPtr& hwaddr) const {
407-
std::vector<uint8_t> client_id(1, static_cast<uint8_t>(hwaddr->htype_));
408-
client_id.insert(client_id.end(), hwaddr->hwaddr_.begin(),
409-
hwaddr->hwaddr_.end());
407+
vector<uint8_t> client_id;
408+
client_id.push_back(static_cast<uint8_t>(hwaddr->htype_));
409+
for (uint8_t const& byte : hwaddr->hwaddr_) {
410+
client_id.push_back(byte);
411+
}
410412
return (OptionPtr(new Option(Option::V4, DHO_DHCP_CLIENT_IDENTIFIER,
411413
client_id)));
412414
}
@@ -486,7 +488,7 @@ int
486488
TestControl::getRandomOffset(const int arg_idx) const {
487489
int rand_offset = options_.getIpVersion() == 4 ?
488490
DHCPV4_RANDOMIZATION_OFFSET : DHCPV6_RANDOMIZATION_OFFSET;
489-
if (options_.getRandomOffset().size() > arg_idx) {
491+
if (options_.getRandomOffset().size() > size_t(arg_idx)) {
490492
rand_offset = options_.getRandomOffset()[arg_idx];
491493
}
492494
return (rand_offset);
@@ -524,7 +526,7 @@ int
524526
TestControl::getTransactionIdOffset(const int arg_idx) const {
525527
int xid_offset = options_.getIpVersion() == 4 ?
526528
DHCPV4_TRANSID_OFFSET : DHCPV6_TRANSID_OFFSET;
527-
if (options_.getTransactionIdOffset().size() > arg_idx) {
529+
if (options_.getTransactionIdOffset().size() > size_t(arg_idx)) {
528530
xid_offset = options_.getTransactionIdOffset()[arg_idx];
529531
}
530532
return (xid_offset);

0 commit comments

Comments
 (0)