Skip to content

Commit

Permalink
Fix data parameter for attribute decoding functions.
Browse files Browse the repository at this point in the history
This involves two changes:

1. Remove const data qualifier from the CipAttributeDecodeFromMessage
   function pointer type. Decoding functions are intended to modify the
   attribute data, therefore the attribute data cannot be constant.

2. Make the data parameter for all decoding functions void * to match
   the CipAttributeDecodeFromMessage type.

Resolves compiler warnings about parameters differing from declaration,
e.g. C4028 and -Wincompatible-pointer-types.
  • Loading branch information
jvalenzuela authored and MartinMelikMerkumians committed Mar 6, 2024
1 parent 51c3d96 commit ee59c3d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions source/src/cip/cipassembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @return length of taken bytes
* -1 .. error
*/
int DecodeCipAssemblyAttribute3(CipByteArray *const data,
int DecodeCipAssemblyAttribute3(void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response);

Expand Down Expand Up @@ -152,7 +152,7 @@ EipStatus NotifyAssemblyConnectedDataReceived(CipInstance *const instance,
return AfterAssemblyDataReceived(instance);
}

int DecodeCipAssemblyAttribute3(CipByteArray *const data,
int DecodeCipAssemblyAttribute3(void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response)
{
Expand All @@ -163,15 +163,15 @@ int DecodeCipAssemblyAttribute3(CipByteArray *const data,

int number_of_decoded_bytes = -1;
OPENER_TRACE_INFO(" -> set Assembly attribute byte array\r\n");
CipByteArray *cip_byte_array = data;
CipByteArray *cip_byte_array = (CipByteArray *)data;

if(message_router_request->request_data_size < data->length) {
if(message_router_request->request_data_size < cip_byte_array->length) {
OPENER_TRACE_INFO(
"DecodeCipByteArray: not enough data received.\n");
message_router_response->general_status = kCipErrorNotEnoughData;
return number_of_decoded_bytes;
}
if(message_router_request->request_data_size > data->length) {
if(message_router_request->request_data_size > cip_byte_array->length) {
OPENER_TRACE_INFO(
"DecodeCipByteArray: too much data received.\n");
message_router_response->general_status = kCipErrorTooMuchData;
Expand Down
4 changes: 2 additions & 2 deletions source/src/cip/cipqos.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static CipQosDscpValues s_active_dscp = {
* @return length of taken bytes
* -1 .. error
*/
int DecodeCipQoSAttribute(CipUsint *const data,
int DecodeCipQoSAttribute(void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response) {

Expand All @@ -81,7 +81,7 @@ int DecodeCipQoSAttribute(CipUsint *const data,
CipUsint attribute_value_received = GetUsintFromMessage(&cip_message);
if (attribute_value_received < 64U) {

*data = attribute_value_received; //write value to attribute
*(CipUsint *)data = attribute_value_received; //write value to attribute

message_router_response->general_status = kCipErrorSuccess;
number_of_decoded_bytes = 1;
Expand Down
8 changes: 4 additions & 4 deletions source/src/cip/ciptcpipinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void EncodeCipLastConflictDetected(const void *const data,


int DecodeTcpIpInterfaceConfigurationControl( /* Attribute 3 */
CipDword *const data,
void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response) {

Expand All @@ -392,7 +392,7 @@ int DecodeTcpIpInterfaceConfigurationControl( /* Attribute 3 */
configuration_control_received &= (kTcpipCfgCtrlMethodMask
| kTcpipCfgCtrlDnsEnable);

*data = configuration_control_received;
*(CipDword *)data = configuration_control_received;
number_of_decoded_bytes = 4;
message_router_response->general_status = kCipErrorSuccess;
}
Expand Down Expand Up @@ -510,7 +510,7 @@ int DecodeCipTcpIpInterfaceHostName( /* Attribute 6 */
#endif /* defined (OPENER_TCPIP_IFACE_CFG_SETTABLE) && 0 != OPENER_TCPIP_IFACE_CFG_SETTABLE*/

int DecodeCipTcpIpInterfaceEncapsulationInactivityTimeout( /* Attribute 13 */
CipUint *const data,
void *const data,
CipMessageRouterRequest *const message_router_request,
CipMessageRouterResponse *const message_router_response) {

Expand All @@ -524,7 +524,7 @@ int DecodeCipTcpIpInterfaceEncapsulationInactivityTimeout( /* Attribute 13 */
kCipErrorInvalidAttributeValue;
} else {

*data = inactivity_timeout_received;
*(CipUint *)data = inactivity_timeout_received;
message_router_response->general_status = kCipErrorSuccess;
number_of_decoded_bytes = 2;

Expand Down
2 changes: 1 addition & 1 deletion source/src/cip/ciptypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ typedef void (*CipAttributeEncodeInMessage)(const void *const data,
ENIPMessage *const outgoing_message);

/** @brief self-describing data decoding for CIP types */
typedef int (*CipAttributeDecodeFromMessage)(const void *const data,
typedef int (*CipAttributeDecodeFromMessage)(void *const data,
CipMessageRouterRequest *
const message_router_request,
CipMessageRouterResponse *const
Expand Down

0 comments on commit ee59c3d

Please sign in to comment.