Also similarly simplify the use of the return value from WelsStrftime and GetCodeName/GetLibName/GetVerNum.
Showing the changes to codec/encoder/core/src/utils.cpp (1 of 3 files). Show all
Unified · Split
| @@ -144,26 +144,20 @@ void WelsLogDefault (void* pCtx, const int32_t kiLevel, const char* kpFmtStr, va · 143 unmodified lines | |||
| 144 | 144 | ||
| 145 | WelsGetTimeOfDay(&tTime); | 145 | WelsGetTimeOfDay(&tTime); |
| 146 | iCurUsed = WelsSnprintf (&pBuf[iBufUsed], iBufLeft, "[0x%p @ ", pEncCtx); // confirmed_safe_unsafe_usage | 146 | iCurUsed = WelsSnprintf (&pBuf[iBufUsed], iBufLeft, "[0x%p @ ", pEncCtx); // confirmed_safe_unsafe_usage |
| 147 | if (iCurUsed >= 0) { | 147 | iBufUsed += iCurUsed; |
| 148 | iBufUsed += iCurUsed; | 148 | iBufLeft -= iCurUsed; |
| 149 | iBufLeft -= iCurUsed; | ||
| 150 | } | ||
| 151 | 149 | ||
| 152 | if (iBufLeft > 0) { | 150 | if (iBufLeft > 0) { |
| 153 | iCurUsed = GetCodeName (&pBuf[iBufUsed], iBufLeft); | 151 | iCurUsed = GetCodeName (&pBuf[iBufUsed], iBufLeft); |
| 154 | if (iCurUsed > 0) { | 152 | iBufUsed += iCurUsed; |
| 155 | iBufUsed += iCurUsed; | 153 | iBufLeft -= iCurUsed; |
| 156 | iBufLeft -= iCurUsed; | ||
| 157 | } | ||
| 158 | pBuf[iBufUsed] = ' '; | 154 | pBuf[iBufUsed] = ' '; |
| 159 | ++ iBufUsed; | 155 | ++ iBufUsed; |
| 160 | -- iBufLeft; | 156 | -- iBufLeft; |
| 161 | 157 | ||
| 162 | iCurUsed = GetLibName (&pBuf[iBufUsed], iBufLeft); | 158 | iCurUsed = GetLibName (&pBuf[iBufUsed], iBufLeft); |
| 163 | if (iCurUsed > 0) { | 159 | iBufUsed += iCurUsed; |
| 164 | iBufUsed += iCurUsed; | 160 | iBufLeft -= iCurUsed; |
| 165 | iBufLeft -= iCurUsed; | ||
| 166 | } | ||
| 167 | pBuf[iBufUsed] = ' '; | 161 | pBuf[iBufUsed] = ' '; |
| 168 | ++ iBufUsed; | 162 | ++ iBufUsed; |
| 169 | -- iBufLeft; | 163 | -- iBufLeft; |
| @@ -172,10 +166,8 @@ void WelsLogDefault (void* pCtx, const int32_t kiLevel, const char* kpFmtStr, va · 2 unmodified lines | |||
| 172 | ++ iBufUsed; | 166 | ++ iBufUsed; |
| 173 | -- iBufLeft; | 167 | -- iBufLeft; |
| 174 | iCurUsed = GetVerNum (&pBuf[iBufUsed], iBufLeft); | 168 | iCurUsed = GetVerNum (&pBuf[iBufUsed], iBufLeft); |
| 175 | if (iCurUsed > 0) { | 169 | iBufUsed += iCurUsed; |
| 176 | iBufUsed += iCurUsed; | 170 | iBufLeft -= iCurUsed; |
| 177 | iBufLeft -= iCurUsed; | ||
| 178 | } | ||
| 179 | pBuf[iBufUsed] = ' '; | 171 | pBuf[iBufUsed] = ' '; |
| 180 | ++ iBufUsed; | 172 | ++ iBufUsed; |
| 181 | -- iBufLeft; | 173 | -- iBufLeft; |
| @@ -183,20 +175,16 @@ void WelsLogDefault (void* pCtx, const int32_t kiLevel, const char* kpFmtStr, va · 1 unmodified line | |||
| 183 | 175 | ||
| 184 | if (iBufLeft > 0) { | 176 | if (iBufLeft > 0) { |
| 185 | iCurUsed = WelsStrftime (&pBuf[iBufUsed], iBufLeft, "%y-%m-%d %H:%M:%S", &tTime); | 177 | iCurUsed = WelsStrftime (&pBuf[iBufUsed], iBufLeft, "%y-%m-%d %H:%M:%S", &tTime); |
| 186 | if (iCurUsed > 0) { | 178 | iBufUsed += iCurUsed; |
| 187 | iBufUsed += iCurUsed; | 179 | iBufLeft -= iCurUsed; |
| 188 | iBufLeft -= iCurUsed; | ||
| 189 | } | ||
| 190 | } else { | 180 | } else { |
| 191 | return; | 181 | return; |
| 192 | } | 182 | } |
| 193 | 183 | ||
| 194 | if (iBufLeft > 0) { | 184 | if (iBufLeft > 0) { |
| 195 | iCurUsed = WelsSnprintf (&pBuf[iBufUsed], iBufLeft, ".%3.3u]: ", tTime.millitm); // confirmed_safe_unsafe_usage | 185 | iCurUsed = WelsSnprintf (&pBuf[iBufUsed], iBufLeft, ".%3.3u]: ", tTime.millitm); // confirmed_safe_unsafe_usage |
| 196 | if (iCurUsed >= 0) { | 186 | iBufUsed += iCurUsed; |
| 197 | iBufUsed += iCurUsed; | 187 | iBufLeft -= iCurUsed; |
| 198 | iBufLeft -= iCurUsed; | ||
| 199 | } | ||
| 200 | } else { | 188 | } else { |
| 201 | return; | 189 | return; |
| 202 | } | 190 | } |
| @@ -209,18 +197,14 @@ void WelsLogDefault (void* pCtx, const int32_t kiLevel, const char* kpFmtStr, va · 6 unmodified lines | |||
| 209 | pStr = GetLogTag (kiLevel, &i_shift); | 197 | pStr = GetLogTag (kiLevel, &i_shift); |
| 210 | if (NULL != pStr) { | 198 | if (NULL != pStr) { |
| 211 | iCurUsed = WelsSnprintf (&pBuf[iBufUsed], iBufLeft, "%s ", pStr); | 199 | iCurUsed = WelsSnprintf (&pBuf[iBufUsed], iBufLeft, "%s ", pStr); |
| 212 | if (iCurUsed >= 0) { | 200 | iBufUsed += iCurUsed; |
| 213 | iBufUsed += iCurUsed; | 201 | iBufLeft -= iCurUsed; |
| 214 | iBufLeft -= iCurUsed; | ||
| 215 | } | ||
| 216 | } | 202 | } |
| 217 | } | 203 | } |
| 218 | if (iBufLeft > 0) { | 204 | if (iBufLeft > 0) { |
| 219 | iCurUsed = WelsVsnprintf (&pBuf[iBufUsed], iBufLeft, kpFmtStr, argv); // confirmed_safe_unsafe_usage | 205 | iCurUsed = WelsVsnprintf (&pBuf[iBufUsed], iBufLeft, kpFmtStr, argv); // confirmed_safe_unsafe_usage |
| 220 | if (iCurUsed > 0) { | 206 | iBufUsed += iCurUsed; |
| 221 | iBufUsed += iCurUsed; | 207 | iBufLeft -= iCurUsed; |
| 222 | iBufLeft -= iCurUsed; | ||
| 223 | } | ||
| 224 | } | 208 | } |
| 225 | #ifdef ENABLE_TRACE_FILE | 209 | #ifdef ENABLE_TRACE_FILE |
| 226 | if (NULL != pEncCtx && NULL != pEncCtx->pFileLog) { | 210 | if (NULL != pEncCtx && NULL != pEncCtx->pFileLog) { |