Skip to content

Commit

Permalink
Fixing some warnings [4086] (#348)
Browse files Browse the repository at this point in the history
* Refs #4086 - Fixing warnings.

* Refs #4086 - Fixing warnings on Mac.

* Refs #4086. Fixed unsigned warnings on win32.
  • Loading branch information
MiguelCompany authored and richiware committed Dec 7, 2018
1 parent 6d63018 commit b48ce9d
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 101 deletions.
8 changes: 4 additions & 4 deletions src/cpp/security/cryptography/AESGCMGMAC_KeyExchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,11 @@ void AESGCMGMAC_KeyExchange::KeyMaterialCDRDeserialize(KeyMaterial_AES_GCM_GMAC&
pos = 4 + 3; // 4 - transformation_kind. 3 - 0's
key_len = data[pos++];
// TODO: check key_len
std::copy(data + pos, data + pos + key_len, buffer.master_salt.data());
memcpy(buffer.master_salt.data(), &data[pos], key_len);
pos += key_len;

// sender_key_id : octet[4]
std::copy(data + pos, data + pos + 4, buffer.sender_key_id.data());
memcpy(buffer.sender_key_id.data(), &data[pos], 4);
pos += 4;

// master_sender_key : sequence<octet,32>
Expand All @@ -456,7 +456,7 @@ void AESGCMGMAC_KeyExchange::KeyMaterialCDRDeserialize(KeyMaterial_AES_GCM_GMAC&
pos += 3;
key_len = data[pos++];
// TODO: check key_len
std::copy(data + pos, data + pos + key_len, buffer.master_sender_key.data());
memcpy(buffer.master_sender_key.data(), &data[pos], key_len);
pos += key_len;

// receiver_specific_key_id : octet[4]
Expand All @@ -475,7 +475,7 @@ void AESGCMGMAC_KeyExchange::KeyMaterialCDRDeserialize(KeyMaterial_AES_GCM_GMAC&
pos += 3;
key_len = data[pos++];
// TODO: check key_len
std::copy(data + pos, data + pos + key_len, buffer.master_receiver_specific_key.data());
memcpy(buffer.master_receiver_specific_key.data(), &data[pos], key_len);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/BlackboxTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ BLACKBOXTEST(BlackBox, StatefulReaderCacheChangeRelease){
std::this_thread::sleep_for(std::chrono::seconds(1));
reader.startReception(expected_data);

ASSERT_EQ(reader.getReceivedCount(), 0);
ASSERT_EQ(reader.getReceivedCount(), 0u);
}

BLACKBOXTEST(BlackBox, PubSubMoreThan256Unacknowledged)
Expand Down
18 changes: 9 additions & 9 deletions test/unittest/logging/LogTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ TEST_F(LogTests, asynchronous_logging)
logWarning(DifferentCategory, "Sample warning message in another category");

auto consumedEntries = HELPER_WaitForEntries(3);
ASSERT_EQ(3, consumedEntries.size());
ASSERT_EQ(3u, consumedEntries.size());
}

TEST_F(LogTests, reporting_options)
{
// moving away from the defaults
Log::ReportFilenames(true);
Log::ReportFunctions(false);

logError(Reporting, "Error with different reporting options");
auto consumedEntries = HELPER_WaitForEntries(1);
ASSERT_EQ(1, consumedEntries.size());
ASSERT_EQ(1u, consumedEntries.size());

auto entry = consumedEntries.back();
ASSERT_NE(entry.context.filename, nullptr);
Expand All @@ -91,7 +91,7 @@ TEST_F(LogTests, multithreaded_logging)
}

auto consumedEntries = HELPER_WaitForEntries(5);
ASSERT_EQ(5, consumedEntries.size());
ASSERT_EQ(5u, consumedEntries.size());
}

TEST_F(LogTests, regex_category_filtering)
Expand All @@ -101,7 +101,7 @@ TEST_F(LogTests, regex_category_filtering)
logError(BadCategory, "If you're seeing this, something went wrong");
logWarning(EvenMoreGoodCategory, "This should be logged too!");
auto consumedEntries = HELPER_WaitForEntries(3);
ASSERT_EQ(2, consumedEntries.size());
ASSERT_EQ(2u, consumedEntries.size());
}

TEST_F(LogTests, multi_criteria_filtering_with_regex)
Expand All @@ -116,14 +116,14 @@ TEST_F(LogTests, multi_criteria_filtering_with_regex)
logError(BadCategory, "Despite the word \"Good\" being here, this shouldn't be logged");
logError(GoodCategory, "And neither should this.");
auto consumedEntries = HELPER_WaitForEntries(3);
ASSERT_EQ(1, consumedEntries.size());
ASSERT_EQ(1u, consumedEntries.size());

Log::SetFilenameFilter(std::regex("(we shouldn't find this ever)"));
logError(GoodCategory, "Despite the word \"Good\" being here, this shouldn't be logged because "\
"the filename is all wrong");

consumedEntries = HELPER_WaitForEntries(2);
ASSERT_EQ(1, consumedEntries.size());
ASSERT_EQ(1u, consumedEntries.size());
}

TEST_F(LogTests, multiple_verbosity_levels)
Expand All @@ -133,15 +133,15 @@ TEST_F(LogTests, multiple_verbosity_levels)
logWarning(VerbosityChecks, "This should be logged too!");
logInfo(VerbosityChecks, "If you're seeing this, something went wrong");
auto consumedEntries = HELPER_WaitForEntries(3);
ASSERT_EQ(2, consumedEntries.size());
ASSERT_EQ(2u, consumedEntries.size());

Log::SetVerbosity(Log::Error);
logError(VerbosityChecks, "This should be logged");
logWarning(VerbosityChecks, "If you're seeing this, something went wrong");
logInfo(VerbosityChecks, "If you're seeing this, something went wrong");

consumedEntries = HELPER_WaitForEntries(5);
ASSERT_EQ(3, consumedEntries.size());
ASSERT_EQ(3u, consumedEntries.size());
}

std::vector<Log::Entry> LogTests::HELPER_WaitForEntries(uint32_t amount)
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/rtps/flowcontrol/ThroughputControllerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TEST_F(ThroughputControllerTests, if_changes_are_fragmented_throughput_controlle
// Then
// The first 5 are completely cleared
// And the last one is partially cleared
ASSERT_EQ(55, testChangesForUse.size());
ASSERT_EQ(55u, testChangesForUse.size());

SequenceNumber_t seqNum(0, 1);
FragmentNumber_t fragNum = 1;
Expand Down Expand Up @@ -118,26 +118,26 @@ TEST_F(ThroughputControllerTests, throughput_controller_carries_over_multiple_at
sController(otherChangesForUse);

// Then
ASSERT_EQ(0, otherChangesForUse.size());
ASSERT_EQ(0u, otherChangesForUse.size());
std::this_thread::sleep_for(std::chrono::milliseconds(periodMillisecs + 50));
}

TEST_F(ThroughputControllerTests, throughput_controller_resets_completely_after_its_refresh_period)
{
// Given
sController(testChangesForUse);
ASSERT_EQ(5, testChangesForUse.size());
ASSERT_EQ(5u, testChangesForUse.size());

// The controller is now fully closed, so controllering anything will throw all changes away.
sController(testChangesForUse);
ASSERT_EQ(0, testChangesForUse.size());
ASSERT_EQ(0u, testChangesForUse.size());

// When
std::this_thread::sleep_for(std::chrono::milliseconds(periodMillisecs + 100));

// The controller should be open now
sController(otherChangesForUse);
EXPECT_EQ(5, otherChangesForUse.size());
EXPECT_EQ(5u, otherChangesForUse.size());
std::this_thread::sleep_for(std::chrono::milliseconds(periodMillisecs + 50));
}

Expand Down
8 changes: 4 additions & 4 deletions test/unittest/rtps/network/NetworkFactoryTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TEST_F(NetworkTests, BuildSenderResource_returns_send_resource_for_a_kind_compat
auto resources = networkFactoryUnderTest.BuildSenderResources(kindCompatibleLocator);

// Then
ASSERT_EQ(1, resources.size());
ASSERT_EQ(1u, resources.size());
}

TEST_F(NetworkTests, BuildReceiverResource_returns_receive_resource_for_a_kind_compatible_transport)
Expand All @@ -73,7 +73,7 @@ TEST_F(NetworkTests, BuildReceiverResource_returns_receive_resource_for_a_kind_c

// Then
ASSERT_TRUE(ret);
ASSERT_EQ(1, resources.size());
ASSERT_EQ(1u, resources.size());
}

TEST_F(NetworkTests, BuildReceiverResource_returns_multiple_resources_if_multiple_transports_compatible)
Expand All @@ -92,7 +92,7 @@ TEST_F(NetworkTests, BuildReceiverResource_returns_multiple_resources_if_multipl

// Then
ASSERT_TRUE(ret);
ASSERT_EQ(2, resources.size());
ASSERT_EQ(2u, resources.size());
}

TEST_F(NetworkTests, BuildSenderResource_returns_multiple_resources_if_multiple_transports_compatible)
Expand All @@ -109,7 +109,7 @@ TEST_F(NetworkTests, BuildSenderResource_returns_multiple_resources_if_multiple_
auto resources = networkFactoryUnderTest.BuildSenderResources(locatorCompatibleWithTwoTransports);

// Then
ASSERT_EQ(2, resources.size());
ASSERT_EQ(2u, resources.size());
}

TEST_F(NetworkTests, creating_send_resource_from_locator_opens_channels_mapped_to_that_locator)
Expand Down
10 changes: 5 additions & 5 deletions test/unittest/rtps/persistence/PersistenceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST_F(PersistenceTest, Writer)
// Initial load should return empty vector
changes.clear();
ASSERT_TRUE(service->load_writer_from_storage(persist_guid, guid, changes, &pool));
ASSERT_EQ(changes.size(), 0);
ASSERT_EQ(changes.size(), 0u);

// Add two changes
change.sequenceNumber.low = 1;
Expand All @@ -84,7 +84,7 @@ TEST_F(PersistenceTest, Writer)
// Loading should return two changes (seqs = 1, 2)
changes.clear();
ASSERT_TRUE(service->load_writer_from_storage(persist_guid, guid, changes, &pool));
ASSERT_EQ(changes.size(), 2);
ASSERT_EQ(changes.size(), 2u);
uint32_t i = 0;
for (auto it : changes)
{
Expand All @@ -100,15 +100,15 @@ TEST_F(PersistenceTest, Writer)
// Loading should return one change (seq = 2)
changes.clear();
ASSERT_TRUE(service->load_writer_from_storage(persist_guid, guid, changes, &pool));
ASSERT_EQ(changes.size(), 1);
ASSERT_EQ(changes.size(), 1u);
ASSERT_EQ((*changes.begin())->sequenceNumber, SequenceNumber_t(0, 2));

// Remove seq = 2, and check that load returns empty vector
changes.clear();
change.sequenceNumber.low = 2;
ASSERT_TRUE(service->remove_writer_change_from_storage(persist_guid, change));
ASSERT_TRUE(service->load_writer_from_storage(persist_guid, guid, changes, &pool));
ASSERT_EQ(changes.size(), 0);
ASSERT_EQ(changes.size(), 0u);
}

/*!
Expand Down Expand Up @@ -137,7 +137,7 @@ TEST_F(PersistenceTest, Reader)
// Initial load should return empty map
seq_map_loaded.clear();
ASSERT_TRUE(service->load_reader_from_storage(persist_guid, seq_map_loaded));
ASSERT_EQ(seq_map_loaded.size(), 0);
ASSERT_EQ(seq_map_loaded.size(), 0u);

// Add two changes
seq_map[guid_1] = seq_1;
Expand Down
Loading

0 comments on commit b48ce9d

Please sign in to comment.