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.
Showing the changes to codec/decoder/plus/src/welsCodecTrace.cpp (1 of 4 files). Show all
Unified · Split
| @@ -60,7 +60,7 @@ int32_t CWelsTraceBase::SetTraceLevel (int iLevel) { · 59 unmodified lines | |||
| 60 | int32_t CWelsTraceBase::Trace (const int kLevel, const str_t* kpFormat, va_list pVl) { | 60 | int32_t CWelsTraceBase::Trace (const int kLevel, const str_t* kpFormat, va_list pVl) { |
| 61 | if (kLevel & m_iLevel) { | 61 | if (kLevel & m_iLevel) { |
| 62 | str_t chBuf[MAX_LOG_SIZE] = {0}; | 62 | str_t chBuf[MAX_LOG_SIZE] = {0}; |
| 63 | const int32_t kLen = WelsStrnlen ((const str_t*)"[DECODER]: ", MAX_LOG_SIZE); | 63 | const int32_t kLen = strlen ("[DECODER]: "); |
| 64 | 64 | ||
| 65 | WelsStrncpy (chBuf, MAX_LOG_SIZE, (const str_t*)"[DECODER]: ", kLen); | 65 | WelsStrncpy (chBuf, MAX_LOG_SIZE, (const str_t*)"[DECODER]: ", kLen); |
| 66 | 66 | ||
| @@ -88,7 +88,7 @@ int32_t CWelsTraceFile::WriteString (int32_t iLevel, const str_t* pStr) { · 21 unmodified lines | |||
| 88 | const static str_t chEnter[16] = "\n"; | 88 | const static str_t chEnter[16] = "\n"; |
| 89 | if (m_pTraceFile) { | 89 | if (m_pTraceFile) { |
| 90 | iRC += WelsFwrite (pStr, 1, WelsStrnlen (pStr, MAX_LOG_SIZE), m_pTraceFile); | 90 | iRC += WelsFwrite (pStr, 1, WelsStrnlen (pStr, MAX_LOG_SIZE), m_pTraceFile); |
| 91 | iRC += WelsFwrite (chEnter, 1, WelsStrnlen (chEnter, 16), m_pTraceFile); | 91 | iRC += WelsFwrite (chEnter, 1, strlen (chEnter), m_pTraceFile); |
| 92 | WelsFflush (m_pTraceFile); | 92 | WelsFflush (m_pTraceFile); |
| 93 | } | 93 | } |
| 94 | return iRC; | 94 | return iRC; |