msgbuf: Allow pldm_msgbuf_span_required to accept NULL

Allow pldm_msgbuf_span_required to accept NULL as an argument
so we can use this API to skip past data in the msg buffer which
is not required and extract only the relevant data.

Change-Id: I08d233b8efe415732fb7c01c00a9925f04666fe2
Signed-off-by: Varsha Kaverappa <vkaverap@in.ibm.com>
diff --git a/tests/msgbuf.cpp b/tests/msgbuf.cpp
index 111200a..7ddd2fb 100644
--- a/tests/msgbuf.cpp
+++ b/tests/msgbuf.cpp
@@ -873,6 +873,7 @@
     struct pldm_msgbuf* ctx = &_ctx;
     uint8_t src[6] = {0x11, 0x22, 0x44, 0x55, 0x66, 0x77};
     uint8_t buf[6] = {0};
+    const size_t required = 4;
     uint16_t testVal;
     [[maybe_unused]] uint8_t* retBuff = NULL;
 
@@ -887,6 +888,8 @@
     ASSERT_EQ(pldm_msgbuf_init_cc(ctxExtract, 0, buf, sizeof(buf)),
               PLDM_SUCCESS);
     EXPECT_EQ(pldm_msgbuf_extract_uint16(ctxExtract, &testVal), PLDM_SUCCESS);
+    EXPECT_EQ(pldm_msgbuf_span_required(ctxExtract, required, NULL),
+              PLDM_SUCCESS);
 
     EXPECT_EQ(pldm_msgbuf_destroy(ctxExtract), PLDM_SUCCESS);
     EXPECT_EQ(pldm_msgbuf_destroy(ctx), PLDM_SUCCESS);