Fix RtpStack static analysis Cppcheck - constVariable

- constVariable, shadowVariable, pointerSize
  and funcArgNamesDifferent warnings resolved
- buffer length rectified in RtpPacketTest

Bug: 260848240
Bug: 260847813
Bug: 260841034
Bug: 260842460
Test: VoLte/Video Call Test with device
      atest ImsMediaNativeTests
      Verified RTCP packets sent and received
Change-Id: I85eb96a795f2fed5167700ee440526418ac07c4b
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/interface/rtp/RtpImpl.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/interface/rtp/RtpImpl.h
index ec346ea..33c6d87 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/interface/rtp/RtpImpl.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/interface/rtp/RtpImpl.h
@@ -52,7 +52,7 @@
 
     eRtp_Bool rtpMemberLeaveInd(IN eRTP_LEAVE_REASON eLeaveReason, IN RtpDt_Int32 uiSsrc);
 
-    eRtp_Bool rtcpPacketSendInd(IN RtpBuffer* pobjRtcpPkt, IN RtpSession* pobjRtpSession);
+    eRtp_Bool rtcpPacketSendInd(IN RtpBuffer* pobjRtcpBuf, IN RtpSession* pobjRtpSession);
 
     eRtp_Bool rtcpAppPayloadReqInd(
             OUT RtpDt_UInt16& usSubType, OUT RtpDt_UInt32& uiName, OUT RtpBuffer* pobjPayload);
@@ -67,7 +67,7 @@
     RtpDt_Void* RtpStartTimer(IN RtpDt_UInt32 uiDuration, IN eRtp_Bool bRepeat,
             IN RTPCB_TIMERHANDLER pfnTimerCb, IN RtpDt_Void* pvData);
 
-    eRtp_Bool RtpStopTimer(IN RtpDt_Void* pTimerId, OUT RtpDt_Void** pUserData);
+    eRtp_Bool RtpStopTimer(IN RtpDt_Void* pTimerId, OUT RtpDt_Void** ppUserData);
 };
 
 #endif /* __RTP_IMPL_H_ */
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/interface/rtp/RtpService.h b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/interface/rtp/RtpService.h
index ace81d6..476bc34 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/interface/rtp/RtpService.h
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/interface/rtp/RtpService.h
@@ -72,7 +72,7 @@
  *
  * @param hRtpSession handle of the newly created session.
  */
-GLOBAL eRtp_Bool IMS_RtpSvc_CreateSession(IN RtpDt_Char* szLocalIP, IN RtpDt_UInt32 uiPort,
+GLOBAL eRtp_Bool IMS_RtpSvc_CreateSession(IN RtpDt_Char* szLocalIP, IN RtpDt_UInt32 port,
         IN RtpDt_Void* pAppData, OUT RtpDt_UInt32* puSsrc, OUT RTPSESSIONID* hRtpSession);
 
 /**
@@ -113,7 +113,7 @@
  * This API is should be called by the application to RTP encode and send the media
  * buffer to peer device.
  *
- * @param pobjIRtpSession media session Listener which will be used for sending the packet to
+ * @param pobjRtpServiceListener media session Listener which will be used for sending the packet to
  * network nodes after RTP encoding.
  *
  * @param hRtpSession A session handled associated with the media stream.
@@ -126,7 +126,7 @@
  * payload-type number, Flag to use Previous RTP time-stamp (Ex: used in case of DTMF),
  * time difference since last media packet/buffer.
  */
-GLOBAL eRtp_Bool IMS_RtpSvc_SendRtpPacket(IN RtpServiceListener* pobjIRtpSession,
+GLOBAL eRtp_Bool IMS_RtpSvc_SendRtpPacket(IN RtpServiceListener* pobjRtpServiceListener,
         IN RTPSESSIONID hRtpSession, IN RtpDt_Char* pBuffer, IN RtpDt_UInt16 wBufferLength,
         IN tRtpSvc_SendRtpPacketParm* pstRtpParam);
 
@@ -134,7 +134,7 @@
  * This API processes the received RTP packet. Processed information is sent using
  * callback OnPeerInd.
  *
- * @param pobjIRtpSession media session Listener used to call callback function and
+ * @param pobjRtpServiceListener media session Listener used to call callback function and
  * pass extracted information back to the caller
  *
  * @param hRtpSession A session handled associated with the media stream.
@@ -149,7 +149,7 @@
  *
  * @param uiPeerSsrc SSRC of the Sender.
  */
-GLOBAL eRtp_Bool IMS_RtpSvc_ProcRtpPacket(IN RtpServiceListener* pobjIRtpSession,
+GLOBAL eRtp_Bool IMS_RtpSvc_ProcRtpPacket(IN RtpServiceListener* pobjRtpServiceListener,
         IN RTPSESSIONID hRtpSession, IN RtpDt_UChar* pMsg, IN RtpDt_UInt16 uiMsgLength,
         IN RtpDt_Char* pPeerIp, IN RtpDt_UInt16 uiPeerPort, OUT RtpDt_UInt32& uiPeerSsrc);
 
@@ -201,8 +201,8 @@
  * @param uiMediaSsrc      SSRC of media source
  */
 GLOBAL eRtp_Bool IMS_RtpSvc_SendRtcpRtpFbPacket(IN RTPSESSIONID hRtpSession,
-        IN RtpDt_UInt32 uiFbType, IN RtpDt_Char* buff, IN RtpDt_UInt32 len,
-        IN RtpDt_UInt32 mediaSsrc);
+        IN RtpDt_UInt32 uiFbType, IN RtpDt_Char* pcBuff, IN RtpDt_UInt32 uiLen,
+        IN RtpDt_UInt32 uiMediaSsrc);
 
 /**
  * Method for sending RTCP Fb message.
@@ -214,13 +214,13 @@
  * @param uiMediaSsrc      SSRC of media source
  */
 GLOBAL eRtp_Bool IMS_RtpSvc_SendRtcpPayloadFbPacket(IN RTPSESSIONID hRtpSession,
-        IN RtpDt_UInt32 uiFbType, IN RtpDt_Char* buff, IN RtpDt_UInt32 len,
-        IN RtpDt_UInt32 mediaSsrc);
+        IN RtpDt_UInt32 uiFbType, IN RtpDt_Char* pcBuff, IN RtpDt_UInt32 uiLen,
+        IN RtpDt_UInt32 uiMediaSsrc);
 
 /**
  * Method for processing incoming RTCP packets.
  *
- * @param pobjIRtpSession   Media session Listener for sending processed info via callbacks
+ * @param pobjRtpServiceListener   Media session Listener for sending processed info via callbacks
  * @param hRtpSession       RTP session handle
  * @param pMsg              Received RTCP packet buffer
  * @param uiMsgLength       RTCP buffer length in bytes
@@ -228,7 +228,7 @@
  * @param uiRtcpPort        RTCP Port number
  * @param uiPeerSsrc        SSRC of the Source
  */
-GLOBAL eRtp_Bool IMS_RtpSvc_ProcRtcpPacket(IN RtpServiceListener* pobjIRtpSession,
+GLOBAL eRtp_Bool IMS_RtpSvc_ProcRtcpPacket(IN RtpServiceListener* pobjRtpServiceListener,
         IN RTPSESSIONID hRtpSession, IN RtpDt_UChar* pMsg, IN RtpDt_UInt16 uiMsgLength,
         IN RtpDt_Char* pcIpAddr, IN RtpDt_UInt32 uiRtcpPort, OUT RtpDt_UInt32* uiPeerSsrc);
 /**
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/RtpImpl.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/RtpImpl.cpp
index c23b6d9..beeaeb6 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/RtpImpl.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/RtpImpl.cpp
@@ -58,15 +58,17 @@
 eRtp_Bool RtpImpl::rtcpPacketSendInd(IN RtpBuffer* pobjRtcpBuf, IN RtpSession* pobjRtpSession)
 {
     RTP_TRACE_MESSAGE("rtcpPacketSendInd", 0, 0);
-    RtpServiceListener* pobjIRtpSession = reinterpret_cast<RtpServiceListener*>(getAppdata());
-    if (pobjIRtpSession == RTP_NULL || pobjRtcpBuf == RTP_NULL || pobjRtpSession == RTP_NULL)
+    RtpServiceListener* pobjRtpServiceListener =
+            reinterpret_cast<RtpServiceListener*>(getAppdata());
+    if (pobjRtpServiceListener == RTP_NULL || pobjRtcpBuf == RTP_NULL || pobjRtpSession == RTP_NULL)
     {
         RTP_TRACE_ERROR("RTCP send failed. No listeners are set", 0, 0);
         return eRTP_FALSE;
     }
 
     // dispatch to peer
-    if (pobjIRtpSession->OnRtcpPacket(pobjRtcpBuf->getBuffer(), pobjRtcpBuf->getLength()) == -1)
+    if (pobjRtpServiceListener->OnRtcpPacket(pobjRtcpBuf->getBuffer(), pobjRtcpBuf->getLength()) ==
+            -1)
     {
         RTP_TRACE_ERROR("Send RTCP: IRTPSession returned Error", 0, 0);
         pobjRtcpBuf->setBufferInfo(RTP_ZERO, RTP_NULL);
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/RtpService.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/RtpService.cpp
index dec491e..ec67204 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/RtpService.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/RtpService.cpp
@@ -390,7 +390,7 @@
     return eRTP_TRUE;
 }
 
-GLOBAL eRtp_Bool IMS_RtpSvc_SendRtpPacket(IN RtpServiceListener* pobjIRtpSession,
+GLOBAL eRtp_Bool IMS_RtpSvc_SendRtpPacket(IN RtpServiceListener* pobjRtpServiceListener,
         IN RTPSESSIONID hRtpSession, IN RtpDt_Char* pBuffer, IN RtpDt_UInt16 wBufferLength,
         IN tRtpSvc_SendRtpPacketParm* pstRtpParam)
 {
@@ -458,7 +458,7 @@
     }
 
     // dispatch to peer
-    if (pobjIRtpSession->OnRtpPacket(pobjRtpBuf->getBuffer(), pobjRtpBuf->getLength()) == -1)
+    if (pobjRtpServiceListener->OnRtpPacket(pobjRtpBuf->getBuffer(), pobjRtpBuf->getLength()) == -1)
     {
         delete pobjRtpBuf;
         RTP_TRACE_WARNING("On Rtp packet failed ..! OnRtpPacket", RTP_ZERO, RTP_ZERO);
@@ -638,7 +638,7 @@
     return eRTP_TRUE;
 }
 
-GLOBAL eRtp_Bool IMS_RtpSvc_ProcRtcpPacket(IN RtpServiceListener* pobjIRtpSession,
+GLOBAL eRtp_Bool IMS_RtpSvc_ProcRtcpPacket(IN RtpServiceListener* pobjRtpServiceListener,
         IN RTPSESSIONID hRtpSession, IN RtpDt_UChar* pMsg, IN RtpDt_UInt16 uiMsgLength,
         IN RtpDt_Char* pcIpAddr, IN RtpDt_UInt32 uiRtcpPort, OUT RtpDt_UInt32* uiPeerSsrc)
 {
@@ -689,11 +689,11 @@
 
         if (populateRcvdSrInfoFromStk(pobjSrList, &stSrRtcpMsg) == eRTP_TRUE)
         {
-            pobjIRtpSession->OnPeerInd(stackInd, (RtpDt_Void*)&stSrRtcpMsg);
+            pobjRtpServiceListener->OnPeerInd(stackInd, (RtpDt_Void*)&stSrRtcpMsg);
         }
 
         RtpDt_UInt32 rttd = pobjRtpSession->getRTTD();
-        pobjIRtpSession->OnPeerRtcpComponents((RtpDt_Void*)&rttd);
+        pobjRtpServiceListener->OnPeerRtcpComponents((RtpDt_Void*)&rttd);
     }
     else
     {
@@ -705,11 +705,11 @@
 
             if (populateRcvdRrInfoFromStk(pobjRrList, &stRrRtcpMsg) == eRTP_TRUE)
             {
-                pobjIRtpSession->OnPeerInd(stackInd, (RtpDt_Void*)&stRrRtcpMsg);
+                pobjRtpServiceListener->OnPeerInd(stackInd, (RtpDt_Void*)&stRrRtcpMsg);
             }
 
             RtpDt_UInt32 rttd = pobjRtpSession->getRTTD();
-            pobjIRtpSession->OnPeerRtcpComponents((RtpDt_Void*)&rttd);
+            pobjRtpServiceListener->OnPeerRtcpComponents((RtpDt_Void*)&rttd);
         }
     }  // end else
 
@@ -730,7 +730,7 @@
         }
         tRtpSvcIndSt_ReceiveRtcpFeedbackInd stFbRtcpMsg;
         if (populateRcvdFbInfoFromStk(pobjFbPkt, &stFbRtcpMsg) == eRTP_TRUE)
-            pobjIRtpSession->OnPeerInd(stackInd, (RtpDt_Void*)&stFbRtcpMsg);
+            pobjRtpServiceListener->OnPeerInd(stackInd, (RtpDt_Void*)&stFbRtcpMsg);
     }  // pobjFbList End
 
     return eRTP_TRUE;
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpByePacket.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpByePacket.cpp
index c16eb7c..fc16168 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpByePacket.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpByePacket.cpp
@@ -25,13 +25,13 @@
 
 RtcpByePacket::~RtcpByePacket()
 {
-    for (auto& puiSsrc : m_uiSsrcList)
+    // delete all ssrc objects
+    for (const auto& puiSsrc : m_uiSsrcList)
     {
         delete puiSsrc;
     }
     m_uiSsrcList.clear();
 
-    // m_pReason
     if (m_pReason != RTP_NULL)
     {
         delete m_pReason;
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpChunk.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpChunk.cpp
index 999a3bf..e2cdcbd 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpChunk.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpChunk.cpp
@@ -25,7 +25,8 @@
 
 RtcpChunk::~RtcpChunk()
 {
-    for (auto& pstSdesItem : m_stSdesItemList)
+    // delete all tRTCP_SDES_ITEM objects from SdesItemList
+    for (const auto& pstSdesItem : m_stSdesItemList)
     {
         if (pstSdesItem->pValue != RTP_NULL)
         {
@@ -125,7 +126,6 @@
     pucBuffer = pucBuffer + RTP_WORD_SIZE;
     uiCurPos = uiCurPos + RTP_WORD_SIZE;
 
-    // m_stSdesItemList
     eRtp_Bool bCName = eRTP_FALSE;
 
     for (auto& pstSdesItem : m_stSdesItemList)
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpPacket.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpPacket.cpp
index 8069ba6..b1ec0f5 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpPacket.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpPacket.cpp
@@ -34,21 +34,21 @@
 RtcpPacket::~RtcpPacket()
 {
     // delete all RtcpSrPacket objects.
-    for (auto& pobjSrPkt : m_objSrPktList)
+    for (const auto& pobjSrPkt : m_objSrPktList)
     {
         delete pobjSrPkt;
     }
     m_objSrPktList.clear();
 
     // delete all RtcpRrPacket objects
-    for (auto& pobjRrPkt : m_objRrPktList)
+    for (const auto& pobjRrPkt : m_objRrPktList)
     {
         delete pobjRrPkt;
     }
     m_objRrPktList.clear();
 
     // delete all RtcpFbPacket objects
-    for (auto& pobjFbPkt : m_objFbPktList)
+    for (const auto& pobjFbPkt : m_objFbPktList)
     {
         delete pobjFbPkt;
     }
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpRrPacket.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpRrPacket.cpp
index 8f277da..1b76f1f 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpRrPacket.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpRrPacket.cpp
@@ -26,14 +26,13 @@
 
 RtcpRrPacket::~RtcpRrPacket()
 {
-    // m_objReportBlkList
-    for (auto& pobjReptBlk : m_objReportBlkList)
+    // delete all RtcpReportBlock objects
+    for (const auto& pobjReptBlk : m_objReportBlkList)
     {
         delete pobjReptBlk;
     }
     m_objReportBlkList.clear();
 
-    // m_pobjExt
     if (m_pobjExt != RTP_NULL)
     {
         delete m_pobjExt;
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpSdesPacket.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpSdesPacket.cpp
index 09f14a3..72b02d2 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpSdesPacket.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtcpSdesPacket.cpp
@@ -24,7 +24,8 @@
 
 RtcpSdesPacket::~RtcpSdesPacket()
 {
-    for (auto& pobjSdesChunk : m_objSdesChunkList)
+    // delete all RtcpChunk objects
+    for (const auto& pobjSdesChunk : m_objSdesChunkList)
     {
         delete pobjSdesChunk;
     }
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpSession.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpSession.cpp
index 9e9826b..8a1f99a 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpSession.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpSession.cpp
@@ -56,8 +56,6 @@
         m_bisXr(eRTP_FALSE),
         m_bFirstRtpRecvd(eRTP_FALSE)
 {
-    // tRTP_NTP_TIME stNtpTs = {RTP_ZERO, RTP_ZERO};
-
     m_pobjRtcpCfgInfo = new RtcpConfigInfo();
     m_pobjRtpRcvrInfoList = new std::list<RtpReceiverInfo*>();
     m_pobjPayloadInfo = new RtpPayloadInfo();
@@ -828,7 +826,7 @@
 RtpDt_Void RtpSession::cleanUtlReceiverList()
 {
     // populate report blocks
-    for (auto& pobjRcvrElm : *m_pobjUtlRcvrList)
+    for (const auto& pobjRcvrElm : *m_pobjUtlRcvrList)
     {
         delete pobjRcvrElm;
     }
@@ -1928,8 +1926,6 @@
 eRTP_STATUS_CODE RtpSession::processRcvdRtcpPkt(IN RtpBuffer* pobjRtcpAddr, IN RtpDt_UInt16 usPort,
         IN RtpBuffer* pobjRTCPBuf, OUT RtcpPacket* pobjRtcpPkt)
 {
-    tRTP_NTP_TIME stNtpTs;
-
     if (m_bEnableRTCP != eRTP_TRUE)
     {
         RTP_TRACE_WARNING("[ProcessRcvdRtcpPkt], RTCP is not enabled", RTP_ZERO, RTP_ZERO);
@@ -1948,6 +1944,7 @@
     RtpDt_UInt16 usExtHdrLen = RTP_ZERO;
     eRTP_STATUS_CODE eDecodeStatus = RTP_FAILURE;
 
+    tRTP_NTP_TIME stNtpTs = {RTP_ZERO, RTP_ZERO};
     RtpOsUtil::GetNtpTime(stNtpTs);
     RtpDt_UInt32 currentTime = RtpStackUtil::getMidFourOctets(&stNtpTs);
     // decode compound packet
@@ -1990,7 +1987,7 @@
         RtpReceiverInfo* pobjRcvInfo = processRtcpPkt(uiRcvdSsrc, pobjRtcpAddr, usPort);
         if (pobjRcvInfo != RTP_NULL)
         {
-            tRTP_NTP_TIME stNtpTs;
+            stNtpTs = {RTP_ZERO, RTP_ZERO};
             pobjRcvInfo->setpreSrTimestamp(pobjSrPkt->getNtpTime());
             RtpOsUtil::GetNtpTime(stNtpTs);
             pobjRcvInfo->setLastSrNtpTimestamp(&stNtpTs);
diff --git a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpSessionManager.cpp b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpSessionManager.cpp
index 71b3352..4b3fb38 100644
--- a/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpSessionManager.cpp
+++ b/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpSessionManager.cpp
@@ -48,7 +48,7 @@
 
 eRtp_Bool RtpSessionManager::isValidRtpSession(IN RtpDt_Void* pvData)
 {
-    for (auto& pobjActiveSession : m_objActiveSessionList)
+    for (const auto& pobjActiveSession : m_objActiveSessionList)
     {
         if (pobjActiveSession == RTP_NULL)
         {
diff --git a/tests/native/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpPacketTest.cpp b/tests/native/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpPacketTest.cpp
index cc72502..e757140 100644
--- a/tests/native/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpPacketTest.cpp
+++ b/tests/native/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/core/RtpPacketTest.cpp
@@ -33,26 +33,24 @@
 
     uint8_t pRtpPayLoad[] = {0x67, 0x42, 0xc0, 0x0c, 0xda, 0x0f, 0x0a, 0x69, 0xa8, 0x10, 0x10, 0x10,
             0x3c, 0x58, 0xba, 0x80};
-    const RtpDt_UInt32 uiLength = sizeof(pRtpPayLoad) / sizeof(pRtpPayLoad[0]);
 
-    RtpBuffer* rtpPayloadBuffer = new RtpBuffer(uiLength, pRtpPayLoad);
+    RtpBuffer* rtpPayloadBuffer = new RtpBuffer(sizeof(pRtpPayLoad), pRtpPayLoad);
     rtpPacket.setRtpPayload(rtpPayloadBuffer);
     RtpBuffer* pobjRtpBuffer = rtpPacket.getRtpPayload();
     ASSERT_TRUE(pobjRtpBuffer != NULL);
 
-    EXPECT_EQ(memcmp(pRtpPayLoad, pobjRtpBuffer->getBuffer(), uiLength), 0);
-    EXPECT_EQ(pobjRtpBuffer->getLength(), uiLength);
+    EXPECT_EQ(memcmp(pRtpPayLoad, pobjRtpBuffer->getBuffer(), sizeof(pRtpPayLoad)), 0);
+    EXPECT_EQ(pobjRtpBuffer->getLength(), sizeof(pRtpPayLoad));
 
     uint8_t pRtpExtHdr[] = {0x41, 0x00, 0x00};
-    const RtpDt_UInt32 uiExtLength = sizeof(pRtpExtHdr) / sizeof(pRtpExtHdr[0]);
 
-    RtpBuffer* rtpExtBuffer = new RtpBuffer(uiExtLength, pRtpExtHdr);
+    RtpBuffer* rtpExtBuffer = new RtpBuffer(sizeof(pRtpExtHdr), pRtpExtHdr);
     rtpPacket.setExtHeader(rtpExtBuffer);
     RtpBuffer* pobjRtpExtHdr = rtpPacket.getExtHeader();
 
     ASSERT_TRUE(pobjRtpBuffer != NULL);
-    EXPECT_EQ(memcmp(pRtpExtHdr, pobjRtpExtHdr->getBuffer(), uiExtLength), 0);
-    EXPECT_EQ(pobjRtpExtHdr->getLength(), uiExtLength);
+    EXPECT_EQ(memcmp(pRtpExtHdr, pobjRtpExtHdr->getBuffer(), sizeof(pRtpExtHdr)), 0);
+    EXPECT_EQ(pobjRtpExtHdr->getLength(), sizeof(pRtpExtHdr));
 }
 
 TEST(RtpPacketTest, TestDecodePacket)
@@ -135,7 +133,7 @@
             0x02, 0xbe, 0xde, 0x00, 0x01, 0x41, 0x78, 0x42, 0x00, 0x67, 0x42, 0xc0, 0x0c, 0xda,
             0x0f, 0x0a, 0x69, 0xa8, 0x10, 0x10, 0x10, 0x3c, 0x58, 0xba, 0x80};
 
-    RtpBuffer rtpBuffer(sizeof(pobjRtpPktBuf) / sizeof(pobjRtpPktBuf[0]), pobjRtpPktBuf);
+    RtpBuffer rtpBuffer(sizeof(pobjRtpPktBuf), pobjRtpPktBuf);
     eRtp_Bool eResult = rtpPacket.decodePacket(&rtpBuffer);
 
     // check for failure as Rtp version is wrong.
@@ -169,7 +167,7 @@
     uint8_t pobjRtpPktBuf[] = {0x50, 0xe3, 0xa5, 0x83, 0x00, 0x00, 0xe1, 0xc8, 0x92, 0x7d, 0xcd,
             0x02, 0xbe, 0xde, 0x00, 0x02, 0x41, 0x78, 0x42, 0x00};
 
-    RtpBuffer rtpBuffer(sizeof(pobjRtpPktBuf) / sizeof(pobjRtpPktBuf[0]), pobjRtpPktBuf);
+    RtpBuffer rtpBuffer(sizeof(pobjRtpPktBuf), pobjRtpPktBuf);
     eRtp_Bool eResult = rtpPacket.decodePacket(&rtpBuffer);
 
     // check for failure as Extension length is wrong.
@@ -205,7 +203,7 @@
             0x02, 0xbe, 0xde, 0x00, 0x01, 0x41, 0x78, 0x42, 0x00, 0x67, 0x42, 0xc0, 0x0c, 0xda,
             0x0f, 0x0a, 0x69, 0xa8, 0x10, 0x10, 0x10, 0x3c, 0x58, 0xba, 0x80, 0x00, 0x02};
 
-    RtpBuffer rtpBuffer(sizeof(pobjRtpPktBuf) / sizeof(pobjRtpPktBuf[0]), pobjRtpPktBuf);
+    RtpBuffer rtpBuffer(sizeof(pobjRtpPktBuf), pobjRtpPktBuf);
     eRtp_Bool eResult = rtpPacket.decodePacket(&rtpBuffer);
 
     // check for padding.
@@ -216,11 +214,10 @@
     RtpBuffer* pobjRtpBuffer = rtpPacket.getRtpPayload();
     uint8_t pRtpPayLoad[] = {0x67, 0x42, 0xc0, 0x0c, 0xda, 0x0f, 0x0a, 0x69, 0xa8, 0x10, 0x10, 0x10,
             0x3c, 0x58, 0xba, 0x80};
-    const RtpDt_UInt32 uiLength = sizeof(pRtpPayLoad) / sizeof(pRtpPayLoad[0]);
 
     ASSERT_TRUE(pobjRtpBuffer != NULL);
-    EXPECT_EQ(memcmp(pRtpPayLoad, pobjRtpBuffer->getBuffer(), uiLength), 0);
-    EXPECT_EQ(pobjRtpBuffer->getLength(), uiLength);
+    EXPECT_EQ(memcmp(pRtpPayLoad, pobjRtpBuffer->getBuffer(), sizeof(pRtpPayLoad)), 0);
+    EXPECT_EQ(pobjRtpBuffer->getLength(), sizeof(pRtpPayLoad));
 }
 
 TEST(RtpPacketTest, TestFormPacketwithoutExtension)
@@ -241,14 +238,14 @@
     // set RtpPayload
     uint8_t pRtpPayLoad[] = {0x67, 0x42, 0xc0, 0x0c, 0xda, 0x0f, 0x0a, 0x69, 0xa8, 0x10, 0x10, 0x10,
             0x3c, 0x58, 0xba, 0x80};
-    const RtpDt_UInt32 uiRtpPayLoadLength = sizeof(pRtpPayLoad) / sizeof(pRtpPayLoad[0]);
+
     RtpBuffer* pobjRtpPayloadBuf = new RtpBuffer();
-    RtpDt_UChar* pucRtpPayLoadBuffer = new RtpDt_UChar[uiRtpPayLoadLength];
-    memcpy(pucRtpPayLoadBuffer, pRtpPayLoad, uiRtpPayLoadLength);
-    pobjRtpPayloadBuf->setBufferInfo(uiRtpPayLoadLength, pucRtpPayLoadBuffer);
+    RtpDt_UChar* pucRtpPayLoadBuffer = new RtpDt_UChar[sizeof(pRtpPayLoad)];
+    memcpy(pucRtpPayLoadBuffer, pRtpPayLoad, sizeof(pRtpPayLoad));
+    pobjRtpPayloadBuf->setBufferInfo(sizeof(pRtpPayLoad), pucRtpPayLoadBuffer);
     rtpPacket.setRtpPayload(pobjRtpPayloadBuf);
 
-    const RtpDt_UInt32 uiRtpLength = RTP_FIXED_HDR_LEN + uiRtpPayLoadLength;
+    const RtpDt_UInt32 uiRtpLength = RTP_FIXED_HDR_LEN + sizeof(pRtpPayLoad);
 
     // define expected Rtp packet.
     uint8_t pExpectedBuffer[uiRtpLength] = {0x80, 0x7f, 0xb0, 0x45, 0x00, 0x01, 0x36, 0x6a, 0xae,
@@ -303,24 +300,25 @@
 
     // set RtpExtension
     uint8_t pRtpExtension[] = {0xbe, 0xde, 0x00, 0x01, 0x41, 0x78, 0x42, 0x00};
-    const RtpDt_UInt32 uiRtpExtensionLength = sizeof(pRtpExtension) / sizeof(pRtpExtension[0]);
+
     RtpBuffer* pobjpRtpExtensionBuf = new RtpBuffer();
-    RtpDt_UChar* pucRtpExtensionBuffer = new RtpDt_UChar[uiRtpExtensionLength];
-    memcpy(pucRtpExtensionBuffer, pRtpExtension, uiRtpExtensionLength);
-    pobjpRtpExtensionBuf->setBufferInfo(uiRtpExtensionLength, pucRtpExtensionBuffer);
+    RtpDt_UChar* pucRtpExtensionBuffer = new RtpDt_UChar[sizeof(pRtpExtension)];
+    memcpy(pucRtpExtensionBuffer, pRtpExtension, sizeof(pRtpExtension));
+    pobjpRtpExtensionBuf->setBufferInfo(sizeof(pRtpExtension), pucRtpExtensionBuffer);
     rtpPacket.setExtHeader(pobjpRtpExtensionBuf);
 
     // set RtpPayload
     uint8_t pRtpPayLoad[] = {0x67, 0x42, 0xc0, 0x0c, 0xda, 0x0f, 0x0a, 0x69, 0xa8, 0x10, 0x10, 0x10,
             0x3c, 0x58, 0xba, 0x80};
-    const RtpDt_UInt32 uiRtpPayLoadLength = sizeof(pRtpPayLoad) / sizeof(pRtpPayLoad[0]);
+
     RtpBuffer* pobjRtpPayloadBuf = new RtpBuffer();
-    RtpDt_UChar* pucRtpPayLoadBuffer = new RtpDt_UChar[uiRtpPayLoadLength];
-    memcpy(pucRtpPayLoadBuffer, pRtpPayLoad, uiRtpPayLoadLength);
-    pobjRtpPayloadBuf->setBufferInfo(uiRtpPayLoadLength, pucRtpPayLoadBuffer);
+    RtpDt_UChar* pucRtpPayLoadBuffer = new RtpDt_UChar[sizeof(pRtpPayLoad)];
+    memcpy(pucRtpPayLoadBuffer, pRtpPayLoad, sizeof(pRtpPayLoad));
+    pobjRtpPayloadBuf->setBufferInfo(sizeof(pRtpPayLoad), pucRtpPayLoadBuffer);
     rtpPacket.setRtpPayload(pobjRtpPayloadBuf);
 
-    const RtpDt_UInt32 uiRtpLength = RTP_FIXED_HDR_LEN + uiRtpExtensionLength + uiRtpPayLoadLength;
+    const RtpDt_UInt32 uiRtpLength =
+            RTP_FIXED_HDR_LEN + sizeof(pRtpExtension) + sizeof(pRtpPayLoad);
 
     // define expected Rtp packet output.
     uint8_t pExpectedBuffer[] = {0x90, 0xe3, 0xa5, 0x83, 0x00, 0x00, 0xe1, 0xc8, 0x92, 0x7d, 0xcd,
diff --git a/tests/native/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/utils/RtpBufferTest.cpp b/tests/native/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/utils/RtpBufferTest.cpp
index 38a974d..9a4c80e 100644
--- a/tests/native/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/utils/RtpBufferTest.cpp
+++ b/tests/native/service/src/com/android/telephony/imsmedia/lib/libimsmedia/protocol/rtp/utils/RtpBufferTest.cpp
@@ -56,11 +56,12 @@
 
 TEST_F(RtpBufferTest, SetBufferInfoTest)
 {
-    RtpDt_UChar* pBuf = new RtpDt_UChar[8];
-    memcpy(pBuf, (RtpDt_UChar[]){0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, sizeof pBuf);
-    testBuf->setBufferInfo(sizeof pBuf, pBuf);
-    EXPECT_EQ(8, testBuf->getLength());
-    EXPECT_EQ(0, memcmp(testBuf->getBuffer(), pBuf, 8));
+    RtpDt_UChar* pBuf = new RtpDt_UChar[7];
+    uint8_t expectedBuf[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+    memcpy(pBuf, expectedBuf, sizeof(expectedBuf));
+    testBuf->setBufferInfo(sizeof(expectedBuf), pBuf);
+    EXPECT_EQ(7, testBuf->getLength());
+    EXPECT_EQ(0, memcmp(testBuf->getBuffer(), pBuf, 7));
 }
 
 }  // namespace android