msgbuf: Bounds checks that satisfy GCC's analyzer

The intent is that there is no change in behavior, but that the code
patterns better match the analyzer's expectations.

Change-Id: I58544aaf6b15209e754059bf72a55dc9d63c9d61
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/tests/dsp/firmware_update.cpp b/tests/dsp/firmware_update.cpp
index dd867ff..8c2be11 100644
--- a/tests/dsp/firmware_update.cpp
+++ b/tests/dsp/firmware_update.cpp
@@ -1653,26 +1653,10 @@
     struct pldm_query_downstream_identifiers_resp resp_data = {};
     struct variable_field downstreamDevices = {};
 
-    /** In test mode, this will trigger an assert failure and cause the unit
-     * test to fail if only testing by the rc. Use ASSERT_DEATH to test this
-     * scenario.
-     *
-     *  The 1st parameter is the function under test.
-     *  The 2nd parameter compares the output of the program.
-     */
-#ifdef NDEBUG
     EXPECT_NE(decode_query_downstream_identifiers_resp(
                   response, responseMsg.size() - hdrSize, &resp_data,
                   &downstreamDevices),
               PLDM_SUCCESS);
-#else
-    EXPECT_DEATH(
-        decode_query_downstream_identifiers_resp(
-            response, responseMsg.size() - hdrSize, &resp_data,
-            &downstreamDevices),
-        // This error doesn't output any error message, leave it be empty
-        "");
-#endif
 }
 #endif
 
@@ -1919,24 +1903,9 @@
     pldm_downstream_device_parameter_entry entry{};
     variable_field versions{};
 
-    /** In test mode, this will trigger an assert failure and cause the unit
-     * test to fail if only testing by the rc. Use ASSERT_DEATH to test this
-     * scenario.
-     *
-     *  The 1st parameter is the function under test.
-     *  The 2nd parameter compares the output of the program.
-     */
-#ifdef NDEBUG
     EXPECT_NE(decode_downstream_device_parameter_table_entry(
                   &downstreamDeviceParamTable, &entry, &versions),
               0);
-#else
-    EXPECT_DEATH(
-        decode_downstream_device_parameter_table_entry(
-            &downstreamDeviceParamTable, &entry, &versions),
-        // This error doesn't output any error message, leave it be empty
-        "");
-#endif
 }
 #endif
 
diff --git a/tests/dsp/platform.cpp b/tests/dsp/platform.cpp
index a81319b..2d29445 100644
--- a/tests/dsp/platform.cpp
+++ b/tests/dsp/platform.cpp
@@ -3706,6 +3706,7 @@
     uint8_t rettransportProtocolType;
     uint8_t reteventReceiverAddressInfo;
     uint16_t retheartbeatTimer;
+
     rc = decode_set_event_receiver_req(
         request, requestMsg.size() - hdrSize - 1, &reteventMessageGlobalEnable,
         &rettransportProtocolType, &reteventReceiverAddressInfo,
@@ -5733,20 +5734,11 @@
         cperEventSize);
     EXPECT_EQ(rc, -EINVAL);
 
-#ifdef NDEBUG
     rc = decode_pldm_platform_cper_event(
         // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
         reinterpret_cast<uint8_t*>(eventData.data()), eventData.size() - 1,
         cperEvent, cperEventSize);
     EXPECT_EQ(rc, -EOVERFLOW);
-#else
-    EXPECT_DEATH(
-        decode_pldm_platform_cper_event(
-            // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
-            reinterpret_cast<uint8_t*>(eventData.data()), eventData.size() - 1,
-            cperEvent, cperEventSize),
-        "ctx->remaining >= 0");
-#endif
 
     rc = decode_pldm_platform_cper_event(
         // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)