shithub: openh264

Download patch

ref: 082a986990bbb529eb5cea2e1576332ac00d9b56
parent: da7d3d9bad342dfa8c561b38ea9581e835b8d2f1
author: Martin Storsjö <martin@martin.st>
date: Tue Jan 28 06:11:05 EST 2014

Use strlen() instead of WelsStrnlen/STRNLEN for string constants

A string constant is guaranteed to be null terminated, and thus
doesn't need to use a version of strlen with a fixed buffer size
limit.

--- a/codec/decoder/plus/src/welsCodecTrace.cpp
+++ b/codec/decoder/plus/src/welsCodecTrace.cpp
@@ -60,7 +60,7 @@
 int32_t  CWelsTraceBase::Trace (const int kLevel, const str_t* kpFormat, va_list pVl) {
   if (kLevel & m_iLevel) {
     str_t chBuf[MAX_LOG_SIZE] = {0};
-    const int32_t kLen	= WelsStrnlen ((const str_t*)"[DECODER]: ", MAX_LOG_SIZE);
+    const int32_t kLen	= strlen ("[DECODER]: ");
 
     WelsStrncpy (chBuf, MAX_LOG_SIZE, (const str_t*)"[DECODER]: ", kLen);
 
@@ -88,7 +88,7 @@
   const static str_t chEnter[16] = "\n";
   if (m_pTraceFile) {
     iRC += WelsFwrite (pStr, 1, WelsStrnlen (pStr, MAX_LOG_SIZE), m_pTraceFile);
-    iRC += WelsFwrite (chEnter, 1, WelsStrnlen (chEnter,  16), m_pTraceFile);
+    iRC += WelsFwrite (chEnter, 1, strlen (chEnter), m_pTraceFile);
     WelsFflush (m_pTraceFile);
   }
   return iRC;
--- a/codec/encoder/core/src/property.cpp
+++ b/codec/encoder/core/src/property.cpp
@@ -64,7 +64,7 @@
   if (NULL == pBuf)
     return 0;
 
-  iLen = STRNLEN (WELS_CODE_NAME, 4);	// confirmed_safe_unsafe_usage
+  iLen = strlen (WELS_CODE_NAME);	// confirmed_safe_unsafe_usage
   if (iSize <= iLen)
     return 0;
 
@@ -86,7 +86,7 @@
   if (NULL == pBuf)
     return 0;
 
-  iLen	= STRNLEN (WELS_LIB_NAME, 7);	// confirmed_safe_unsafe_usage
+  iLen	= strlen (WELS_LIB_NAME);	// confirmed_safe_unsafe_usage
   if (iSize <= iLen)
     return 0;
 
@@ -108,7 +108,7 @@
   if (NULL == pBuf)
     return 0;
 
-  iLen	= STRNLEN (WELS_VERSION_STR, 5);	// confirmed_safe_unsafe_usage
+  iLen	= strlen (WELS_VERSION_STR);	// confirmed_safe_unsafe_usage
   if (iSize <= iLen)
     return 0;
 
@@ -130,7 +130,7 @@
   if (NULL == pBuf)
     return 0;
 
-  iLen	= STRNLEN (WELS_IDENT, 30);	// confirmed_safe_unsafe_usage
+  iLen	= strlen (WELS_IDENT);	// confirmed_safe_unsafe_usage
   if (iSize <= iLen)
     return 0;
 
--- a/codec/encoder/plus/src/welsCodecTrace.cpp
+++ b/codec/encoder/plus/src/welsCodecTrace.cpp
@@ -120,7 +120,7 @@
   }
 
   str_t pBuf[MAX_LOG_SIZE] = {0};
-  const int32_t len	= STRNLEN ("[ENCODER]: ", MAX_LOG_SIZE);	// confirmed_safe_unsafe_usage
+  const int32_t len	= strlen ("[ENCODER]: ");	// confirmed_safe_unsafe_usage
 
 
   STRNCPY (pBuf, MAX_LOG_SIZE, "[ENCODER]: ", len);	// confirmed_safe_unsafe_usage
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -994,7 +994,7 @@
   str_t strFileName[256] = {0};
   const int32_t iDataLength = m_iMaxPicWidth * m_iMaxPicHeight;
 
-  STRNCPY (strFileName, 256, "pic_in_", STRNLEN ("pic_in_", 255));	// confirmed_safe_unsafe_usage
+  STRNCPY (strFileName, 256, "pic_in_", strlen ("pic_in_"));	// confirmed_safe_unsafe_usage
 
   if (m_iMaxPicWidth == 640) {
     STRCAT (strFileName, 256, "360p.");	// confirmed_safe_unsafe_usage