From d1c38e3461e92787a965eb393049002a92d38f0c Mon Sep 17 00:00:00 2001 From: Troy Karan Harrison <troy.harrison@zettascale.tech> Date: Mon, 31 Jul 2023 18:03:32 +0200 Subject: [PATCH] [DCT-5]: Fix unnecessary check on retcode in `dds_strretcode` --- src/ddsrt/src/retcode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ddsrt/src/retcode.c b/src/ddsrt/src/retcode.c index 0efc1e4c25..f39c90ac4a 100644 --- a/src/ddsrt/src/retcode.c +++ b/src/ddsrt/src/retcode.c @@ -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)];