Skip to content

Commit

Permalink
Replace path word size constants with sizeof().
Browse files Browse the repository at this point in the history
Resolves some signed/unsigned comparison warnings, e.g., Visual
Studio C4018 and C4389, and removes some magic numbers.
  • Loading branch information
jvalenzuela authored and MartinMelikMerkumians committed Sep 25, 2023
1 parent f59f486 commit ff1f3d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion source/src/cip/cipcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,8 +1378,10 @@ void EncodeEPath(const CipEpath *const epath,
}
}

/* path size is in 16 bit chunks according to the specification */
OPENER_ASSERT(
epath->path_size * 2 == message->used_message_length - start_length); /* path size is in 16 bit chunks according to the specification */
epath->path_size * sizeof(CipWord) ==
message->used_message_length - start_length);
}

int DecodePaddedEPath(CipEpath *epath,
Expand Down
4 changes: 2 additions & 2 deletions source/src/cip/cipconnectionmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,14 +1352,14 @@ EipUint8 ParseConnectionPath(CipConnectionObject *connection_object,
header_length = g_kLargeForwardOpenHeaderLength;
}

if( (header_length + remaining_path * 2) <
if( ( header_length + remaining_path * sizeof(CipWord) ) <
message_router_request->request_data_size ) {
/* the received packet is larger than the data in the path */
*extended_error = 0;
return kCipErrorTooMuchData;
}

if( (header_length + remaining_path * 2) >
if( ( header_length + remaining_path * sizeof(CipWord) ) >
message_router_request->request_data_size ) {
/*there is not enough data in received packet */
*extended_error = 0;
Expand Down

0 comments on commit ff1f3d6

Please sign in to comment.