Skip to content

Commit

Permalink
[DCT-5]: Fix unnecessary check on retcode in dds_strretcode
Browse files Browse the repository at this point in the history
  • Loading branch information
noxpardalis committed Aug 21, 2023
1 parent c9fcea7 commit d1c38e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ddsrt/src/retcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ const char *dds_strretcode (dds_return_t ret)
if (ret == INT32_MIN)
return xretcodes[0];

// INT32_MIN has already been handled and so this is safe
// and will guarantee ret >= 0.
if (ret < 0)
ret = -ret;
if (ret >= 0 && ret < nretcodes)
if (ret < nretcodes)
return retcodes[ret];
else if (ret >= (-DDS_XRETCODE_BASE) && ret < (-DDS_XRETCODE_BASE) + nxretcodes)
return xretcodes[ret - (-DDS_XRETCODE_BASE)];
Expand Down

0 comments on commit d1c38e3

Please sign in to comment.