Remove the now unused count parameter to WelsStrncpy

Also remove manual null termination as WelsStrncpy now always
takes care of it.
This commit is contained in:
Martin Storsjö 2014-01-28 12:12:42 +02:00
parent a16ccc0b4d
commit 9840f11784
6 changed files with 11 additions and 15 deletions

View File

@ -74,7 +74,7 @@ int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFor
return iRc;
}
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc) {
strncpy_s (pDest, iSizeInBytes, kpSrc, _TRUNCATE);
return pDest;
@ -130,7 +130,7 @@ int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFor
return iRc;
}
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc) {
strncpy (pDest, kpSrc, iSizeInBytes); //confirmed_safe_unsafe_usage
pDest[iSizeInBytes - 1] = '\0';
@ -188,7 +188,7 @@ int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFor
return iRc;
}
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc) {
strncpy (pDest, kpSrc, iSizeInBytes); //confirmed_safe_unsafe_usage
pDest[iSizeInBytes - 1] = '\0';
return pDest;

View File

@ -76,7 +76,7 @@ typedef struct timeb SWelsTime;
#endif
int32_t WelsSnprintf (str_t* buffer, int32_t sizeOfBuffer, const str_t* format, ...);
str_t* WelsStrncpy (str_t* dest, int32_t sizeInBytes, const str_t* src, int32_t count);
str_t* WelsStrncpy (str_t* dest, int32_t sizeInBytes, const str_t* src);
str_t* WelsStrcat (str_t* dest, int32_t sizeInBytes, str_t* src);
int32_t WelsVsnprintf (str_t* buffer, int32_t sizeOfBuffer, const str_t* format, va_list argptr);

View File

@ -62,7 +62,7 @@ int32_t CWelsTraceBase::Trace (const int kLevel, const str_t* kpFormat, va_list
str_t chBuf[MAX_LOG_SIZE] = {0};
const int32_t kLen = strlen ("[DECODER]: ");
WelsStrncpy (chBuf, MAX_LOG_SIZE, (const str_t*)"[DECODER]: ", kLen);
WelsStrncpy (chBuf, MAX_LOG_SIZE, (const str_t*)"[DECODER]: ");
WelsVsnprintf ((chBuf + kLen), MAX_LOG_SIZE - kLen, (const str_t*)kpFormat, pVl);

View File

@ -68,8 +68,7 @@ int32_t GetCodeName (str_t* pBuf, int32_t iSize) {
if (iSize <= iLen)
return 0;
pBuf[iLen] = '\0';
WelsStrncpy (pBuf, iSize, WELS_CODE_NAME, iLen); // confirmed_safe_unsafe_usage
WelsStrncpy (pBuf, iSize, WELS_CODE_NAME); // confirmed_safe_unsafe_usage
return iLen;
}
@ -90,8 +89,7 @@ int32_t GetLibName (str_t* pBuf, int32_t iSize) {
if (iSize <= iLen)
return 0;
pBuf[iLen] = '\0';
WelsStrncpy (pBuf, iSize, WELS_LIB_NAME, iLen); // confirmed_safe_unsafe_usage
WelsStrncpy (pBuf, iSize, WELS_LIB_NAME); // confirmed_safe_unsafe_usage
return iLen;
}
@ -112,8 +110,7 @@ int32_t GetVerNum (str_t* pBuf, int32_t iSize) {
if (iSize <= iLen)
return 0;
pBuf[iLen] = '\0';
WelsStrncpy (pBuf, iSize, WELS_VERSION_STR, iLen); // confirmed_safe_unsafe_usage
WelsStrncpy (pBuf, iSize, WELS_VERSION_STR); // confirmed_safe_unsafe_usage
return iLen;
}
@ -134,8 +131,7 @@ int32_t GetIdentInfo (str_t* pBuf, int32_t iSize) {
if (iSize <= iLen)
return 0;
pBuf[iLen] = '\0';
WelsStrncpy (pBuf, iSize, WELS_IDENT, iLen); // confirmed_safe_unsafe_usage
WelsStrncpy (pBuf, iSize, WELS_IDENT); // confirmed_safe_unsafe_usage
return iLen;
}

View File

@ -123,7 +123,7 @@ void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const str_
const int32_t len = strlen ("[ENCODER]: "); // confirmed_safe_unsafe_usage
WelsStrncpy (pBuf, MAX_LOG_SIZE, "[ENCODER]: ", len); // confirmed_safe_unsafe_usage
WelsStrncpy (pBuf, MAX_LOG_SIZE, "[ENCODER]: "); // confirmed_safe_unsafe_usage
WelsVsnprintf (pBuf + len, MAX_LOG_SIZE - len, Str_Format, vl); // confirmed_safe_unsafe_usage
// g_WelsCodecTrace.TraceString(iLevel, pBuf);

View File

@ -994,7 +994,7 @@ void CWelsH264SVCEncoder::DumpSrcPicture (const uint8_t* pSrc) {
str_t strFileName[256] = {0};
const int32_t iDataLength = m_iMaxPicWidth * m_iMaxPicHeight;
WelsStrncpy (strFileName, 256, "pic_in_", strlen ("pic_in_")); // confirmed_safe_unsafe_usage
WelsStrncpy (strFileName, 256, "pic_in_"); // confirmed_safe_unsafe_usage
if (m_iMaxPicWidth == 640) {
STRCAT (strFileName, 256, "360p."); // confirmed_safe_unsafe_usage