VirtualBox

Changeset 26525 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Feb 15, 2010 3:33:33 AM (15 years ago)
Author:
vboxsync
Message:

Runtime: win.amd64 warnings.

Location:
trunk/src/VBox/Runtime/common
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/alloc/heapoffset.cpp

    r26344 r26525  
    375375     */
    376376    AssertReturn(cbMemory >= PAGE_SIZE, VERR_INVALID_PARAMETER);
     377    AssertReturn(cbMemory < UINT32_MAX, VERR_INVALID_PARAMETER);
    377378    AssertPtrReturn(pvMemory, VERR_INVALID_POINTER);
    378379    AssertReturn((uintptr_t)pvMemory + (cbMemory - 1) > (uintptr_t)cbMemory, VERR_INVALID_PARAMETER);
     
    394395    /* Init the heap anchor block. */
    395396    pHeapInt->u32Magic = RTHEAPOFFSET_MAGIC;
    396     pHeapInt->cbHeap = cbMemory;
    397     pHeapInt->cbFree = cbMemory
     397    pHeapInt->cbHeap = (uint32_t)cbMemory;
     398    pHeapInt->cbFree = (uint32_t)cbMemory
    398399                     - sizeof(RTHEAPOFFSETBLOCK)
    399400                     - sizeof(RTHEAPOFFSETINTERNAL);
  • trunk/src/VBox/Runtime/common/alloc/memcache.cpp

    r26452 r26525  
    167167    if (cbAlignment == 0)
    168168    {
    169         cbAlignment = UINT32_C(1) << ASMBitLastSetU32((uint32_t)cbObject);
     169        cbAlignment = (size_t)1 << ASMBitLastSetU32((uint32_t)cbObject);
    170170        if (cbAlignment > 64)
    171171            cbAlignment = 64;
     
    191191
    192192    pThis->u32Magic         = RTMEMCACHE_MAGIC;
    193     pThis->cbObject         = RT_ALIGN_Z(cbObject, cbAlignment);
    194     pThis->cbAlignment      = cbAlignment;
    195     pThis->cPerPage         = (PAGE_SIZE - RT_ALIGN_Z(sizeof(RTMEMCACHEPAGE), cbAlignment)) / pThis->cbObject;
     193    pThis->cbObject         = (uint32_t)RT_ALIGN_Z(cbObject, cbAlignment);
     194    pThis->cbAlignment      = (uint32_t)cbAlignment;
     195    pThis->cPerPage         = (uint32_t)((PAGE_SIZE - RT_ALIGN_Z(sizeof(RTMEMCACHEPAGE), cbAlignment)) / pThis->cbObject);
    196196    while (    RT_ALIGN_Z(sizeof(RTMEMCACHEPAGE), RT_MIN(cbAlignment, 8))
    197197             + pThis->cPerPage * pThis->cbObject
  • trunk/src/VBox/Runtime/common/checksum/crc32-zlib.cpp

    r21920 r26525  
    4040/** @todo Check if we can't just use the zlib code directly here. */
    4141
     42/**
     43 * Deal with blocks that are too big for the uInt type.
     44 */
     45static uint32_t rtCrc32ProcessTooBig(uint32_t uCRC32, const void *pv, size_t cb)
     46{
     47    const Bytef *pb = (const Bytef *)pv;
     48    do
     49    {
     50        uInt const cbChunk = cb <= ~(uInt)0 ? (uInt)cb : ~(uInt)0;
     51        uCRC32 = crc32(uCRC32, pb, cbChunk);
     52        pb += cbChunk;
     53        cb -= cbChunk;
     54    } while (!cb);
     55    return uCRC32;
     56}
     57
    4258RTDECL(uint32_t) RTCrc32(const void *pv, register size_t cb)
    4359{
    4460    uint32_t uCrc = crc32(0, NULL, 0);
    45     return crc32(uCrc, (const Bytef *)pv, cb);
     61    if (RT_UNLIKELY((uInt)cb == cb))
     62        uCrc = crc32(uCrc, (const Bytef *)pv, (uInt)cb);
     63    else
     64        uCrc = rtCrc32ProcessTooBig(uCrc, pv, cb);
     65    return uCrc;
    4666}
    4767RT_EXPORT_SYMBOL(RTCrc32);
     
    5777RTDECL(uint32_t) RTCrc32Process(uint32_t uCRC32, const void *pv, size_t cb)
    5878{
    59     return crc32(uCRC32, (const Bytef *)pv, cb);
     79    if (RT_UNLIKELY((uInt)cb == cb))
     80        uCRC32 = crc32(uCRC32, (const Bytef *)pv, (uInt)cb);
     81    else
     82        uCRC32 = rtCrc32ProcessTooBig(uCRC32, pv, cb);
     83    return uCRC32;
    6084}
    6185RT_EXPORT_SYMBOL(RTCrc32Process);
  • trunk/src/VBox/Runtime/common/misc/getoptargv.cpp

    r26478 r26525  
    8787            return false;
    8888        default:
    89             return memchr(pszSeparators, ch, cchSeparators);
     89            return memchr(pszSeparators, ch, cchSeparators) != NULL;
    9090    }
    9191}
  • trunk/src/VBox/Runtime/common/misc/s3.cpp

    r25645 r26525  
    137137}
    138138
    139 static char* rtS3ParseHeaders(char** ppHeaders, size_t cHead)
     139static char* rtS3ParseHeaders(char** ppHeaders, size_t cHeadEnts)
    140140{
    141141    char pszEmpty[] = "";
     
    143143    char *pszDate = pszEmpty;
    144144    char *pszType = pszEmpty;
    145     for(size_t i=0; i < cHead; ++i)
     145    for(size_t i=0; i < cHeadEnts; ++i)
    146146    {
    147147        if(ppHeaders[i] != NULL)
     
    171171}
    172172
    173 static char* rtS3Canonicalize(const char* pszAction, const char* pszBucket, const char* pszKey, char** ppszHead, size_t cHead)
     173static char* rtS3Canonicalize(const char* pszAction, const char* pszBucket, const char* pszKey, char** papszHeadEnts, size_t cHeadEnts)
    174174{
    175175    char* pszRes;
    176176    /* Grep the necessary info out of the headers & put them in a string */
    177     char* pszHead = rtS3ParseHeaders(ppszHead, cHead);
     177    char* pszHead = rtS3ParseHeaders(papszHeadEnts, cHeadEnts);
    178178    /* Create the string which will be used as signature */
    179179    RTStrAPrintf(&pszRes, "%s\n%s\n/",
     
    199199}
    200200
    201 static char* rtS3CreateSignature(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey, char** ppszHead, size_t cHead)
     201static char* rtS3CreateSignature(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey,
     202                                 char** papszHeadEnts, size_t cHeadEnts)
    202203{
    203204    /* Create a string we can sign */
    204     char* pszSig = rtS3Canonicalize(pszAction, pszBucket, pszKey, ppszHead, cHead);
     205    char* pszSig = rtS3Canonicalize(pszAction, pszBucket, pszKey, papszHeadEnts, cHeadEnts);
    205206//    printf ("Sig %s\n", pszSig);
    206207    /* Sign the string by creating a SHA1 finger print */
    207208    char pszSigEnc[1024];
    208209    unsigned int cSigEnc = sizeof(pszSigEnc);
    209     HMAC(EVP_sha1(), pS3Int->pszSecretKey, strlen(pS3Int->pszSecretKey),
     210    HMAC(EVP_sha1(), pS3Int->pszSecretKey, (int)strlen(pS3Int->pszSecretKey),
    210211         (const unsigned char*)pszSig, strlen(pszSig),
    211212         (unsigned char*)pszSigEnc, &cSigEnc);
     
    220221}
    221222
    222 static char* rtS3CreateAuthHeader(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey, char** ppszHead, size_t cHead)
     223static char* rtS3CreateAuthHeader(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey,
     224                                  char** papszHeadEnts, size_t cHeadEnts)
    223225{
    224226    char *pszAuth;
    225227    /* Create a signature out of the header & the bucket/key info */
    226     char *pszSigBase64Enc = rtS3CreateSignature(pS3Int, pszAction, pszBucket, pszKey, ppszHead, cHead);
     228    char *pszSigBase64Enc = rtS3CreateSignature(pS3Int, pszAction, pszBucket, pszKey, papszHeadEnts, cHeadEnts);
    227229    /* Create the authorization header entry */
    228230    RTStrAPrintf(&pszAuth, "Authorization: AWS %s:%s",
     
    377379static int rtS3ReadXmlFromMemory(PRTS3TMPMEMCHUNK pChunk, const char* pszRootElement, xmlDocPtr *ppDoc, xmlNodePtr *ppCur)
    378380{
    379     *ppDoc = xmlReadMemory(pChunk->pszMem, pChunk->cSize, "", "ISO-8859-1", XML_PARSE_NOBLANKS);
     381    *ppDoc = xmlReadMemory(pChunk->pszMem, (int)pChunk->cSize, "", "ISO-8859-1", XML_PARSE_NOBLANKS);
    380382    if (*ppDoc == NULL)
    381383        return VERR_PARSE_ERROR;
     
    566568
    567569    /* Create the three basic header entries */
    568     char *ppszHead[3] =
     570    char *apszHead[3] =
    569571    {
    570572        rtS3HostHeader("", pS3Int->pszBaseUrl), /* Host entry */
     
    573575    };
    574576    /* Create the authorization header entry */
    575     ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", "", "", ppszHead, RT_ELEMENTS(ppszHead));
     577    apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", "", "", apszHead, RT_ELEMENTS(apszHead));
    576578
    577579    /* Add all headers to curl */
    578580    struct curl_slist* pHeaders = NULL; /* Init to NULL is important */
    579     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    580         pHeaders = curl_slist_append(pHeaders, ppszHead[i]);
     581    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     582        pHeaders = curl_slist_append(pHeaders, apszHead[i]);
    581583
    582584    /* Pass our list of custom made headers */
     
    592594    /* Regardless of the result, free all used resources first*/
    593595    curl_slist_free_all(pHeaders);
    594     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    595         RTStrFree(ppszHead[i]);
     596    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     597        RTStrFree(apszHead[i]);
    596598
    597599    /* On success parse the result */
     
    645647
    646648    /* Create the basic header entries */
    647     char *ppszHead[4] =
     649    char *apszHead[4] =
    648650    {
    649651        RTStrDup("Content-Length: 0"),                     /* Content length entry */
     
    653655    };
    654656    /* Create the authorization header entry */
    655     ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, "", ppszHead, RT_ELEMENTS(ppszHead));
     657    apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead));
    656658
    657659    /* Add all headers to curl */
    658660    struct curl_slist* pHeaders = NULL; /* Init to NULL is important */
    659     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    660         pHeaders = curl_slist_append(pHeaders, ppszHead[i]);
     661    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     662        pHeaders = curl_slist_append(pHeaders, apszHead[i]);
    661663
    662664    /* Pass our list of custom made headers */
     
    681683    /* Regardless of the result, free all used resources first*/
    682684    curl_slist_free_all(pHeaders);
    683     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    684         RTStrFree(ppszHead[i]);
     685    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     686        RTStrFree(apszHead[i]);
    685687
    686688    return rc;
     
    700702
    701703    /* Create the three basic header entries */
    702     char *ppszHead[3] =
     704    char *apszHead[3] =
    703705    {
    704706        rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
     
    707709    };
    708710    /* Create the authorization header entry */
    709     ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, "", ppszHead, RT_ELEMENTS(ppszHead));
     711    apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead));
    710712
    711713    /* Add all headers to curl */
    712714    struct curl_slist* pHeaders = NULL; /* Init to NULL is important */
    713     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    714         pHeaders = curl_slist_append(pHeaders, ppszHead[i]);
     715    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     716        pHeaders = curl_slist_append(pHeaders, apszHead[i]);
    715717
    716718    /* Pass our list of custom made headers */
     
    731733    /* Regardless of the result, free all used resources first*/
    732734    curl_slist_free_all(pHeaders);
    733     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    734         RTStrFree(ppszHead[i]);
     735    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     736        RTStrFree(apszHead[i]);
    735737
    736738    return rc;
     
    752754
    753755    /* Create the three basic header entries */
    754     char *ppszHead[3] =
     756    char *apszHead[3] =
    755757    {
    756758        rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
     
    759761    };
    760762    /* Create the authorization header entry */
    761     ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, "", ppszHead, RT_ELEMENTS(ppszHead));
     763    apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead));
    762764
    763765    /* Add all headers to curl */
    764766    struct curl_slist* pHeaders = NULL; /* Init to NULL is important */
    765     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    766         pHeaders = curl_slist_append(pHeaders, ppszHead[i]);
     767    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     768        pHeaders = curl_slist_append(pHeaders, apszHead[i]);
    767769
    768770    /* Pass our list of custom made headers */
     
    779781    /* Regardless of the result, free all used resources first*/
    780782    curl_slist_free_all(pHeaders);
    781     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    782         RTStrFree(ppszHead[i]);
     783    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     784        RTStrFree(apszHead[i]);
    783785
    784786    /* On success parse the result */
     
    832834
    833835    /* Create the three basic header entries */
    834     char *ppszHead[3] =
     836    char *apszHead[3] =
    835837    {
    836838        rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
     
    839841    };
    840842    /* Create the authorization header entry */
    841     ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, pszKeyName, ppszHead, RT_ELEMENTS(ppszHead));
     843    apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead));
    842844
    843845    /* Add all headers to curl */
    844846    struct curl_slist* pHeaders = NULL; /* Init to NULL is important */
    845     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    846         pHeaders = curl_slist_append(pHeaders, ppszHead[i]);
     847    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     848        pHeaders = curl_slist_append(pHeaders, apszHead[i]);
    847849
    848850    /* Pass our list of custom made headers */
     
    857859    /* Regardless of the result, free all used resources first*/
    858860    curl_slist_free_all(pHeaders);
    859     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    860         RTStrFree(ppszHead[i]);
     861    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     862        RTStrFree(apszHead[i]);
    861863
    862864    return rc;
     
    882884
    883885    /* Create the three basic header entries */
    884     char *ppszHead[3] =
     886    char *apszHead[3] =
    885887    {
    886888        rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */
     
    889891    };
    890892    /* Create the authorization header entry */
    891     ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, pszKeyName, ppszHead, RT_ELEMENTS(ppszHead));
     893    apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead));
    892894
    893895    /* Add all headers to curl */
    894896    struct curl_slist* pHeaders = NULL; /* Init to NULL is important */
    895     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    896         pHeaders = curl_slist_append(pHeaders, ppszHead[i]);
     897    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     898        pHeaders = curl_slist_append(pHeaders, apszHead[i]);
    897899
    898900    /* Pass our list of custom made headers */
     
    908910    /* Regardless of the result, free all used resources first*/
    909911    curl_slist_free_all(pHeaders);
    910     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    911         RTStrFree(ppszHead[i]);
     912    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     913        RTStrFree(apszHead[i]);
    912914
    913915    /* Close the open file */
     
    950952    RTStrAPrintf(&pszContentLength, "Content-Length: %lu", cbFileSize);
    951953    /* Create the three basic header entries */
    952     char *ppszHead[5] =
     954    char *apszHead[5] =
    953955    {
    954956        /* todo: For now we use octet-stream for all types. Later we should try
     
    962964    };
    963965    /* Create the authorization header entry */
    964     ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, pszKeyName, ppszHead, RT_ELEMENTS(ppszHead));
     966    apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead));
    965967
    966968    /* Add all headers to curl */
    967969    struct curl_slist* pHeaders = NULL; /* Init to NULL is important */
    968     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    969         pHeaders = curl_slist_append(pHeaders, ppszHead[i]);
     970    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     971        pHeaders = curl_slist_append(pHeaders, apszHead[i]);
    970972
    971973    /* Pass our list of custom made headers */
     
    988990    /* Regardless of the result, free all used resources first*/
    989991    curl_slist_free_all(pHeaders);
    990     for(size_t i=0; i < RT_ELEMENTS(ppszHead); ++i)
    991         RTStrFree(ppszHead[i]);
     992    for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i)
     993        RTStrFree(apszHead[i]);
    992994
    993995    /* Close the open file */
  • trunk/src/VBox/Runtime/common/misc/zip.cpp

    r25000 r26525  
    17261726# endif
    17271727
    1728             unsigned cbDstActual = lzf_compress(pvSrc, cbSrc, pvDst, cbDst);
     1728            unsigned cbDstActual = lzf_compress(pvSrc, (unsigned)cbSrc, pvDst, (unsigned)cbDst);    /** @todo deal with size type overflows */
    17291729            if (RT_UNLIKELY(cbDstActual < 1))
    17301730                return VERR_BUFFER_OVERFLOW;
     
    18181818        {
    18191819#ifdef RTZIP_USE_LZF
    1820             unsigned cbDstActual = lzf_decompress(pvSrc, cbSrc, pvDst, cbDst);
     1820            unsigned cbDstActual = lzf_decompress(pvSrc, (unsigned)cbSrc, pvDst, (unsigned)cbDst);  /** @todo deal with size type overflows */
    18211821            if (RT_UNLIKELY(cbDstActual < 1))
    18221822            {
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