Quellcode durchsuchen

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.
Jason Valenzuela vor 3 Jahren
Ursprung
Commit
4a4d30b582
1 geänderte Dateien mit 3 neuen und 1 gelöschten Zeilen
  1. 3 1
      source/src/enet_encap/cpf.c

+ 3 - 1
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???*/
     {