VirtualBox

Ignore:
Timestamp:
May 12, 2017 6:21:24 PM (8 years ago)
Author:
vboxsync
Message:

iprt: RTUINT256U & RTUINT512U formatter fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/strformatnum.cpp

    r66882 r66884  
    161161    fFlags &= ~RTSTR_F_BIT_MASK;
    162162
    163     char szTmp[64+32];
    164     size_t cchFirst  = RTStrFormatNumber(szTmp, pu128->s.Hi, 16, 0, 0, fFlags | RTSTR_F_64BIT);
    165     size_t cchSecond = RTStrFormatNumber(&szTmp[cchFirst], pu128->s.Lo, 16, 8, 0,
    166                                          (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL);
    167     int rc = RTStrCopy(pszBuf, cbBuf, szTmp);
    168     if (RT_FAILURE(rc))
    169         return rc;
    170     return cchFirst + cchSecond;
     163    char szTmp[64+32+32+32];
     164    char *pszTmp = cbBuf >= sizeof(szTmp) ? pszBuf : szTmp;
     165    size_t cchResult = RTStrFormatNumber(pszTmp, pu128->QWords.qw1, 16, 0, 0, fFlags | RTSTR_F_64BIT);
     166    cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu128->QWords.qw0, 16, 8, 0,
     167                                   (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL);
     168    if (pszTmp == pszBuf)
     169        return cchResult;
     170    int rc = RTStrCopy(pszBuf, cbBuf, pszTmp);
     171    if (RT_SUCCESS(rc))
     172        return cchResult;
     173    return rc;
    171174}
    172175
     
    182185    char szTmp[64+32+32+32];
    183186    char *pszTmp = cbBuf >= sizeof(szTmp) ? pszBuf : szTmp;
    184     size_t cchResult = RTStrFormatNumber(szTmp, pu256->QWords.qw3, 16, 0, 0, fFlags | RTSTR_F_64BIT);
     187    size_t cchResult = RTStrFormatNumber(pszTmp, pu256->QWords.qw3, 16, 0, 0, fFlags | RTSTR_F_64BIT);
    185188    cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu256->QWords.qw2, 16, 8, 0,
    186189                                   (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL);
     
    208211    char szTmp[64+32+32+32 + 32+32+32+32];
    209212    char *pszTmp = cbBuf >= sizeof(szTmp) ? pszBuf : szTmp;
    210     size_t cchResult = RTStrFormatNumber(szTmp, pu512->QWords.qw7, 16, 0, 0, fFlags | RTSTR_F_64BIT);
     213    size_t cchResult = RTStrFormatNumber(pszTmp, pu512->QWords.qw7, 16, 0, 0, fFlags | RTSTR_F_64BIT);
    211214    cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu512->QWords.qw6, 16, 8, 0,
    212215                                   (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette