VirtualBox

Changeset 25000 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Nov 26, 2009 2:22:44 PM (15 years ago)
Author:
vboxsync
Message:

IPRT: Fixed -Wshadow warnings, found two bugs in error paths.

Location:
trunk/src/VBox/Runtime
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/VBox/strformat-vbox.cpp

    r14061 r25000  
    107107            {
    108108                int rc = va_arg(*pArgs, int);
    109                 char ch = *(*ppszFormat)++;
     109                ch = *(*ppszFormat)++;
    110110#ifdef IN_RING3                         /* we don't want this anywhere else yet. */
    111111                PCRTSTATUSMSG pMsg = RTErrGet(rc);
     
    152152            case 'h':
    153153            {
    154                 char ch = *(*ppszFormat)++;
     154                ch = *(*ppszFormat)++;
    155155                switch (ch)
    156156                {
  • trunk/src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h

    r24678 r25000  
    489489                 */
    490490                AssertMsgReturn(Value == (RTUINTPTR)Value, (FMT_ELF_ADDR "\n", Value), VERR_SYMBOL_VALUE_TOO_BIG);
    491                 int rc = pfnCallback(pMod, pszName, ~0, (RTUINTPTR)Value, pvUser);
     491                rc = pfnCallback(pMod, pszName, ~0, (RTUINTPTR)Value, pvUser);
    492492                if (rc)
    493493                    return rc;
     
    873873        for (unsigned i = 0; i < cbName; i++, off++)
    874874        {
    875             int rc = pModElf->pReader->pfnRead(pModElf->pReader, pszName + i, 1, off);
     875            rc = pModElf->pReader->pfnRead(pModElf->pReader, pszName + i, 1, off);
    876876            if (RT_FAILURE(rc))
    877877            {
  • trunk/src/VBox/Runtime/common/misc/handletablectx.cpp

    r24181 r25000  
    176176                &&  pThis->cCur < pThis->cMax)
    177177            {
    178                 uint32_t i;
    179 
    180178                pThis->papvLevel1[iLevel1New] = paTable;
    181179
  • trunk/src/VBox/Runtime/common/misc/handletablesimple.cpp

    r24181 r25000  
    170170                /* link all entries into a free list. */
    171171                Assert(!(pThis->cCur % RTHT_LEVEL2_ENTRIES));
    172                 for (uint32_t i = 0; i < RTHT_LEVEL2_ENTRIES - 1; i++)
     172                for (i = 0; i < RTHT_LEVEL2_ENTRIES - 1; i++)
    173173                    RTHT_SET_FREE_IDX((PRTHTENTRYFREE)&paTable[i], i + 1 + pThis->cCur);
    174174                RTHT_SET_FREE_IDX((PRTHTENTRYFREE)&paTable[RTHT_LEVEL2_ENTRIES - 1], NIL_RTHT_INDEX);
  • trunk/src/VBox/Runtime/common/misc/thread.cpp

    r23125 r25000  
    136136         * But first, we'll create the semaphore.
    137137         */
    138         int rc = RTSemRWCreate(&g_ThreadRWSem);
     138        rc = RTSemRWCreate(&g_ThreadRWSem);
    139139        if (RT_SUCCESS(rc))
    140140        {
  • trunk/src/VBox/Runtime/common/misc/zip.cpp

    r22007 r25000  
    565565    pZip->u.Zlib.next_out = (Bytef *)pvBuf;
    566566    pZip->u.Zlib.avail_out = (uInt)cbBuf;                   Assert(pZip->u.Zlib.avail_out == cbBuf);
    567     int rc = Z_OK;
    568     /* Be greedy reading input, even if no output buffer is left. It's possible
     567
     568    /*
     569     * Be greedy reading input, even if no output buffer is left. It's possible
    569570     * that it's just the end of stream marker which needs to be read. Happens
    570      * for incompressible blocks just larger than the input buffer size.*/
     571     * for incompressible blocks just larger than the input buffer size.
     572     */
    571573    while (pZip->u.Zlib.avail_out > 0 || pZip->u.Zlib.avail_in <= 0)
    572574    {
     
    587589         * Pass it on to zlib.
    588590         */
    589         rc = inflate(&pZip->u.Zlib, Z_NO_FLUSH);
     591        int rc = inflate(&pZip->u.Zlib, Z_NO_FLUSH);
    590592        if (rc == Z_STREAM_END)
    591593        {
  • trunk/src/VBox/Runtime/common/string/strformatrt.cpp

    r23961 r25000  
    572572            case 'f':
    573573            {
    574                 char ch = *(*ppszFormat)++;
    575                 switch (ch)
     574                switch (*(*ppszFormat)++)
    576575                {
    577576                    /*
     
    607606
    608607                    default:
    609                         AssertMsgFailed(("Invalid status code format type '%.10s'!\n", ch, pszFormatOrg));
     608                        AssertMsgFailed(("Invalid status code format type '%.10s'!\n", pszFormatOrg));
    610609                        break;
    611610                }
     
    619618            case 'h':
    620619            {
    621                 char ch = *(*ppszFormat)++;
    622                 switch (ch)
     620                switch (*(*ppszFormat)++)
    623621                {
    624622                    /*
     
    632630                        if (pu8)
    633631                        {
    634                             ch = *(*ppszFormat)++;
    635                             switch (ch)
     632                            switch (*(*ppszFormat)++)
    636633                            {
    637634                                /*
     
    687684
    688685                                default:
    689                                     AssertMsgFailed(("Invalid status code format type '%.10s'!\n", ch, pszFormatOrg));
     686                                    AssertMsgFailed(("Invalid status code format type '%.10s'!\n", pszFormatOrg));
    690687                                    break;
    691688                            }
     
    704701                    case 'r':
    705702                    {
    706 
    707                         char ch = *(*ppszFormat)++;
    708703                        uint32_t hrc = va_arg(*pArgs, uint32_t);
    709704                        PCRTCOMERRMSG pMsg = RTErrCOMGet(hrc);
    710                         switch (ch)
     705                        switch (*(*ppszFormat)++)
    711706                        {
    712707                            case 'c':
     
    725720
    726721                    default:
    727                         AssertMsgFailed(("Invalid status code format type '%.10s'!\n", ch, pszFormatOrg));
     722                        AssertMsgFailed(("Invalid status code format type '%.10s'!\n", pszFormatOrg));
    728723                        return 0;
    729724
     
    738733            {
    739734                int rc = va_arg(*pArgs, int);
    740                 char ch = *(*ppszFormat)++;
    741735#ifdef IN_RING3                         /* we don't want this anywhere else yet. */
    742736                PCRTSTATUSMSG pMsg = RTErrGet(rc);
    743                 switch (ch)
     737                switch (*(*ppszFormat)++)
    744738                {
    745739                    case 'c':
     
    756750                }
    757751#else /* !IN_RING3 */
    758                 switch (ch)
     752                switch (*(*ppszFormat)++)
    759753                {
    760754                    case 'c':
     
    778772            {
    779773                long rc = va_arg(*pArgs, long);
    780                 char ch = *(*ppszFormat)++;
    781774# if defined(RT_OS_WINDOWS)
    782775                PCRTWINERRMSG pMsg = RTErrWinGet(rc);
    783776# endif
    784                 switch (ch)
     777                switch (*(*ppszFormat)++)
    785778                {
    786779# if defined(RT_OS_WINDOWS)
  • trunk/src/VBox/Runtime/common/string/utf-8.cpp

    r21791 r25000  
    11601160               &&   !(uMask & 1))
    11611161        {
    1162             unsigned uch = *--puch;
     1162            uch = *--puch;
    11631163            if ((uch & 0xc0) != 0x80)
    11641164            {
  • trunk/src/VBox/Runtime/generic/env-generic.cpp

    r21337 r25000  
    245245            for (size_t iVar = 0; iVar < cVars; iVar++)
    246246            {
    247                 int rc = RTStrCurrentCPToUtf8(&pIntEnv->papszEnv[iVar], papszEnv[iVar]);
    248                 if (RT_FAILURE(rc))
     247                int rc2 = RTStrCurrentCPToUtf8(&pIntEnv->papszEnv[iVar], papszEnv[iVar]);
     248                if (RT_FAILURE(rc2))
    249249                {
    250250                    pIntEnv->cVars = iVar;
    251251                    RTEnvDestroy(pIntEnv);
    252                     return rc;
     252                    return rc2;
    253253                }
    254254            }
     
    265265                    pIntEnv->cVars = iVar;
    266266                    RTEnvDestroy(pIntEnv);
    267                     return rc;
     267                    return VERR_NO_STR_MEMORY;
    268268                }
    269269                pIntEnv->papszEnv[iVar] = pszVar;
  • trunk/src/VBox/Runtime/generic/uuid-generic.cpp

    r21337 r25000  
    324324RTDECL(int)  RTUuidToUtf16(PCRTUUID pUuid, PRTUTF16 pwszString, size_t cwcString)
    325325{
    326     static const char g_achDigits[17] = "0123456789abcdef";
    327326    uint32_t u32TimeLow;
    328327    unsigned u;
  • trunk/src/VBox/Runtime/r3/tcp.cpp

    r24219 r25000  
    603603                 * we cannot safely access the handle so we'll have to return here.
    604604                 */
    605                 RTSOCKET SockServer = rtTcpAtomicXchgSock(&pServer->SockServer, NIL_RTSOCKET);
     605                SockServer = rtTcpAtomicXchgSock(&pServer->SockServer, NIL_RTSOCKET);
    606606                rtTcpServerSetState(pServer, RTTCPSERVERSTATE_STOPPED, RTTCPSERVERSTATE_STOPPING);
    607607                rtTcpClose(SockServer, "Listener: server stopped", false /*fTryGracefulShutdown*/);
  • trunk/src/VBox/Runtime/r3/xml.cpp

    r23973 r25000  
    340340void MemoryBuf::setPos (uint64_t aPos)
    341341{
    342     size_t pos = (size_t) aPos;
    343     if ((uint64_t) pos != aPos)
     342    size_t off = (size_t) aPos;
     343    if ((uint64_t) off != aPos)
    344344        throw EInvalidArg();
    345345
    346     if (pos > m->len)
     346    if (off > m->len)
    347347        throw EInvalidArg();
    348348
    349     m->pos = pos;
     349    m->pos = off;
    350350}
    351351
  • trunk/src/VBox/Runtime/testcase/tstFile.cpp

    r14831 r25000  
    180180            else
    181181            {
    182                 size_t cbWritten = 0;
     182                cbWritten = 0;
    183183                while (cbWritten < sizeof(szTestBuf))
    184184                {
  • trunk/src/VBox/Runtime/testcase/tstFileAio.cpp

    r23973 r25000  
    186186
    187187                        NanoTS = RTTimeNanoTS() - NanoTS;
    188                         unsigned SpeedKBs = cbTestFile / (NanoTS / 1000000000.0) / 1024;
     188                        unsigned SpeedKBs = (unsigned)(cbTestFile / (NanoTS / 1000000000.0) / 1024);
    189189
    190190                        RTPrintf("tstFileAio: Completed simple %s test: %d.%03d MB/sec\n",
  • trunk/src/VBox/Runtime/testcase/tstFork.cpp

    r20606 r25000  
    6969     */
    7070    pid_t pid = fork();
    71     if (pid == -1)
    72         RTTestFailed(hTest, "fork() failed: %d - %s", errno, strerror(errno));
    73     else if (pid == 0)
     71    if (pid == 0)
    7472    {
    7573        /*
    7674         * Check that the values has changed.
    7775         */
    78         int rc = 0;
     76        rc = 0;
    7977        if (ProcBefore == RTProcSelf())
    8078        {
     
    8482        return rc;
    8583    }
    86     else
     84    if (pid != -1)
    8785    {
    8886        /*
     
    9492         * Wait for the child.
    9593         */
    96         int rc = 1;
     94        rc = 1;
    9795        while (   waitpid(pid, &rc, 0)
    9896               && errno == EINTR)
     
    10199            RTTestFailed(hTest, "rc=%#x", rc);
    102100    }
     101    else
     102        RTTestFailed(hTest, "fork() failed: %d - %s", errno, strerror(errno));
    103103#endif
    104104
  • trunk/src/VBox/Runtime/testcase/tstLdr-4.cpp

    r19924 r25000  
    203203        if (aLoads[i].hLdrMod)
    204204        {
    205             int rc = RTLdrClose(aLoads[i].hLdrMod);
     205            rc = RTLdrClose(aLoads[i].hLdrMod);
    206206            if (RT_FAILURE(rc))
    207207            {
  • trunk/src/VBox/Runtime/testcase/tstOnce.cpp

    r10947 r25000  
    143143        char szName[16];
    144144        RTStrPrintf(szName, sizeof(szName), "ONCE2-%d\n", i);
    145         int rc = RTThreadCreate(&aThreads[i], Once2Thread, NULL, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, szName);
     145        rc = RTThreadCreate(&aThreads[i], Once2Thread, NULL, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, szName);
    146146        if (RT_FAILURE(rc))
    147147        {
     
    165165        {
    166166            int rc2;
    167             int rc = RTThreadWait(aThreads[i], 30*1000, &rc2);
     167            rc = RTThreadWait(aThreads[i], 30*1000, &rc2);
    168168            if (RT_FAILURE(rc))
    169169            {
  • trunk/src/VBox/Runtime/testcase/tstPath.cpp

    r20606 r25000  
    184184                if (s_aRTPathAbsExTests[i].pcszOutput[1] == 'p')
    185185                {
    186                     size_t cch = strlen(szTmp);
     186                    cch = strlen(szTmp);
    187187                    if (cch + strlen(s_aRTPathAbsExTests[i].pcszOutput) - 2 <= sizeof(szTmp))
    188188                        strcpy(szTmp + cch, s_aRTPathAbsExTests[i].pcszOutput + 2);
  • trunk/src/VBox/Runtime/testcase/tstRTCidr.cpp

    r20606 r25000  
    4646    do { \
    4747        RTIPV4ADDR Network, NetMask; \
    48         int rc = RTCidrStrToIPv4(String, &Network, &NetMask); \
    49         if ((rcExpected) && !rc) \
     48        int rc2 = RTCidrStrToIPv4(String, &Network, &NetMask); \
     49        if ((rcExpected) && !rc2) \
    5050        { \
    5151            RTTestIFailed("at line %d: '%s': expected %Rrc got %Rrc\n", \
    52                           __LINE__, String, (rcExpected), rc); \
     52                          __LINE__, String, (rcExpected), rc2); \
    5353        } \
    54         else if (   (rcExpected) != rc \
    55                  || (   rc == VINF_SUCCESS \
     54        else if (   (rcExpected) != rc2 \
     55                 || (   rc2 == VINF_SUCCESS \
    5656                     && (   (ExpectedNetwork) != Network \
    5757                         || (ExpectedNetMask) != NetMask))) \
    5858        { \
    5959            RTTestIFailed("at line %d: '%s': expected %Rrc got %Rrc, expected network %08x got %08x, expected netmask %08x got %08x\n", \
    60                           __LINE__, String, rcExpected, rc, (ExpectedNetwork), Network, (ExpectedNetMask), NetMask); \
     60                          __LINE__, String, rcExpected, rc2, (ExpectedNetwork), Network, (ExpectedNetMask), NetMask); \
    6161        } \
    6262    } while (0)
  • trunk/src/VBox/Runtime/testcase/tstRTProcWait.cpp

    r14831 r25000  
    7575        /* Wait for it to complete. */
    7676        int rc2;
    77         int rc = RTThreadWait(Thread, RT_INDEFINITE_WAIT, &rc2);
     77        rc = RTThreadWait(Thread, RT_INDEFINITE_WAIT, &rc2);
    7878        if (RT_SUCCESS(rc))
    7979            rc = rc2;
  • trunk/src/VBox/Runtime/testcase/tstTSC.cpp

    r17093 r25000  
    390390     */
    391391    RTPrintf("tstTSC: %RU64 ticks in %RU64 ns\n", uTSC, uNanoTS);
    392     uint64_t cHz = uTSC / ((long double)uNanoTS / (long double)1000000000);
     392    uint64_t cHz = (uint64_t)(uTSC / ((long double)uNanoTS / (long double)1000000000));
    393393    RTPrintf("tstTSC: Frequency %RU64 Hz", cHz);
    394394    if (cHz > _1G)
  • trunk/src/VBox/Runtime/testcase/tstTimer.cpp

    r14831 r25000  
    167167         * Start the timer and active waiting for the requested test period.
    168168         */
    169         uint64_t uTSBegin = RTTimeNanoTS();
     169        uTSBegin = RTTimeNanoTS();
    170170#ifndef RT_OS_WINDOWS
    171171        rc = RTTimerStart(pTimer, 0);
     
    182182        /* destroy the timer */
    183183        uint64_t uTSEnd = RTTimeNanoTS();
    184         uint64_t uTSDiff = uTSEnd - uTSBegin;
     184        uTSDiff = uTSEnd - uTSBegin;
    185185        rc = RTTimerDestroy(pTimer);
    186186        if (RT_FAILURE(rc))
  • trunk/src/VBox/Runtime/testcase/tstTimerLR.cpp

    r14831 r25000  
    160160         * Start the timer an actively wait for it for the period requested.
    161161         */
    162         uint64_t uTSBegin = RTTimeNanoTS();
     162        uTSBegin = RTTimeNanoTS();
    163163        rc = RTTimerLRStart(hTimerLR, 0);
    164164        if (RT_FAILURE(rc))
     
    180180
    181181        uint64_t uTSEnd = RTTimeNanoTS();
    182         uint64_t uTSDiff = uTSEnd - uTSBegin;
     182        uTSDiff = uTSEnd - uTSBegin;
    183183        RTPrintf("uTS=%RI64 (%RU64 - %RU64)\n", uTSDiff, uTSBegin, uTSEnd);
    184184
  • trunk/src/VBox/Runtime/testcase/tstUtf8.cpp

    r23223 r25000  
    469469            RTTestFailed(hTest, "UTF-8 -> UTF-16 failed compare!");
    470470
    471         char *pszUtf8;
    472471        rc = RTUtf16ToUtf8(pwszUtf16, &pszUtf8);
    473472        if (rc == VINF_SUCCESS)
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