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