Also similarly simplify the use of the return value from WelsStrftime and GetCodeName/GetLibName/GetVerNum.
Unified · Split
| @@ -110,20 +110,16 @@ CWelsDecoder::CWelsDecoder (void) · 109 unmodified lines | ||
| 110 | 110 | iCurUsed = WelsSnprintf (chFileName, iBufLeft, "bs_0x%p_", (void*)this); |
| 111 | 111 | iCurUsedSize = WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void*)this); |
| 112 | 112 | |
| 113 | − if (iCurUsed > 0) { | |
| 114 | − iBufUsed += iCurUsed; | |
| 115 | − iBufLeft -= iCurUsed; | |
| 116 | − } | |
| 113 | + iBufUsed += iCurUsed; | |
| 114 | + iBufLeft -= iCurUsed; | |
| 117 | 115 | if (iBufLeft > 0) { |
| 118 | 116 | iCurUsed = WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime); |
| 119 | 117 | iBufUsed += iCurUsed; |
| 120 | 118 | iBufLeft -= iCurUsed; |
| 121 | 119 | } |
| 122 | 120 | |
| 123 | − if (iCurUsedSize > 0) { | |
| 124 | − iBufUsedSize += iCurUsedSize; | |
| 125 | − iBufLeftSize -= iCurUsedSize; | |
| 126 | − } | |
| 121 | + iBufUsedSize += iCurUsedSize; | |
| 122 | + iBufLeftSize -= iCurUsedSize; | |
| 127 | 123 | if (iBufLeftSize > 0) { |
| 128 | 124 | iCurUsedSize = WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime); |
| 129 | 125 | iBufUsedSize += iCurUsedSize; |
| @@ -132,19 +128,15 @@ CWelsDecoder::CWelsDecoder (void) · 2 unmodified lines | ||
| 132 | 128 | |
| 133 | 129 | if (iBufLeft > 0) { |
| 134 | 130 | iCurUsed = WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillisecond (&sCurTime)); |
| 135 | − if (iCurUsed > 0) { | |
| 136 | − iBufUsed += iCurUsed; | |
| 137 | − iBufLeft -= iCurUsed; | |
| 138 | − } | |
| 131 | + iBufUsed += iCurUsed; | |
| 132 | + iBufLeft -= iCurUsed; | |
| 139 | 133 | } |
| 140 | 134 | |
| 141 | 135 | if (iBufLeftSize > 0) { |
| 142 | 136 | iCurUsedSize = WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len", |
| 143 | 137 | WelsGetMillisecond (&sCurTime)); |
| 144 | − if (iCurUsedSize > 0) { | |
| 145 | − iBufUsedSize += iCurUsedSize; | |
| 146 | − iBufLeftSize -= iCurUsedSize; | |
| 147 | − } | |
| 138 | + iBufUsedSize += iCurUsedSize; | |
| 139 | + iBufLeftSize -= iCurUsedSize; | |
| 148 | 140 | } |
| 149 | 141 | |
| 150 | 142 | |
| @@ -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) { |
| @@ -90,20 +90,16 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 89 unmodified lines | ||
| 90 | 90 | iCurUsedSize = WelsSnprintf (strLenFileName, iBufferLeftSize, "enc_size_0x%p_", (void*)this); |
| 91 | 91 | |
| 92 | 92 | |
| 93 | − if (iCurUsed > 0) { | |
| 94 | − iBufferUsed += iCurUsed; | |
| 95 | − iBufferLeft -= iCurUsed; | |
| 96 | − } | |
| 93 | + iBufferUsed += iCurUsed; | |
| 94 | + iBufferLeft -= iCurUsed; | |
| 97 | 95 | if (iBufferLeft > 0) { |
| 98 | 96 | iCurUsed = WelsStrftime (&strStreamFileName[iBufferUsed], iBufferLeft, "%y%m%d%H%M%S", &tTime); |
| 99 | 97 | iBufferUsed += iCurUsed; |
| 100 | 98 | iBufferLeft -= iCurUsed; |
| 101 | 99 | } |
| 102 | 100 | |
| 103 | − if (iCurUsedSize > 0) { | |
| 104 | − iBufferUsedSize += iCurUsedSize; | |
| 105 | − iBufferLeftSize -= iCurUsedSize; | |
| 106 | − } | |
| 101 | + iBufferUsedSize += iCurUsedSize; | |
| 102 | + iBufferLeftSize -= iCurUsedSize; | |
| 107 | 103 | if (iBufferLeftSize > 0) { |
| 108 | 104 | iCurUsedSize = WelsStrftime (&strLenFileName[iBufferUsedSize], iBufferLeftSize, "%y%m%d%H%M%S", &tTime); |
| 109 | 105 | iBufferUsedSize += iCurUsedSize; |
| @@ -113,19 +109,15 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 3 unmodified lines | ||
| 113 | 109 | if (iBufferLeft > 0) { |
| 114 | 110 | iCurUsed = WelsSnprintf (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", |
| 115 | 111 | WelsGetMillisecond(&tTime)); |
| 116 | − if (iCurUsed > 0) { | |
| 117 | − iBufferUsed += iCurUsed; | |
| 118 | − iBufferLeft -= iCurUsed; | |
| 119 | − } | |
| 112 | + iBufferUsed += iCurUsed; | |
| 113 | + iBufferLeft -= iCurUsed; | |
| 120 | 114 | } |
| 121 | 115 | |
| 122 | 116 | if (iBufferLeftSize > 0) { |
| 123 | 117 | iCurUsedSize = WelsSnprintf (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", |
| 124 | 118 | WelsGetMillisecond(&tTime)); |
| 125 | − if (iCurUsedSize > 0) { | |
| 126 | − iBufferUsedSize += iCurUsedSize; | |
| 127 | − iBufferLeftSize -= iCurUsedSize; | |
| 128 | − } | |
| 119 | + iBufferUsedSize += iCurUsedSize; | |
| 120 | + iBufferLeftSize -= iCurUsedSize; | |
| 129 | 121 | } |
| 130 | 122 | |
| 131 | 123 | m_pFileBs = WelsFopen (strStreamFileName, "wb"); |