From 4a4d30b5827087f16b8d9c65fde7043c505a3875 Mon Sep 17 00:00:00 2001 From: Jason Valenzuela Date: Thu, 10 Mar 2022 14:52:08 -0500 Subject: [PATCH] Fix data type for CPF address item count. Resolves warning about possible loss of data due to implicit integer conversion, e.g., Visual Studio C4244. --- source/src/enet_encap/cpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/src/enet_encap/cpf.c b/source/src/enet_encap/cpf.c index d8b4d9422..bcd2ae349 100644 --- a/source/src/enet_encap/cpf.c +++ b/source/src/enet_encap/cpf.c @@ -271,7 +271,9 @@ EipStatus CreateCommonPacketFormatStructure(const EipUint8 *data, return kEipStatusError; } - CipUsint address_item_count = common_packet_format_data->item_count - 2; + /* Data type per CIP Volume 2, Edition 1.4, Table 2-6.1. */ + CipUint address_item_count = (CipUint)(common_packet_format_data->item_count - 2U); + for(size_t j = 0; j < (address_item_count > 2 ? 2 : address_item_count); j++) /* TODO there needs to be a limit check here???*/ {