VirtualBox

Changeset 62363 in vbox


Ignore:
Timestamp:
Jul 20, 2016 3:45:58 PM (8 years ago)
Author:
vboxsync
Message:

Main/VBoxSVC: enable -Wconversion plus a couple of fixes (all harmless)

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/shflsvc.h

    r59204 r62363  
    181181DECLINLINE(uint32_t) ShflStringSizeOfBuffer(PCSHFLSTRING pString)
    182182{
    183     return pString ? sizeof(SHFLSTRING) - sizeof(pString->String) + pString->u16Size : 0;
     183    return pString ? (uint32_t)(sizeof(SHFLSTRING) - sizeof(pString->String) + pString->u16Size) : 0;
    184184}
    185185
     
    201201    {
    202202        pString = (PSHFLSTRING)pvBuffer;
    203         pString->u16Size = u32Size - u32HeaderSize;
     203        pString->u16Size = (uint16_t)(u32Size - u32HeaderSize);
    204204        pString->u16Length = 0;
    205205        if (pString->u16Size >= sizeof(pString->String.ucs2[0]))
  • trunk/src/VBox/Main/Makefile.kmk

    r62349 r62363  
    306306
    307307ifneq ($(KBUILD_TARGET),win)
    308  VBoxSVC_CXXFLAGS = -Wunused
     308 VBoxSVC_CXXFLAGS = -Wunused -Wconversion
    309309endif
    310310
  • trunk/src/VBox/Main/src-all/DisplayResampleImage.cpp

    r55401 r62363  
    5050
    5151/* 2.0.10: cast instead of floor() yields 35% performance improvement.
    52         Thanks to John Buckman. */
     52        Thanks to John Buckman. */
    5353
    5454#define floor2(exp) ((long) exp)
     
    7878#define gdTrueColorGetBlue(c) ((c) & 0x0000FF)
    7979#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \
    80         ((r) << 16) + \
    81         ((g) << 8) + \
    82         (b))
     80        ((r) << 16) + \
     81        ((g) << 8) + \
     82        (b))
    8383
    8484void gdImageCopyResampled (uint8_t *dst,
    85                       uint8_t *src,
    86                       int dstX, int dstY,
    87                       int srcX, int srcY,
    88                       int dstW, int dstH, int srcW, int srcH)
     85                      uint8_t *src,
     86                      int dstX, int dstY,
     87                      int srcX, int srcY,
     88                      int dstW, int dstH, int srcW, int srcH)
    8989{
    9090  int x, y;
     
    9494      sy1 = ((double) y - (double) dstY) * (double) srcH / (double) dstH;
    9595      sy2 = ((double) (y + 1) - (double) dstY) * (double) srcH /
    96         (double) dstH;
     96        (double) dstH;
    9797      for (x = dstX; (x < dstX + dstW); x++)
    98         {
    99           double sx, sy;
    100           double spixels = 0;
    101           double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
    102           sx1 = ((double) x - (double) dstX) * (double) srcW / dstW;
    103           sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / dstW;
    104           sy = sy1;
    105           do
    106             {
    107               double yportion;
    108               if (floor2 (sy) == floor2 (sy1))
    109                 {
    110                   yportion = 1.0 - (sy - floor2 (sy));
    111                   if (yportion > sy2 - sy1)
    112                     {
    113                       yportion = sy2 - sy1;
    114                     }
    115                   sy = floor2 (sy);
    116                 }
    117               else if (sy == floor2 (sy2))
    118                 {
    119                   yportion = sy2 - floor2 (sy2);
    120                 }
    121               else
    122                 {
    123                   yportion = 1.0;
    124                 }
    125               sx = sx1;
    126               do
    127                 {
    128                   double xportion;
    129                   double pcontribution;
    130                   int p;
    131                   if (floor2 (sx) == floor2 (sx1))
    132                     {
    133                       xportion = 1.0 - (sx - floor2 (sx));
    134                       if (xportion > sx2 - sx1)
    135                         {
    136                           xportion = sx2 - sx1;
    137                         }
    138                       sx = floor2 (sx);
    139                     }
    140                   else if (sx == floor2 (sx2))
    141                     {
    142                       xportion = sx2 - floor2 (sx2);
    143                     }
    144                   else
    145                     {
    146                       xportion = 1.0;
    147                     }
    148                   pcontribution = xportion * yportion;
    149                   /* 2.08: previously srcX and srcY were ignored.
    150                      Andrew Pattison */
    151                   p = gdImageGetTrueColorPixel (src,
    152                                                 (int) sx + srcX,
    153                                                 (int) sy + srcY, srcW);
    154                   red += gdTrueColorGetRed (p) * pcontribution;
    155                   green += gdTrueColorGetGreen (p) * pcontribution;
    156                   blue += gdTrueColorGetBlue (p) * pcontribution;
    157                   alpha += gdTrueColorGetAlpha (p) * pcontribution;
    158                   spixels += xportion * yportion;
    159                   sx += 1.0;
    160                 }
    161               while (sx < sx2);
    162               sy += 1.0;
    163             }
    164           while (sy < sy2);
    165           if (spixels != 0.0)
    166             {
    167               red /= spixels;
    168               green /= spixels;
    169               blue /= spixels;
    170               alpha /= spixels;
    171             }
    172           /* Clamping to allow for rounding errors above */
    173           if (red > 255.0)
    174             {
    175               red = 255.0;
    176             }
    177           if (green > 255.0)
    178             {
    179               green = 255.0;
    180             }
    181           if (blue > 255.0)
    182             {
    183               blue = 255.0;
    184             }
    185           if (alpha > gdAlphaMax)
    186             {
    187               alpha = gdAlphaMax;
    188             }
    189           gdImageSetPixel (dst,
    190                            x, y,
    191                            gdTrueColorAlpha ((int) red,
    192                                              (int) green,
    193                                              (int) blue, (int) alpha), dstW);
    194         }
     98        {
     99          double sx, sy;
     100          double spixels = 0;
     101          double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
     102          sx1 = ((double) x - (double) dstX) * (double) srcW / dstW;
     103          sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / dstW;
     104          sy = sy1;
     105          do
     106            {
     107              double yportion;
     108              if (floor2 (sy) == floor2 (sy1))
     109                {
     110                  yportion = 1.0 - (sy - (double)floor2 (sy));
     111                  if (yportion > sy2 - sy1)
     112                    {
     113                      yportion = sy2 - sy1;
     114                    }
     115                  sy = (double)floor2 (sy);
     116                }
     117              else if (sy == floor2 (sy2))
     118                {
     119                  yportion = sy2 - (double)floor2 (sy2);
     120                }
     121              else
     122                {
     123                  yportion = 1.0;
     124                }
     125              sx = sx1;
     126              do
     127                {
     128                  double xportion;
     129                  double pcontribution;
     130                  int p;
     131                  if (floor2 (sx) == floor2 (sx1))
     132                    {
     133                      xportion = 1.0 - (sx - (double)floor2 (sx));
     134                      if (xportion > sx2 - sx1)
     135                        {
     136                          xportion = sx2 - sx1;
     137                        }
     138                      sx = (double)floor2 (sx);
     139                    }
     140                  else if (sx == floor2 (sx2))
     141                    {
     142                      xportion = sx2 - (double)floor2 (sx2);
     143                    }
     144                  else
     145                    {
     146                      xportion = 1.0;
     147                    }
     148                  pcontribution = xportion * yportion;
     149                  /* 2.08: previously srcX and srcY were ignored.
     150                     Andrew Pattison */
     151                  p = gdImageGetTrueColorPixel (src,
     152                                                (int) sx + srcX,
     153                                                (int) sy + srcY, srcW);
     154                  red += gdTrueColorGetRed (p) * pcontribution;
     155                  green += gdTrueColorGetGreen (p) * pcontribution;
     156                  blue += gdTrueColorGetBlue (p) * pcontribution;
     157                  alpha += gdTrueColorGetAlpha (p) * pcontribution;
     158                  spixels += xportion * yportion;
     159                  sx += 1.0;
     160                }
     161              while (sx < sx2);
     162              sy += 1.0;
     163            }
     164          while (sy < sy2);
     165          if (spixels != 0.0)
     166            {
     167              red /= spixels;
     168              green /= spixels;
     169              blue /= spixels;
     170              alpha /= spixels;
     171            }
     172          /* Clamping to allow for rounding errors above */
     173          if (red > 255.0)
     174            {
     175              red = 255.0;
     176            }
     177          if (green > 255.0)
     178            {
     179              green = 255.0;
     180            }
     181          if (blue > 255.0)
     182            {
     183              blue = 255.0;
     184            }
     185          if (alpha > gdAlphaMax)
     186            {
     187              alpha = gdAlphaMax;
     188            }
     189          gdImageSetPixel (dst,
     190                           x, y,
     191                           gdTrueColorAlpha ((int) red,
     192                                             (int) green,
     193                                             (int) blue, (int) alpha), dstW);
     194        }
    195195    }
    196196}
  • trunk/src/VBox/Main/src-all/DisplayUtils.cpp

    r54792 r62363  
    7070                        if (cbBlock > 2 * sizeof(uint32_t))
    7171                        {
    72                             cbData = cbBlock - 2 * sizeof(uint32_t);
     72                            cbData = (uint32_t)(cbBlock - 2 * sizeof(uint32_t));
    7373                            pu8Data = (uint8_t *)RTMemAlloc(cbData);
    7474                            if (pu8Data == NULL)
  • trunk/src/VBox/Main/src-all/ProgressImpl.cpp

    r55190 r62363  
    625625            uint64_t ullTimeNow = RTTimeMilliTS();
    626626            uint64_t ullTimeElapsed = ullTimeNow - m_ullTimestamp;
    627             uint64_t ullTimeTotal = (uint64_t)(ullTimeElapsed * 100 / dPercentDone);
     627            uint64_t ullTimeTotal = (uint64_t)((double)ullTimeElapsed * 100 / dPercentDone);
    628628            uint64_t ullTimeRemaining = ullTimeTotal - ullTimeElapsed;
    629629
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r62221 r62363  
    12991299     */
    13001300    char    *pszOvfNameBase = NULL;
    1301     size_t   cchOvfNameBase = 0;
     1301    size_t   cchOvfNameBase = 0; NOREF(cchOvfNameBase);
    13021302    unsigned cLeftToFind = 3;
    13031303    HRESULT  hrc = S_OK;
     
    14471447    int vrc = RTVfsIoStrmReadAll(hVfsIosOvf, &pvBufferedOvf, &cbBufferedOvf);
    14481448    uint32_t cRefs = RTVfsIoStrmRelease(hVfsIosOvf);     /* consumes stream handle.  */
     1449    NOREF(cRefs);
    14491450    Assert(cRefs == 0);
    14501451    if (RT_FAILURE(vrc))
  • trunk/src/VBox/Main/src-server/ClientWatcher.cpp

    r60066 r62363  
    966966                {
    967967                    uOld = ASMAtomicUoReadU8(&that->mUpdateAdaptCtr);
    968                     uNew = uOld ? uOld - 1 : uOld;
     968                    uNew = uOld ? (uint8_t)(uOld - 1) : uOld;
    969969                } while (!ASMAtomicCmpXchgU8(&that->mUpdateAdaptCtr, uNew, uOld));
    970970                Assert(uOld <= RT_ELEMENTS(s_aUpdateTimeoutSteps) - 1);
  • trunk/src/VBox/Main/src-server/HostUSBDeviceImpl.cpp

    r61667 r62363  
    216216    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    217217
    218     *aVersion = mUsb->bcdUSB >> 8;
     218    *aVersion = (USHORT)(mUsb->bcdUSB >> 8);
    219219
    220220    return S_OK;
     
    257257     */
    258258    if (mUsb->enmSpeed == USBDEVICESPEED_UNKNOWN)
    259         *aPortVersion = mUsb->bcdUSB >> 8;
     259        *aPortVersion = (USHORT)(mUsb->bcdUSB >> 8);
    260260    else
    261261    {
     
    459459        alock.release();
    460460        HRESULT hrc = i_attachToVM(aMachine, aCaptureFilename, aMaskedIfs);
    461         return SUCCEEDED(hrc);
     461        return hrc;
    462462    }
    463463
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r62047 r62363  
    88548854    const ComObjPtr<Medium> &pTarget = task.mMedium;
    88558855
    8856     uint64_t size = 0, logicalSize = 0;
    8857     MediumVariant_T variant = MediumVariant_Standard;
     8856    uint64_t size = 0; NOREF(size);
     8857    uint64_t logicalSize = 0; NOREF(logicalSize);
     8858    MediumVariant_T variant = MediumVariant_Standard; NOREF(variant);
    88588859
    88598860    /*
  • trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp

    r61173 r62363  
    2626#include "VirtualBoxImpl.h"
    2727
     28#include <iprt/ctype.h>
    2829#include <iprt/string.h>
    2930#include <iprt/cpp/utils.h>
     
    353354                    if (c >= 'a' && c <= 'f')
    354355                    {
    355                         /** @todo the runtime lacks an ascii lower/upper conv */
    356                         c &= 0xdf;
     356                        c = (char)RTLocCToUpper(c);
    357357                        *macAddressStr = c;
    358358                    }
    359359                    /* we only accept capital letters */
    360                     if (((c < '0') || (c > '9')) &&
    361                         ((c < 'A') || (c > 'F')))
     360                    if (   (c < '0' || c > '9')
     361                        && (c < 'A' || c > 'F'))
    362362                        rc = setError(E_INVALIDARG, tr("Invalid MAC address format"));
    363363                    /* the second digit must have even value for unicast addresses */
    364                     if ((i == 1) && (!!(c & 1) == (c >= '0' && c <= '9')))
     364                    if (   (i == 1)
     365                        && (!!(c & 1) == (c >= '0' && c <= '9')))
    365366                        rc = setError(E_INVALIDARG, tr("Invalid MAC address format"));
    366367
  • trunk/src/VBox/Main/src-server/NetworkServiceRunner.cpp

    r59153 r62363  
    153153        RTProcTerminate(m->mProcess);
    154154        int rc = RTProcWait(m->mProcess, RTPROCWAIT_FLAGS_BLOCK, NULL);
     155        NOREF(rc);
    155156    }
    156157
  • trunk/src/VBox/Main/src-server/VFSExplorerImpl.cpp

    r60448 r62363  
    173173    {
    174174        int vrc = taskThread(NULL, this);
     175        NOREF(vrc);
    175176    }
    176177
     
    352353    HRESULT rc = S_OK;
    353354
    354     float fPercentStep = 100.0f / aTask->filenames.size();
     355    float fPercentStep = 100.0f / (float)aTask->filenames.size();
    355356    try
    356357    {
     
    369370                throw setError(VBOX_E_FILE_ERROR, tr("Can't delete file '%s' (%Rrc)"), szPath, vrc);
    370371            if (aTask->progress)
    371                 aTask->progress->SetCurrentOperationProgress((ULONG)(fPercentStep * i));
     372                aTask->progress->SetCurrentOperationProgress((ULONG)(fPercentStep * (float)i));
    372373        }
    373374    }
  • trunk/src/VBox/Main/src-server/generic/NetIf-generic.cpp

    r56994 r62363  
    113113    if (fp)
    114114    {
    115         if (fgets(pszBuffer, cBufSize, fp))
     115        if (fgets(pszBuffer, (int)cBufSize, fp))
    116116        {
    117117            if (!strncmp(VBOXNETADPCTL_NAME ":", pszBuffer, sizeof(VBOXNETADPCTL_NAME)))
  • trunk/src/VBox/Main/src-server/generic/USBProxyBackendUsbIp.cpp

    r61127 r62363  
    532532                rc = VERR_INVALID_STATE;
    533533            }
    534             aMillies -= (RTTimeMilliTS() - msPollStart);
     534            aMillies -= (RTMSINTERVAL)(RTTimeMilliTS() - msPollStart);
    535535        }
    536536        else if (rc == VERR_TIMEOUT)
     
    667667    {
    668668        int rc = RTPollSetRemove(m->hPollSet, USBIP_POLL_ID_SOCKET);
     669        NOREF(rc);
    669670        Assert(RT_SUCCESS(rc) || rc == VERR_POLL_HANDLE_ID_NOT_FOUND);
    670671
  • trunk/src/VBox/Main/src-server/linux/NetIf-linux.cpp

    r57358 r62363  
    145145        RTUuidClear(&uuid);
    146146        memcpy(&uuid, Req.ifr_name, RT_MIN(sizeof(Req.ifr_name), sizeof(uuid)));
    147         uuid.Gen.u8ClockSeqHiAndReserved = (uuid.Gen.u8ClockSeqHiAndReserved & 0x3f) | 0x80;
    148         uuid.Gen.u16TimeHiAndVersion = (uuid.Gen.u16TimeHiAndVersion & 0x0fff) | 0x4000;
     147        uuid.Gen.u8ClockSeqHiAndReserved = (uint8_t)((uuid.Gen.u8ClockSeqHiAndReserved & 0x3f) | 0x80);
     148        uuid.Gen.u16TimeHiAndVersion = (uint16_t)((uuid.Gen.u16TimeHiAndVersion & 0x0fff) | 0x4000);
    149149        memcpy(uuid.Gen.au8Node, &Req.ifr_hwaddr.sa_data, sizeof(uuid.Gen.au8Node));
    150150        pInfo->Uuid = uuid;
     
    233233                    continue;
    234234                *pszEndOfName = 0;
    235                 int iFirstNonWS = strspn(buf, " ");
    236                 char *pszName = buf+iFirstNonWS;
     235                size_t iFirstNonWS = strspn(buf, " ");
     236                char *pszName = buf + iFirstNonWS;
    237237                NETIFINFO Info;
    238238                RT_ZERO(Info);
  • trunk/src/VBox/Main/src-server/linux/PerformanceLinux.cpp

    r60373 r62363  
    8282    uint64_t     mSingleUser, mSingleKernel, mSingleIdle;
    8383    uint32_t     mHZ;
    84     ULONG        totalRAM;
     84    ULONG        mTotalRAM;
    8585};
    8686
     
    101101    }
    102102    else
    103         mHZ = hz;
     103        mHZ = (uint32_t)hz;
    104104    LogFlowThisFunc(("mHZ=%u\n", mHZ));
    105105
     
    107107    int rc = RTSystemQueryTotalRam(&cb);
    108108    if (RT_FAILURE(rc))
    109         totalRAM = 0;
     109        mTotalRAM = 0;
    110110    else
    111         totalRAM = (ULONG)(cb / 1024);
     111        mTotalRAM = (ULONG)(cb / 1024);
    112112}
    113113
     
    212212int CollectorLinux::getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available)
    213213{
    214     AssertReturn(totalRAM, VERR_INTERNAL_ERROR);
     214    AssertReturn(mTotalRAM, VERR_INTERNAL_ERROR);
    215215    uint64_t cb;
    216216    int rc = RTSystemQueryAvailableRam(&cb);
    217217    if (RT_SUCCESS(rc))
    218218    {
    219         *total = totalRAM;
    220         *available = cb / 1024;
     219        *total = mTotalRAM;
     220        *available = (ULONG)(cb / 1024);
    221221        *used = *total - *available;
    222222    }
     
    413413char *CollectorLinux::trimNewline(char *pszName)
    414414{
    415     unsigned cbName = strlen(pszName);
     415    size_t cbName = strlen(pszName);
    416416    if (cbName == 0)
    417417        return pszName;
     
    427427char *CollectorLinux::trimTrailingDigits(char *pszName)
    428428{
    429     unsigned cbName = strlen(pszName);
     429    size_t cbName = strlen(pszName);
    430430    if (cbName == 0)
    431431        return pszName;
     
    452452{
    453453    unsigned cbName = 0;
    454     unsigned cbDevName = strlen(pszDevName);
     454    size_t cbDevName = strlen(pszDevName);
    455455    const char *pszEnd = pszDevName + cbDevName - 1;
    456456    if (fTrimDigits)
  • trunk/src/VBox/Main/src-server/linux/USBGetDevices.cpp

    r62343 r62363  
    376376         * Set the value.
    377377         */
    378         *pu16 = (uint16_t)u32Int << 8 | (uint16_t)u32Dec;
     378        *pu16 = (uint16_t)((u32Int << 8) | (uint16_t)u32Dec);
    379379    }
    380380    return VINF_SUCCESS;
     
    11791179
    11801180    /* usbfs compatibility, 0-based port number. */
    1181     *pu8Port -= 1;
     1181    *pu8Port = (uint8_t)(*pu8Port - 1);
    11821182    return VINF_SUCCESS;
    11831183}
     
    12841284    /* Fill in the simple fields */
    12851285    pDev->enmState           = USBDEVICESTATE_UNUSED;
    1286     pDev->bBus               = usbsysfsGetBusFromPath(pszSysfsPath);
     1286    pDev->bBus               = (uint8_t)usbsysfsGetBusFromPath(pszSysfsPath);
    12871287    pDev->bDeviceClass       = usbsysfsReadDevicePropertyU8Def(16, 0, "%s/bDeviceClass", pszSysfsPath);
    12881288    pDev->bDeviceSubClass    = usbsysfsReadDevicePropertyU8Def(16, 0, "%s/bDeviceSubClass", pszSysfsPath);
  • trunk/src/VBox/Main/src-server/linux/USBProxyBackendLinux.cpp

    r61423 r62363  
    321321
    322322    RT_ZERO(PollFds);
    323     PollFds[0].fd        = RTFileToNative(mhFile);
     323    PollFds[0].fd        = (int)RTFileToNative(mhFile);
    324324    PollFds[0].events    = POLLIN;
    325     PollFds[1].fd        = RTPipeToNative(mhWakeupPipeR);
     325    PollFds[1].fd        = (int)RTPipeToNative(mhWakeupPipeR);
    326326    PollFds[1].events    = POLLIN | POLLERR | POLLHUP;
    327327
  • trunk/src/VBox/Main/src-server/xpcom/server.cpp

    r62222 r62363  
    838838        {
    839839            char szBuf[80];
    840             int  iSize;
    841 
    842             iSize = RTStrPrintf(szBuf, sizeof(szBuf),
     840            size_t cSize;
     841
     842            cSize = RTStrPrintf(szBuf, sizeof(szBuf),
    843843                                VBOX_PRODUCT" XPCOM Server Version "
    844844                                VBOX_VERSION_STRING);
    845             for (int i = iSize; i > 0; i--)
     845            for (size_t i = cSize; i > 0; i--)
    846846                putchar('*');
    847847            RTPrintf("\n%s\n", szBuf);
  • trunk/src/VBox/Main/xml/Settings.cpp

    r62339 r62363  
    907907        (*pf)->getAttributeValue("hostip", rule.strHostIP);
    908908        (*pf)->getAttributeValue("hostport", port);
    909         rule.u16HostPort = port;
     909        rule.u16HostPort = (uint16_t)port;
    910910        (*pf)->getAttributeValue("guestip", rule.strGuestIP);
    911911        (*pf)->getAttributeValue("guestport", port);
    912         rule.u16GuestPort = port;
     912        rule.u16GuestPort = (uint16_t)port;
    913913        mapRules.insert(std::make_pair(rule.strName, rule));
    914914    }
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