Skip to content

Commit

Permalink
Fix VS 2017 compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sedovmo committed Nov 25, 2024
1 parent f2fb754 commit 65ca2d9
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 49 deletions.
2 changes: 1 addition & 1 deletion asam_cmp_capture_module/src/capture_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void CaptureFb::statusLoop()
ethernetWrapper->sendPacket(e);


for (int i = 0; i < captureStatus.getInterfaceStatusCount(); ++i)
for (SizeT i = 0; i < captureStatus.getInterfaceStatusCount(); ++i)
{
encodedData = encoders.encode(1, captureStatus.getInterfaceStatus(i).getPacket(), encoderContext);
for (const auto& e : encodedData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace
if (inputDataDescriptorStruct.getCount() != referenceDataDescriptorStruct.getCount())
return false;

for (int i = 0; i < inputDataDescriptorStruct.getCount(); ++i)
for (SizeT i = 0; i < inputDataDescriptorStruct.getCount(); ++i)
{
if (!checkDataDescriptor(inputDataDescriptorStruct.getItemAt(i), referenceDataDescriptorStruct.getItemAt(i)))
return false;
Expand Down
2 changes: 1 addition & 1 deletion asam_cmp_capture_module/src/stream_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ void createAnalogPayloadWithInternalScaling(ASAM::CMP::AnalogPayload& payload,
payload.setSampleOffset(analogDataOffset);

std::vector<int32_t> scaledData(sampleCount);
for (int i = 0; i < sampleCount; ++i)
for (size_t i = 0; i < sampleCount; ++i)
{
scaledData[i] = std::round((rawData[i] - analogDataOffset) / analogDataScale);
}
Expand Down
6 changes: 3 additions & 3 deletions asam_cmp_capture_module/tests/test_analog_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AnalogMessagesTest : public testing::Test
void testAnalogPackets(bool setScale);

template <typename T>
bool checkSamples(const ASAM::CMP::AnalogPayload& analogPayload, int& receivedSamples);
bool checkSamples(const ASAM::CMP::AnalogPayload& analogPayload, size_t& receivedSamples);

protected:
TimeStub timeStub;
Expand All @@ -97,7 +97,7 @@ class AnalogMessagesTest : public testing::Test
};

template <typename T>
bool AnalogMessagesTest::checkSamples(const ASAM::CMP::AnalogPayload& analogPayload, int& receivedSamples)
bool AnalogMessagesTest::checkSamples(const ASAM::CMP::AnalogPayload& analogPayload, size_t& receivedSamples)
{
auto rawData = reinterpret_cast<const T*>(analogPayload.getData());
auto receivedSamplesCnt = analogPayload.getSamplesCount();
Expand Down Expand Up @@ -150,7 +150,7 @@ void AnalogMessagesTest::testAnalogPackets(bool setScale)
auto chPrivate = analogChannel.asPtr<IInputChannelStub>();
chPrivate->collectSamples(curTime);

int receivedSamples = 0;
size_t receivedSamples = 0;
auto checker = [&]() -> bool
{
std::scoped_lock lock{packedReceivedSync};
Expand Down
2 changes: 1 addition & 1 deletion asam_cmp_capture_module/tests/test_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ TEST_F(InterfaceFbTest, TestInterfaceStatusWithStreamsReceived)

const uint8_t* receivedVendorData = static_cast<ASAM::CMP::InterfacePayload&>(lastReceivedPacket.getPayload()).getVendorData();

for (int i = 0; i < vendorDataLen; ++i)
for (size_t i = 0; i < vendorDataLen; ++i)
{
if (vendorData[i] != receivedVendorData[i])
return false;
Expand Down
7 changes: 1 addition & 6 deletions asam_cmp_common_lib/src/network_manager_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ void NetworkManagerFb::addNetworkAdaptersProperty()
ListPtr<StringPtr> devicesNames = ethernetWrapper->getEthernetDevicesNamesList();
ListPtr<StringPtr> devicesDescriptions = ethernetWrapper->getEthernetDevicesDescriptionsList();

int selectedDeviceInd = 0;
for (int i = 0; i < devicesNames.getCount(); ++i)
for (SizeT i = 0; i < devicesNames.getCount(); ++i)
{
if (ethernetWrapper->setDevice(devicesNames[i]))
{
selectedDeviceInd = i;
selectedEthernetDeviceName = devicesNames[i];
break;
}
Expand All @@ -49,9 +47,6 @@ void NetworkManagerFb::addNetworkAdaptersProperty()
objPtr.addProperty(prop);
objPtr.getOnPropertyValueWrite(propName) += [this, propName](PropertyObjectPtr& obj, PropertyValueEventArgsPtr& args)
{
// setPropertyValueInternal(
// String("InterfaceId").asPtr<IString>(true), BaseObjectPtr(interfaceId).asPtr<IBaseObject>(true), false, false, false);

StringPtr oldName = objPtr.getPropertySelectionValue("NetworkAdaptersNames");
int oldInd = objPtr.getPropertyValue("NetworkAdaptersNames");

Expand Down
8 changes: 4 additions & 4 deletions asam_cmp_data_sink/tests/test_capture_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TEST_F(CaptureFbTest, FunctionBlockType)
TEST_F(CaptureFbTest, AvailableFunctionBlockTypes)
{
auto availableTypes = captureFb.getAvailableFunctionBlockTypes();
ASSERT_EQ(availableTypes.getCount(), 1);
ASSERT_EQ(availableTypes.getCount(), 1u);
ASSERT_TRUE(availableTypes.hasKey("AsamCmpInterface"));
ASSERT_EQ(availableTypes.get("AsamCmpInterface"), asam_cmp_common_lib::InterfaceCommonFb::CreateType());
}
Expand Down Expand Up @@ -127,17 +127,17 @@ TEST_F(CaptureFbTest, TestCreateInterface)
{
ProcedurePtr createProc = captureFb.getPropertyValue("AddInterface");

ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 0);
ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 0u);
createProc();
createProc();
ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 2);
ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 2u);

int lstId = captureFb.getFunctionBlocks().getItemAt(1).getPropertyValue("InterfaceId");

ProcedurePtr removeProc = captureFb.getPropertyValue("RemoveInterface");
removeProc(0);

ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 1);
ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 1u);
ASSERT_EQ(captureFb.getFunctionBlocks().getItemAt(0).getPropertyValue("InterfaceId"), lstId);
}

Expand Down
30 changes: 15 additions & 15 deletions asam_cmp_data_sink/tests/test_data_sink_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ TEST_F(DataSinkFbTest, FunctionBlockType)
TEST_F(DataSinkFbTest, AvailableFunctionBlockTypes)
{
auto availableTypes = funcBlock.getAvailableFunctionBlockTypes();
ASSERT_EQ(availableTypes.getCount(), 1);
ASSERT_EQ(availableTypes.getCount(), 1u);
ASSERT_TRUE(availableTypes.hasKey("AsamCmpCapture"));
ASSERT_EQ(availableTypes.get("AsamCmpCapture"), CaptureFb::CreateType());
}
Expand All @@ -110,7 +110,7 @@ TEST_F(DataSinkFbTest, AddCaptureModuleFromStatus)
ProcedurePtr addCaptureModuleFromStatus = funcBlock.getPropertyValue("AddCaptureModuleFromStatus");
addCaptureModuleFromStatus(0);
addCaptureModuleFromStatus(0);
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 2);
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 2u);
auto captureModule = funcBlock.getFunctionBlocks()[0];

StringPtr propVal = captureModule.getPropertyValue("DeviceDescription");
Expand All @@ -130,15 +130,15 @@ TEST_F(DataSinkFbTest, AddCaptureModuleFromStatus)
{ return arg.hasProperty("InterfaceId") && (arg.getPropertyValue("InterfaceId") == targetInterfaceId); });
SearchFilterPtr interfaceFilter = search::Custom(isCorrectInterface);

ASSERT_EQ(captureModule.getFunctionBlocks(interfaceFilter).getCount(), 1);
ASSERT_EQ(captureModule.getFunctionBlocks(interfaceFilter).getCount(), 1u);
auto interfaceFb = captureModule.getFunctionBlocks(interfaceFilter)[0];

int targetStreamId = 1;
FunctionPtr isCorrectStream = Function([&targetStreamId](FunctionBlockPtr arg)
{ return arg.hasProperty("StreamId") && (arg.getPropertyValue("StreamId") == targetStreamId); });
SearchFilterPtr streamFilter = search::Custom(isCorrectStream);

ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1);
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1u);

cmPacket->setDeviceId(3);
statusHandler->processStatusPacket(cmPacket);
Expand All @@ -154,26 +154,26 @@ TEST_F(DataSinkFbTest, AddCaptureModuleFromStatus)
statusHandler->processStatusPacket(ifPacket);

addCaptureModuleFromStatus(1);
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 3);
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 3u);
captureModule = funcBlock.getFunctionBlocks()[2];

targetInterfaceId = 22;
ASSERT_EQ(captureModule.getFunctionBlocks(interfaceFilter).getCount(), 1);
ASSERT_EQ(captureModule.getFunctionBlocks(interfaceFilter).getCount(), 1u);
interfaceFb = captureModule.getFunctionBlocks(interfaceFilter)[0];

targetStreamId = 1;
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1);
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1u);

targetInterfaceId = 33;
ASSERT_EQ(captureModule.getFunctionBlocks(interfaceFilter).getCount(), 1);
ASSERT_EQ(captureModule.getFunctionBlocks(interfaceFilter).getCount(), 1u);
interfaceFb = captureModule.getFunctionBlocks(interfaceFilter)[0];

targetStreamId = 3;
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1);
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1u);
targetStreamId = 5;
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1);
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1u);
targetStreamId = 10;
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1);
ASSERT_EQ(interfaceFb.getFunctionBlocks(streamFilter).getCount(), 1u);
}

TEST_F(DataSinkFbTest, RemoveCaptureFromStatus)
Expand All @@ -200,7 +200,7 @@ TEST_F(DataSinkFbTest, AddCaptureModuleEmpty)
ProcedurePtr func = funcBlock.getPropertyValue("AddCaptureModuleEmpty");
func();
func();
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 2);
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 2u);
}

TEST_F(DataSinkFbTest, UpdateDeviceInfo)
Expand Down Expand Up @@ -229,7 +229,7 @@ TEST_F(DataSinkFbTest, RemoveCaptureModuleReadOnly)

TEST_F(DataSinkFbTest, RemoveCaptureModule)
{
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 0);
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 0u);
ProcedurePtr addFunc = funcBlock.getPropertyValue("AddCaptureModuleEmpty");
addFunc();
auto captureFb = funcBlock.getFunctionBlocks().getItemAt(0);
Expand All @@ -239,8 +239,8 @@ TEST_F(DataSinkFbTest, RemoveCaptureModule)

ProcedurePtr removeFunc = funcBlock.getPropertyValue("RemoveCaptureModule");
removeFunc(0);
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 0);
ASSERT_EQ(publisher.size(), 0);
ASSERT_EQ(funcBlock.getFunctionBlocks().getCount(), 0u);
ASSERT_EQ(publisher.size(), 0u);
}

TEST_F(DataSinkFbTest, DefaultDevicesIds)
Expand Down
6 changes: 3 additions & 3 deletions asam_cmp_data_sink/tests/test_interface_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TEST_F(InterfaceFbTest, FunctionBlockType)
TEST_F(InterfaceFbTest, AvailableFunctionBlockTypes)
{
auto availableTypes = interfaceFb.getAvailableFunctionBlockTypes();
ASSERT_EQ(availableTypes.getCount(), 1);
ASSERT_EQ(availableTypes.getCount(), 1u);
ASSERT_TRUE(availableTypes.hasKey("AsamCmpStream"));
ASSERT_EQ(availableTypes.get("AsamCmpStream"), modules::asam_cmp_data_sink_module::StreamFb::CreateType());
}
Expand All @@ -71,7 +71,7 @@ TEST_F(InterfaceFbTest, CaptureModuleProperties)
TEST_F(InterfaceFbTest, InterfaceId)
{
captureFb.getPropertyValue("AddInterface").execute();
ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 2);
ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 2u);

const auto interfaceFb2 = captureFb.getFunctionBlocks().getItemAt(1);

Expand Down Expand Up @@ -117,7 +117,7 @@ TEST_F(InterfaceFbTest, AddRemoveStream)

interfaceFb.getPropertyValue("RemoveStream").execute(0);

ASSERT_EQ(interfaceFb.getFunctionBlocks().getCount(), 1);
ASSERT_EQ(interfaceFb.getFunctionBlocks().getCount(), 1u);
}

TEST_F(InterfaceFbTest, TestBeginUpdateEndUpdate)
Expand Down
2 changes: 1 addition & 1 deletion asam_cmp_data_sink/tests/test_status_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST_F(StatusFbTest, FunctionBlockType)
TEST_F(StatusFbTest, CaptureModuleList)
{
ListPtr<IString> cmList = funcBlock.getPropertyValue("CaptureModuleList");
ASSERT_EQ(cmList.getCount(), 0);
ASSERT_EQ(cmList.getCount(), 0u);
EXPECT_THROW(funcBlock.setPropertyValue("CaptureModuleList", cmList), daq::AccessDeniedException);
}

Expand Down
26 changes: 13 additions & 13 deletions asam_cmp_data_sink/tests/test_stream_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ TEST_F(StreamFbTest, StreamIdMax)
TEST_F(StreamFbTest, SignalsCount)
{
const auto outputSignals = funcBlock.getSignalsRecursive();
ASSERT_EQ(outputSignals.getCount(), 1);
ASSERT_EQ(outputSignals.getCount(), 1u);
}

TEST_F(StreamFbTest, SignalName)
Expand Down Expand Up @@ -169,9 +169,9 @@ TEST_F(StreamFbTest, DefaultSignalDescriptors)
TEST_F(StreamFbTest, RemoveStream)
{
interfaceFb.getPropertyValue("RemoveStream").execute(0);
ASSERT_EQ(interfaceFb.getFunctionBlocks().getCount(), 0);
ASSERT_EQ(interfaceFb.getFunctionBlocks().getCount(), 0u);

ASSERT_EQ(publisher.size(), 0);
ASSERT_EQ(publisher.size(), 0u);
}

TEST_F(StreamFbTest, RemoveAddStream)
Expand All @@ -188,9 +188,9 @@ TEST_F(StreamFbTest, RemoveAddStream)
TEST_F(StreamFbTest, RemoveInterface)
{
captureFb.getPropertyValue("RemoveInterface").execute(0);
ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 0);
ASSERT_EQ(captureFb.getFunctionBlocks().getCount(), 0u);

ASSERT_EQ(publisher.size(), 0);
ASSERT_EQ(publisher.size(), 0u);
}

class StreamFbCanPayloadTest : public StreamFbTest
Expand Down Expand Up @@ -249,12 +249,12 @@ TEST_F(StreamFbCanPayloadTest, ChangeStreamId)

publisher.publish({canPacket->getDeviceId(), canPacket->getInterfaceId(), canPacket->getStreamId()}, canPacket);
auto samplesCount = waitForSamples(reader);
ASSERT_EQ(samplesCount, 0);
ASSERT_EQ(samplesCount, 0u);

canPacket->setStreamId(newStreamId);
publisher.publish({canPacket->getDeviceId(), canPacket->getInterfaceId(), canPacket->getStreamId()}, canPacket);
samplesCount = waitForSamples(reader);
ASSERT_EQ(samplesCount, 1);
ASSERT_EQ(samplesCount, 1u);
}

TEST_F(StreamFbCanPayloadTest, ChangeInterfaceId)
Expand All @@ -268,12 +268,12 @@ TEST_F(StreamFbCanPayloadTest, ChangeInterfaceId)

publisher.publish({canPacket->getDeviceId(), canPacket->getInterfaceId(), canPacket->getStreamId()}, canPacket);
auto samplesCount = waitForSamples(reader);
ASSERT_EQ(samplesCount, 0);
ASSERT_EQ(samplesCount, 0u);

canPacket->setInterfaceId(newInterfaceId);
publisher.publish({canPacket->getDeviceId(), canPacket->getInterfaceId(), canPacket->getStreamId()}, canPacket);
samplesCount = waitForSamples(reader);
ASSERT_EQ(samplesCount, 1);
ASSERT_EQ(samplesCount, 1u);
}

TEST_F(StreamFbCanPayloadTest, ChangeDeviceId)
Expand All @@ -287,12 +287,12 @@ TEST_F(StreamFbCanPayloadTest, ChangeDeviceId)

publisher.publish({canPacket->getDeviceId(), canPacket->getInterfaceId(), canPacket->getStreamId()}, canPacket);
auto samplesCount = waitForSamples(reader);
ASSERT_EQ(samplesCount, 0);
ASSERT_EQ(samplesCount, 0u);

canPacket->setDeviceId(newDeviceId);
publisher.publish({canPacket->getDeviceId(), canPacket->getInterfaceId(), canPacket->getStreamId()}, canPacket);
samplesCount = waitForSamples(reader);
ASSERT_EQ(samplesCount, 1);
ASSERT_EQ(samplesCount, 1u);
}

TEST_F(StreamFbCanPayloadTest, CanSignalDescriptors)
Expand Down Expand Up @@ -338,13 +338,13 @@ TEST_F(StreamFbCanPayloadTest, ReadOutputCanSignal)

publisher.publish({canPacket->getDeviceId(), canPacket->getInterfaceId(), canPacket->getStreamId()}, canPacket);
const auto samplesCount = waitForSamples(reader);
ASSERT_EQ(samplesCount, 1);
ASSERT_EQ(samplesCount, 1u);

CANData sample;
uint64_t domainSample;
size_t count = 1;
reader.readWithDomain(&sample, &domainSample, &count);
ASSERT_EQ(count, 1);
ASSERT_EQ(count, 1u);
ASSERT_EQ(domainSample, canPacket->getTimestamp());
ASSERT_EQ(sample.arbId, arbId);
ASSERT_EQ(sample.length, sizeof(canData));
Expand Down

0 comments on commit 65ca2d9

Please sign in to comment.