Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix some Wsign-compare warnings
To avoid creating a new warning in DiscoveryManager.cpp, use
static_cast. The IdentityObject takes a CipUint anyway.

On Windows, setsocktopt() with SO_RCVTIMEO takes a uint32_t, but
std::chrono::duration::count() returnes a "signed integer type of at
least 45 bits" [1], so it also produces a warning.

[1]. https://en.cppreference.com/w/cpp/chrono/duration
  • Loading branch information
JohannesKauffmann committed Aug 15, 2022
commit 23eec082942762fefa0eddfc848324fb7348b0cb
4 changes: 2 additions & 2 deletions src/DiscoveryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace eipScanner {
CommonPacket commonPacket;
commonPacket.expand(std::vector<uint8_t>(data.begin()+EncapsPacket::HEADER_SIZE, data.end()));

for (int i=0; i < commonPacket.getItems().size(); ++i) {
for (size_t i = 0; i < commonPacket.getItems().size(); ++i) {
Buffer buffer(commonPacket.getItems()[i].getData());
CipUint ignore;
sockets::EndPoint socketAddr("", 0);
Expand All @@ -65,7 +65,7 @@ namespace eipScanner {
>> revision >> status
>> serialNumber >> productName;

IdentityObject identityObject(i);
IdentityObject identityObject(static_cast<cip::CipUint>(i));
identityObject.setVendorId(vendorId);
identityObject.setDeviceType(deviceType);
identityObject.setProductCode(productCode);
Expand Down
2 changes: 1 addition & 1 deletion src/cip/EPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace cip {
_attributeId = 0;
_size = 0;

for (int i = 0; i < data.size() && !buffer.empty(); ++i) {
for (size_t i = 0; i < data.size() && !buffer.empty(); ++i) {
EPathSegmentTypes segmentType;
CipUsint ignore = 0;
CipUsint byte;
Expand Down
2 changes: 1 addition & 1 deletion src/sockets/BaseSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace sockets {
_recvTimeout = recvTimeout;

#if defined(_WIN32) || defined(WIN32) || defined(_WIN64)
uint32_t ms = recvTimeout.count();
auto ms = uint32_t(recvTimeout.count());
setsockopt(_sockedFd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&ms, sizeof ms);
#else
timeval tv = makePortableInterval(recvTimeout);
Expand Down
2 changes: 1 addition & 1 deletion src/vendor/yaskawa/mp3300iec/Yaskawa_EPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace cip {
_attributeId = 0;
_size = 0;

for (int i = 0; i < data.size() && !buffer.empty(); ++i) {
for (size_t i = 0; i < data.size() && !buffer.empty(); ++i) {
EPathSegmentTypes segmentType;
CipUsint ignore = 0;
CipUsint byte;
Expand Down