Fix handling of snprintf return values and buffer size calculations
Unified · Split
| @@ -90,10 +90,12 @@ CWelsDecoder::CWelsDecoder (void_t) · 89 unmodified lines | |||
| 90 | str_t chFileName[1024] = { 0 }; //for .264 | 90 | str_t chFileName[1024] = { 0 }; //for .264 |
| 91 | int iBufUsed = 0; | 91 | int iBufUsed = 0; |
| 92 | int iBufLeft = 1023; | 92 | int iBufLeft = 1023; |
| 93 | int iCurUsed; | ||
| 93 | 94 | ||
| 94 | str_t chFileNameSize[1024] = { 0 }; //for .len | 95 | str_t chFileNameSize[1024] = { 0 }; //for .len |
| 95 | int iBufUsedSize = 0; | 96 | int iBufUsedSize = 0; |
| 96 | int iBufLeftSize = 1023; | 97 | int iBufLeftSize = 1023; |
| 98 | int iCurUsedSize; | ||
| 97 | #endif//OUTPUT_BIT_STREAM | 99 | #endif//OUTPUT_BIT_STREAM |
| 98 | 100 | ||
| 99 | m_pTrace = CreateWelsTrace (Wels_Trace_Type); | 101 | m_pTrace = CreateWelsTrace (Wels_Trace_Type); |
| @@ -106,30 +108,44 @@ CWelsDecoder::CWelsDecoder (void_t) · 6 unmodified lines | |||
| 106 | 108 | ||
| 107 | WelsGetTimeOfDay (&sCurTime); | 109 | WelsGetTimeOfDay (&sCurTime); |
| 108 | 110 | ||
| 109 | iBufUsed += WelsSnprintf (chFileName, iBufLeft, "bs_0x%p_", (void_t*)this); | 111 | iCurUsed = WelsSnprintf (chFileName, iBufLeft, "bs_0x%p_", (void_t*)this); |
| 110 | iBufUsedSize += WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this); | 112 | iCurUsedSize = WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this); |
| 111 | 113 | ||
| 112 | iBufLeft -= iBufUsed; | 114 | if (iCurUsed > 0) { |
| 113 | if (iBufLeft > iBufUsed) { | 115 | iBufUsed += iCurUsed; |
| 114 | iBufUsed += WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime); | 116 | iBufLeft -= iCurUsed; |
| 115 | iBufLeft -= iBufUsed; | 117 | } |
| 118 | if (iBufLeft > 0) { | ||
| 119 | iCurUsed = WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime); | ||
| 120 | iBufUsed += iCurUsed; | ||
| 121 | iBufLeft -= iCurUsed; | ||
| 116 | } | 122 | } |
| 117 | 123 | ||
| 118 | iBufLeftSize -= iBufUsedSize; | 124 | if (iCurUsedSize > 0) { |
| 119 | if (iBufLeftSize > iBufUsedSize) { | 125 | iBufUsedSize += iCurUsedSize; |
| 120 | iBufUsedSize += WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime); | 126 | iBufLeftSize -= iCurUsedSize; |
| 121 | iBufLeftSize -= iBufUsedSize; | 127 | } |
| 128 | if (iBufLeftSize > 0) { | ||
| 129 | iCurUsedSize = WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime); | ||
| 130 | iBufUsedSize += iCurUsedSize; | ||
| 131 | iBufLeftSize -= iCurUsedSize; | ||
| 122 | } | 132 | } |
| 123 | 133 | ||
| 124 | if (iBufLeft > iBufUsed) { | 134 | if (iBufLeft > 0) { |
| 125 | iBufUsed += WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond (&sCurTime)); | 135 | iCurUsed = WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond (&sCurTime)); |
| 126 | iBufLeft -= iBufUsed; | 136 | if (iCurUsed > 0) { |
| 137 | iBufUsed += iCurUsed; | ||
| 138 | iBufLeft -= iCurUsed; | ||
| 139 | } | ||
| 127 | } | 140 | } |
| 128 | 141 | ||
| 129 | if (iBufLeftSize > iBufUsedSize) { | 142 | if (iBufLeftSize > 0) { |
| 130 | iBufUsedSize += WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len", | 143 | iCurUsedSize = WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len", |
| 131 | WelsGetMillsecond (&sCurTime)); | 144 | WelsGetMillsecond (&sCurTime)); |
| 132 | iBufLeftSize -= iBufUsedSize; | 145 | if (iCurUsedSize > 0) { |
| 146 | iBufUsedSize += iCurUsedSize; | ||
| 147 | iBufLeftSize -= iCurUsedSize; | ||
| 148 | } | ||
| 133 | } | 149 | } |
| 134 | 150 | ||
| 135 | 151 | ||
| @@ -443,7 +443,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 442 unmodified lines | |||
| 443 | while (iIdx < iThreadNum) { | 443 | while (iIdx < iThreadNum) { |
| 444 | #if defined(__GNUC__) && !defined(_WIN32) // for posix threading | 444 | #if defined(__GNUC__) && !defined(_WIN32) // for posix threading |
| 445 | str_t name[SEM_NAME_MAX] = {0}; | 445 | str_t name[SEM_NAME_MAX] = {0}; |
| 446 | int32_t used_len = 0; | ||
| 447 | WELS_THREAD_ERROR_CODE err = 0; | 446 | WELS_THREAD_ERROR_CODE err = 0; |
| 448 | #endif//__GNUC__ | 447 | #endif//__GNUC__ |
| 449 | pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) (*ppCtx); | 448 | pSmt->pThreadPEncCtx[iIdx].pWelsPEncCtx = (void*) (*ppCtx); |
| @@ -462,8 +461,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 12 unmodified lines | |||
| 462 | #if defined(ENABLE_TRACE_MT) | 461 | #if defined(ENABLE_TRACE_MT) |
| 463 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); | 462 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); |
| 464 | #endif | 463 | #endif |
| 465 | used_len = SNPRINTF (name, SEM_NAME_MAX, "fu%d%p", iIdx, (void*) (*ppCtx)); | 464 | SNPRINTF (name, SEM_NAME_MAX, "fu%d%p", iIdx, (void*) (*ppCtx)); |
| 466 | name[used_len] = '\0'; | ||
| 467 | err = WelsEventOpen (&pSmt->pFinUpdateMbListEvent[iIdx], name); | 465 | err = WelsEventOpen (&pSmt->pFinUpdateMbListEvent[iIdx], name); |
| 468 | #if defined(ENABLE_TRACE_MT) | 466 | #if defined(ENABLE_TRACE_MT) |
| 469 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); | 467 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pFinUpdateMbListEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); |
| @@ -477,14 +475,12 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 7 unmodified lines | |||
| 477 | WelsEventInit (&pSmt->pFinSliceCodingEvent[iIdx]); | 475 | WelsEventInit (&pSmt->pFinSliceCodingEvent[iIdx]); |
| 478 | WelsEventInit (&pSmt->pExitEncodeEvent[iIdx]); | 476 | WelsEventInit (&pSmt->pExitEncodeEvent[iIdx]); |
| 479 | #else | 477 | #else |
| 480 | used_len = SNPRINTF (name, SEM_NAME_MAX, "sc%d%p", iIdx, (void*) (*ppCtx)); | 478 | SNPRINTF (name, SEM_NAME_MAX, "sc%d%p", iIdx, (void*) (*ppCtx)); |
| 481 | name[used_len] = '\0'; | ||
| 482 | err = WelsEventOpen (&pSmt->pSliceCodedEvent[iIdx], name); | 479 | err = WelsEventOpen (&pSmt->pSliceCodedEvent[iIdx], name); |
| 483 | #if defined(ENABLE_TRACE_MT) | 480 | #if defined(ENABLE_TRACE_MT) |
| 484 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pSliceCodedEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); | 481 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pSliceCodedEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); |
| 485 | #endif | 482 | #endif |
| 486 | used_len = SNPRINTF (name, SEM_NAME_MAX, "rc%d%p", iIdx, (void*) (*ppCtx)); | 483 | SNPRINTF (name, SEM_NAME_MAX, "rc%d%p", iIdx, (void*) (*ppCtx)); |
| 487 | name[used_len] = '\0'; | ||
| 488 | err = WelsEventOpen (&pSmt->pReadySliceCodingEvent[iIdx], name); | 484 | err = WelsEventOpen (&pSmt->pReadySliceCodingEvent[iIdx], name); |
| 489 | #if defined(ENABLE_TRACE_MT) | 485 | #if defined(ENABLE_TRACE_MT) |
| 490 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pReadySliceCodingEvent%d = 0x%p named(%s) ret%d err%d\n", iIdx, | 486 | WelsLog ((*ppCtx), WELS_LOG_INFO, "[MT] Open pReadySliceCodingEvent%d = 0x%p named(%s) ret%d err%d\n", iIdx, |
| @@ -577,19 +573,15 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 86 unmodified lines | |||
| 577 | #endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE | 573 | #endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE |
| 578 | #else | 574 | #else |
| 579 | str_t ename[SEM_NAME_MAX] = {0}; | 575 | str_t ename[SEM_NAME_MAX] = {0}; |
| 580 | int32_t used_len = 0; | ||
| 581 | // length of semaphore name should be system constrained at least on mac 10.7 | 576 | // length of semaphore name should be system constrained at least on mac 10.7 |
| 582 | SNPRINTF (ename, SEM_NAME_MAX, "sc%d%p", iIdx, (void*) (*ppCtx)); | 577 | SNPRINTF (ename, SEM_NAME_MAX, "sc%d%p", iIdx, (void*) (*ppCtx)); |
| 583 | WelsEventClose (pSmt->pSliceCodedEvent[iIdx], ename); | 578 | WelsEventClose (pSmt->pSliceCodedEvent[iIdx], ename); |
| 584 | used_len = SNPRINTF (ename, SEM_NAME_MAX, "rc%d%p", iIdx, (void*) (*ppCtx)); | 579 | SNPRINTF (ename, SEM_NAME_MAX, "rc%d%p", iIdx, (void*) (*ppCtx)); |
| 585 | ename[used_len] = '\0'; | ||
| 586 | WelsEventClose (pSmt->pReadySliceCodingEvent[iIdx], ename); | 580 | WelsEventClose (pSmt->pReadySliceCodingEvent[iIdx], ename); |
| 587 | #if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) | 581 | #if defined(DYNAMIC_SLICE_ASSIGN) && defined(TRY_SLICING_BALANCE) |
| 588 | used_len = SNPRINTF (ename, SEM_NAME_MAX, "ud%d%p", iIdx, (void*) (*ppCtx)); | 582 | SNPRINTF (ename, SEM_NAME_MAX, "ud%d%p", iIdx, (void*) (*ppCtx)); |
| 589 | ename[used_len] = '\0'; | ||
| 590 | WelsEventClose (pSmt->pUpdateMbListEvent[iIdx], ename); | 583 | WelsEventClose (pSmt->pUpdateMbListEvent[iIdx], ename); |
| 591 | used_len = SNPRINTF (ename, SEM_NAME_MAX, "fu%d%p", iIdx, (void*) (*ppCtx)); | 584 | SNPRINTF (ename, SEM_NAME_MAX, "fu%d%p", iIdx, (void*) (*ppCtx)); |
| 592 | ename[used_len] = '\0'; | ||
| 593 | WelsEventClose (pSmt->pFinUpdateMbListEvent[iIdx], ename); | 585 | WelsEventClose (pSmt->pFinUpdateMbListEvent[iIdx], ename); |
| 594 | #endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE | 586 | #endif//DYNAMIC_SLICE_ASSIGN && TRY_SLICING_BALANCE |
| 595 | #endif//_WIN32 | 587 | #endif//_WIN32 |
| @@ -77,10 +77,12 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 76 unmodified lines | |||
| 77 | str_t strStreamFileName[1024] = { 0 }; //for .264 | 77 | str_t strStreamFileName[1024] = { 0 }; //for .264 |
| 78 | int32_t iBufferUsed = 0; | 78 | int32_t iBufferUsed = 0; |
| 79 | int32_t iBufferLeft = 1023; | 79 | int32_t iBufferLeft = 1023; |
| 80 | int32_t iCurUsed; | ||
| 80 | 81 | ||
| 81 | str_t strLenFileName[1024] = { 0 }; //for .len | 82 | str_t strLenFileName[1024] = { 0 }; //for .len |
| 82 | int32_t iBufferUsedSize = 0; | 83 | int32_t iBufferUsedSize = 0; |
| 83 | int32_t iBufferLeftSize = 1023; | 84 | int32_t iBufferLeftSize = 1023; |
| 85 | int32_t iCurUsedSize; | ||
| 84 | #endif//OUTPUT_BIT_STREAM | 86 | #endif//OUTPUT_BIT_STREAM |
| 85 | 87 | ||
| 86 | #ifdef OUTPUT_BIT_STREAM | 88 | #ifdef OUTPUT_BIT_STREAM |
| @@ -118,26 +120,29 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 31 unmodified lines | |||
| 118 | #ifdef _WIN32 | 120 | #ifdef _WIN32 |
| 119 | #if defined(_MSC_VER) | 121 | #if defined(_MSC_VER) |
| 120 | #if _MSC_VER>=1500 | 122 | #if _MSC_VER>=1500 |
| 121 | iBufferUsed += SNPRINTF (strStreamFileName, iBufferLeft, iBufferLeft, "enc_bs_0x%p_", (void*)this); | 123 | iCurUsed = SNPRINTF (strStreamFileName, iBufferLeft, iBufferLeft, "enc_bs_0x%p_", (void*)this); |
| 122 | iBufferUsedSize += SNPRINTF (strLenFileName, iBufferLeftSize, iBufferLeftSize, "enc_size_0x%p_", (void*)this); | 124 | iCurUsedSize = SNPRINTF (strLenFileName, iBufferLeftSize, iBufferLeftSize, "enc_size_0x%p_", (void*)this); |
| 123 | #else | 125 | #else |
| 124 | iBufferUsed += SNPRINTF (strStreamFileName, iBufferLeft, "enc_bs_0x%p_", (void*)this); | 126 | iCurUsed = SNPRINTF (strStreamFileName, iBufferLeft, "enc_bs_0x%p_", (void*)this); |
| 125 | iBufferUsedSize += SNPRINTF (strLenFileName, iBufferLeftSize, "enc_size_0x%p_", (void*)this); | 127 | iCurUsedSize = SNPRINTF (strLenFileName, iBufferLeftSize, "enc_size_0x%p_", (void*)this); |
| 126 | #endif//_MSC_VER>=1500 | 128 | #endif//_MSC_VER>=1500 |
| 127 | #endif//_MSC_VER | 129 | #endif//_MSC_VER |
| 128 | #else | 130 | #else |
| 129 | iBufferUsed += SNPRINTF (strStreamFileName, iBufferLeft, "/tmp/enc_bs_0x%p_", (void*)this); | 131 | iCurUsed = SNPRINTF (strStreamFileName, iBufferLeft, "/tmp/enc_bs_0x%p_", (void*)this); |
| 130 | iBufferUsedSize += SNPRINTF (strLenFileName, iBufferLeftSize, "/tmp/enc_size_0x%p", (void*)this); | 132 | iCurUsedSize = SNPRINTF (strLenFileName, iBufferLeftSize, "/tmp/enc_size_0x%p", (void*)this); |
| 131 | #endif//WIN32 | 133 | #endif//WIN32 |
| 132 | 134 | ||
| 133 | 135 | ||
| 134 | iBufferLeft -= iBufferUsed; | 136 | if (iCurUsed > 0) { |
| 135 | if (iBufferLeft > iBufferUsed) { | 137 | iBufferUsed += iCurUsed; |
| 138 | iBufferLeft -= iCurUsed; | ||
| 139 | } | ||
| 140 | if (iBufferLeft > 0) { | ||
| 136 | #if defined(_GNUC__) | 141 | #if defined(_GNUC__) |
| 137 | iBufferUsed += strftime (&strStreamFileName[iBufferUsed], iBufferLeft, "%y%m%d%H%M%S", tTimeNow); | 142 | iCurUsed = strftime (&strStreamFileName[iBufferUsed], iBufferLeft, "%y%m%d%H%M%S", tTimeNow); |
| 138 | #else | 143 | #else |
| 139 | #if defined(_MSC_VER) | 144 | #if defined(_MSC_VER) |
| 140 | iBufferUsed += strftime (&strStreamFileName[iBufferUsed], iBufferLeft, "%y%m%d%H%M%S", | 145 | iCurUsed = strftime (&strStreamFileName[iBufferUsed], iBufferLeft, "%y%m%d%H%M%S", |
| 141 | #if _MSC_VER>=1500 | 146 | #if _MSC_VER>=1500 |
| 142 | & tTimeNow | 147 | & tTimeNow |
| 143 | #else | 148 | #else |
| @@ -146,16 +151,20 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 2 unmodified lines | |||
| 146 | ); | 151 | ); |
| 147 | #endif//_MSC_VER | 152 | #endif//_MSC_VER |
| 148 | #endif//__GNUC__ | 153 | #endif//__GNUC__ |
| 149 | iBufferLeft -= iBufferUsed; | 154 | iBufferUsed += iCurUsed; |
| 155 | iBufferLeft -= iCurUsed; | ||
| 150 | } | 156 | } |
| 151 | 157 | ||
| 152 | iBufferLeftSize -= iBufferUsedSize; | 158 | if (iCurUsedSize > 0) { |
| 153 | if (iBufferLeftSize > iBufferUsedSize) { | 159 | iBufferUsedSize += iCurUsedSize; |
| 160 | iBufferLeftSize -= iCurUsedSize; | ||
| 161 | } | ||
| 162 | if (iBufferLeftSize > 0) { | ||
| 154 | #if defined(_GNUC__) | 163 | #if defined(_GNUC__) |
| 155 | iBufferUsedSize += strftime (&strLenFileName[iBufferUsedSize], iBufferLeftSize, "%y%m%d%H%M%S", tTimeNow); | 164 | iCurUsedSize = strftime (&strLenFileName[iBufferUsedSize], iBufferLeftSize, "%y%m%d%H%M%S", tTimeNow); |
| 156 | #else | 165 | #else |
| 157 | #if defined(_MSC_VER) | 166 | #if defined(_MSC_VER) |
| 158 | iBufferUsedSize += strftime (&strLenFileName[iBufferUsedSize], iBufferLeftSize, "%y%m%d%H%M%S", | 167 | iCurUsedSize = strftime (&strLenFileName[iBufferUsedSize], iBufferLeftSize, "%y%m%d%H%M%S", |
| 159 | #if _MSC_VER>=1500 | 168 | #if _MSC_VER>=1500 |
| 160 | & tTimeNow | 169 | & tTimeNow |
| 161 | #else | 170 | #else |
| @@ -164,38 +173,45 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 2 unmodified lines | |||
| 164 | ); | 173 | ); |
| 165 | #endif//_MSC_VER | 174 | #endif//_MSC_VER |
| 166 | #endif//__GNUC__ | 175 | #endif//__GNUC__ |
| 167 | iBufferLeftSize -= iBufferUsedSize; | 176 | iBufferUsedSize += iCurUsedSize; |
| 177 | iBufferLeftSize -= iCurUsedSize; | ||
| 168 | } | 178 | } |
| 169 | 179 | ||
| 170 | if (iBufferLeft > iBufferUsed) { | 180 | if (iBufferLeft > 0) { |
| 171 | #ifdef _WIN32 | 181 | #ifdef _WIN32 |
| 172 | #if defined(_MSC_VER) | 182 | #if defined(_MSC_VER) |
| 173 | #if _MSC_VER>=1500 | 183 | #if _MSC_VER>=1500 |
| 174 | iBufferUsed += SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, iBufferLeft, ".%03.3u.264", tTimeb.millitm); | 184 | iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, iBufferLeft, ".%03.3u.264", tTimeb.millitm); |
| 175 | #else | 185 | #else |
| 176 | iBufferUsed += SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimeb.millitm); | 186 | iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimeb.millitm); |
| 177 | #endif//_MSC_VER>=1500 | 187 | #endif//_MSC_VER>=1500 |
| 178 | #endif//_MSC_VER | 188 | #endif//_MSC_VER |
| 179 | #else | 189 | #else |
| 180 | iBufferUsed += SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimev.tv_usec / 1000); | 190 | iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimev.tv_usec / 1000); |
| 181 | #endif//WIN32 | 191 | #endif//WIN32 |
| 182 | iBufferLeft -= iBufferUsed; | 192 | if (iCurUsed > 0) { |
| 193 | iBufferUsed += iCurUsed; | ||
| 194 | iBufferLeft -= iCurUsed; | ||
| 195 | } | ||
| 183 | } | 196 | } |
| 184 | 197 | ||
| 185 | if (iBufferLeftSize > iBufferUsedSize) { | 198 | if (iBufferLeftSize > 0) { |
| 186 | #ifdef _WIN32 | 199 | #ifdef _WIN32 |
| 187 | #if defined(_MSC_VER) | 200 | #if defined(_MSC_VER) |
| 188 | #if _MSC_VER>=1500 | 201 | #if _MSC_VER>=1500 |
| 189 | iBufferUsedSize += SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, iBufferLeftSize, ".%03.3u.len", | 202 | iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, iBufferLeftSize, ".%03.3u.len", |
| 190 | tTimeb.millitm); | 203 | tTimeb.millitm); |
| 191 | #else | 204 | #else |
| 192 | iBufferUsedSize += SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimeb.millitm); | 205 | iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimeb.millitm); |
| 193 | #endif//_MSC_VER>=1500 | 206 | #endif//_MSC_VER>=1500 |
| 194 | #endif//_MSC_VER | 207 | #endif//_MSC_VER |
| 195 | #else | 208 | #else |
| 196 | iBufferUsedSize += SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimev.tv_usec / 1000); | 209 | iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimev.tv_usec / 1000); |
| 197 | #endif//WIN32 | 210 | #endif//WIN32 |
| 198 | iBufferLeftSize -= iBufferUsedSize; | 211 | if (iCurUsedSize > 0) { |
| 212 | iBufferUsedSize += iCurUsedSize; | ||
| 213 | iBufferLeftSize -= iCurUsedSize; | ||
| 214 | } | ||
| 199 | } | 215 | } |
| 200 | 216 | ||
| 201 | #if defined(__GNUC__) | 217 | #if defined(__GNUC__) |