Просмотр исходного кода

Fixes several pointer type errors

Signed-off-by: CapXilinx <melik-merkumians@acin.tuwien.ac.at>
CapXilinx 8 лет назад
Родитель
Сommit
a96570aaf0

+ 25 - 25
source/src/cip/cipepath.c

@@ -72,7 +72,7 @@ const unsigned int kPortSegmentExtendedPort = 15; /**< Reserved port segment por
 
 
 /*** Path Segment ***/
-SegmentType GetPathSegmentType(const unsigned char *const cip_path) {
+SegmentType GetPathSegmentType(const CipOctet *const cip_path) {
   const unsigned int kSegmentTypeMask = 0xE0;
   const unsigned int segment_type = *cip_path & kSegmentTypeMask;
   SegmentType result = kSegmentTypeReserved;
@@ -194,7 +194,7 @@ unsigned int GetPathPortSegmentExtendedPortNumber(
 }
 
 void SetPathPortSegmentExtendedPortIdentifier(
-  const unsigned int extended_port_identifier, unsigned char *const cip_path) {
+  const unsigned int extended_port_identifier, CipOctet *const cip_path) {
   SetPathPortSegmentPortIdentifier(kPortSegmentExtendedPort, cip_path);
   const unsigned int kExtendedPortSegmentPosition =
     GetPathPortSegmentExtendedLinkAddressSizeBit(cip_path) == true ? 2 : 1;
@@ -246,7 +246,7 @@ LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
   return result;
 }
 
-void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, unsigned char *const cip_path) {
+void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, CipOctet *const cip_path) {
   OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
   switch (logical_type) {
       case kLogicalSegmentLogicalTypeClassId:
@@ -304,8 +304,8 @@ LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
   return result;
 }
 
-void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format, unsigned char *const cip_path) {
-  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType(cip_path) );
+void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format, CipOctet *const cip_path) {
+  OPENER_ASSERT( kSegmentTypeLogicalSegment == GetPathSegmentType((const CipOctet *)cip_path) );
   switch (format) {
     case kLogicalSegmentLogicalFormatEightBit:
       (*cip_path) |= LOGICAL_SEGMENT_FORMAT_EIGHT_BIT;
@@ -347,8 +347,8 @@ const CipDword CipEpathGetLogicalValue(const EipUint8 **message) {
 size_t CipEpathSetLogicalValue(const CipDword logical_value, const LogicalSegmentLogicalFormat logical_format, CipOctet **message) {
   switch(logical_value) {
     case kLogicalSegmentLogicalFormatEightBit: AddSintToMessage(logical_value, message); return 1; break;
-    case kLogicalSegmentLogicalFormatSixteenBit: MoveMessageNOctets(1, message); AddIntToMessage(logical_value, message); return 3; break;
-    case kLogicalSegmentLogicalFormatThirtyTwoBit: MoveMessageNOctets(1, message); AddDintToMessage(logical_value, message); return 5; break;
+    case kLogicalSegmentLogicalFormatSixteenBit: MoveMessageNOctets(1, (const CipOctet**)message); AddIntToMessage(logical_value, message); return 3; break;
+    case kLogicalSegmentLogicalFormatThirtyTwoBit: MoveMessageNOctets(1, (const CipOctet**)message); AddDintToMessage(logical_value, message); return 5; break;
   }
   OPENER_ASSERT(false); /* This should never happen! */
   return 0;
@@ -420,14 +420,14 @@ ElectronicKeySegmentFormat GetPathLogicalSegmentElectronicKeyFormat(
 void GetElectronicKeyFormat4FromMessage(
   const CipOctet **const message, ElectronicKeyFormat4 *key) {
   OPENER_ASSERT( kElectronicKeySegmentFormatKeyFormat4 ==
-                 GetPathLogicalSegmentElectronicKeyFormat(message) );
+                 GetPathLogicalSegmentElectronicKeyFormat(*message) );
 
   MoveMessageNOctets(2, message);
-  ElectronicKeyFormat4SetVendorId(key, GetIntFromMessage(&message));
-  ElectronicKeyFormat4SetDeviceType(key, GetIntFromMessage(&message));
-  ElectronicKeyFormat4SetProductCode(key, GetIntFromMessage(&message));
-  ElectronicKeyFormat4SetMajorRevisionCompatibility(key, GetSintFromMessage(&message));
-  ElectronicKeyFormat4SetMinorRevision(key, GetSintFromMessage(&message));
+  ElectronicKeyFormat4SetVendorId(key, GetIntFromMessage(message));
+  ElectronicKeyFormat4SetDeviceType(key, GetIntFromMessage(message));
+  ElectronicKeyFormat4SetProductCode(key, GetIntFromMessage(message));
+  ElectronicKeyFormat4SetMajorRevisionCompatibility(key, GetSintFromMessage(message));
+  ElectronicKeyFormat4SetMinorRevision(key, GetSintFromMessage(message));
 }
 
 /*** Logical Segment ***/
@@ -621,32 +621,32 @@ size_t CipEpathEncodeConnectionEpath(const CipConnectionPathEpath *const connect
 
 	size_t encoded_path_length = 0;
   {
-  SetPathSegmentType(kSegmentTypeLogicalSegment, encoded_path);
-  SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, encoded_path);
+  SetPathSegmentType(kSegmentTypeLogicalSegment, *encoded_path);
+  SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, *encoded_path);
   LogicalSegmentLogicalFormat logical_value = CipEpathGetNeededLogicalFormatForValue(connection_epath->class_id);
-  SetPathLogicalSegmentLogicalFormat(logical_value, encoded_path);
+  SetPathLogicalSegmentLogicalFormat(logical_value, *encoded_path);
   encoded_path_length += 1;
-  MoveMessageNOctets(1, encoded_path);
+  MoveMessageNOctets(1, (const CipOctet**)encoded_path);
   encoded_path_length += CipEpathSetLogicalValue(connection_epath->class_id, logical_value, encoded_path);
   }
 
   {
-  SetPathSegmentType(kSegmentTypeLogicalSegment, encoded_path);
-  SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, encoded_path);
+  SetPathSegmentType(kSegmentTypeLogicalSegment, *encoded_path);
+  SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, *encoded_path);
   LogicalSegmentLogicalFormat logical_value = CipEpathGetNeededLogicalFormatForValue(connection_epath->instance_id);
-  SetPathLogicalSegmentLogicalFormat(logical_value, encoded_path);
+  SetPathLogicalSegmentLogicalFormat(logical_value, *encoded_path);
   encoded_path_length += 1;
-  MoveMessageNOctets(1, encoded_path);
+  MoveMessageNOctets(1, (const CipOctet**)encoded_path);
   encoded_path_length += CipEpathSetLogicalValue(connection_epath->instance_id, logical_value, encoded_path);
   }
 
   if(0 != connection_epath->attribute_id_or_connection_point){
-    SetPathSegmentType(kSegmentTypeLogicalSegment, encoded_path);
-    SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, encoded_path);
+    SetPathSegmentType(kSegmentTypeLogicalSegment, *encoded_path);
+    SetPathLogicalSegmentLogicalType(kLogicalSegmentLogicalTypeClassId, *encoded_path);
     LogicalSegmentLogicalFormat logical_value = CipEpathGetNeededLogicalFormatForValue(connection_epath->attribute_id_or_connection_point);
-    SetPathLogicalSegmentLogicalFormat(logical_value, encoded_path);
+    SetPathLogicalSegmentLogicalFormat(logical_value, *encoded_path);
     encoded_path_length += 1;
-    MoveMessageNOctets(1, encoded_path);
+    MoveMessageNOctets(1, (const CipOctet**)encoded_path);
     encoded_path_length += CipEpathSetLogicalValue(connection_epath->attribute_id_or_connection_point, logical_value, encoded_path);
   }
   return encoded_path_length += 1;

+ 4 - 4
source/src/cip/cipepath.h

@@ -172,7 +172,7 @@ typedef struct connection_path_epath {
  * @param cip_path The start of the EPath message
  * @return The basic segment type
  */
-SegmentType GetPathSegmentType(const unsigned char *const cip_path);
+SegmentType GetPathSegmentType(const CipOctet *const cip_path);
 
 /** @brief Sets the basic segment type of an CIP EPath to be sent
  *
@@ -231,7 +231,7 @@ unsigned int GetPathPortSegmentExtendedPortNumber(
  * @param cip_path The start for the EPatch message
  */
 void SetPathPortSegmentExtendedPortIdentifier(
-  const unsigned int extended_port_identifier, unsigned char *const cip_path);
+  const unsigned int extended_port_identifier, CipOctet *const cip_path);
 
 /** @brief Gets the Logical Type of an EPath Logical Segment message
  *
@@ -241,7 +241,7 @@ void SetPathPortSegmentExtendedPortIdentifier(
 LogicalSegmentLogicalType GetPathLogicalSegmentLogicalType(
   const unsigned char *const cip_path);
 
-void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, unsigned char *const cip_path);
+void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, CipOctet *const cip_path);
 
 /** @brief Gets the Logical Format of a Logical Segment EPath message
  *
@@ -251,7 +251,7 @@ void SetPathLogicalSegmentLogicalType(LogicalSegmentLogicalType logical_type, un
 LogicalSegmentLogicalFormat GetPathLogicalSegmentLogicalFormat(
   const unsigned char *const cip_path);
 
-void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format, unsigned char *const cip_path);
+void SetPathLogicalSegmentLogicalFormat(LogicalSegmentLogicalFormat format, CipOctet *const cip_path);
 
 const CipDword CipEpathGetLogicalValue(const EipUint8 **message);
 

+ 1 - 1
source/src/utils/doublylinkedlist.c

@@ -32,7 +32,7 @@ void DoublyLinkedListDestroy(DoublyLinkedList *list) {
 }
 
 DoublyLinkedListNode *DoublyLinkedListNodeCreate(
-  void *data,
+  const void *const data,
   NodeMemoryAllocator const
   allocator) {
   DoublyLinkedListNode *new_node = (DoublyLinkedListNode *)allocator();

+ 1 - 1
source/src/utils/doublylinkedlist.h

@@ -40,7 +40,7 @@ void DoublyLinkedListInitialize(DoublyLinkedList *list,
 
 void DoublyLinkedListDestroy(DoublyLinkedList *list);
 
-DoublyLinkedListNode *DoublyLinkedListNodeCreate(void *data,
+DoublyLinkedListNode *DoublyLinkedListNodeCreate(const void *const data,
                                                  NodeMemoryAllocator allocator);
 
 void DoublyLinkedListNodeDestroy(const DoublyLinkedList *const list,