History

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.

Martin Storsjö committed 12 years ago

Commit 082a9861 parent da7d3d94 files · +8 −8Browse files

Showing the changes to codec/decoder/plus/src/welsCodecTrace.cpp (1 of 4 files). Show all

Unified · Split

codec/decoder/plus/src/welsCodecTrace.cpp+2−2
@@ -60,7 +60,7 @@ int32_t CWelsTraceBase::SetTraceLevel (int iLevel) { · 59 unmodified lines
60int32_t CWelsTraceBase::Trace (const int kLevel, const str_t* kpFormat, va_list pVl) {60int32_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;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t