VirtualBox

Changeset 47117 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jul 12, 2013 12:48:17 PM (11 years ago)
Author:
vboxsync
Message:

Main: RT_ZERO() / RTStrCopy()

Location:
trunk/src/VBox/Main
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/glue/initterm.cpp

    r46651 r47117  
    346346        return NS_ERROR_FILE_ACCESS_DENIED;
    347347    AssertRCReturn(vrc, NS_ERROR_FAILURE);
    348     strcpy(szXptiDat, szCompReg);
    349 
     348    vrc = RTStrCopy(szXptiDat, sizeof(szXptiDat), szCompReg);
     349    AssertRCReturn(vrc, NS_ERROR_FAILURE);
    350350    vrc = RTPathAppend(szCompReg, sizeof(szCompReg), "compreg.dat");
    351351    AssertRCReturn(vrc, NS_ERROR_FAILURE);
     
    397397        {
    398398            /* Iterate over all other paths */
    399             szAppHomeDir[RTPATH_MAX - 1] = '\0';
    400             strncpy(szAppHomeDir, kAppPathsToProbe[i], RTPATH_MAX - 1);
     399            RTStrCopy(szAppHomeDir, sizeof(szAppHomeDir), kAppPathsToProbe[i]);
    401400            vrc = VINF_SUCCESS;
    402401        }
     
    406405            continue;
    407406        }
    408 
    409407        char szCompDir[RTPATH_MAX];
    410         vrc = RTPathAppend(strcpy(szCompDir, szAppHomeDir), sizeof(szCompDir), "components");
     408        vrc = RTStrCopy(szCompDir, sizeof(szCompDir), szAppHomeDir);
     409        if (RT_FAILURE(vrc))
     410        {
     411            rc = NS_ERROR_FAILURE;
     412            continue;
     413        }
     414        vrc = RTPathAppend(szCompDir, sizeof(szCompDir), "components");
    411415        if (RT_FAILURE(vrc))
    412416        {
  • trunk/src/VBox/Main/include/netif.h

    r45367 r47117  
    129129        return VERR_INVALID_PARAMETER;
    130130
    131     memset(aAddrPtr, 0, sizeof(RTNETADDRIPV6));
     131    RT_ZERO(*aAddrPtr);
    132132
    133133    ASMBitSetRange(aAddrPtr, 0, cPrefix);
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r47106 r47117  
    405405    LogFlowThisFunc(("\n"));
    406406
    407     memset(mapStorageLeds, 0, sizeof(mapStorageLeds));
    408     memset(mapNetworkLeds, 0, sizeof(mapNetworkLeds));
    409     memset(&mapUSBLed, 0, sizeof(mapUSBLed));
    410     memset(&mapSharedFolderLed, 0, sizeof(mapSharedFolderLed));
     407    RT_ZERO(mapStorageLeds);
     408    RT_ZERO(mapNetworkLeds);
     409    RT_ZERO(mapUSBLed);
     410    RT_ZERO(mapSharedFolderLed);
    411411
    412412    for (unsigned i = 0; i < RT_ELEMENTS(maStorageDevType); ++i)
     
    82978297         */
    82988298        struct ifreq IfReq;
    8299         memset(&IfReq, 0, sizeof(IfReq));
     8299        RT_ZERO(IfReq);
    83008300        /* The name of the TAP interface we are using */
    83018301        Bstr tapDeviceName;
     
    83138313            /* If we are using a static TAP device then try to open it. */
    83148314            Utf8Str str(tapDeviceName);
    8315             if (str.length() <= sizeof(IfReq.ifr_name))
    8316                 strcpy(IfReq.ifr_name, str.c_str());
    8317             else
    8318                 memcpy(IfReq.ifr_name, str.c_str(), sizeof(IfReq.ifr_name) - 1); /** @todo bitch about names which are too long... */
     8315            RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), str.c_str()); /** @todo bitch about names which are too long... */
    83198316            IfReq.ifr_flags = IFF_TAP | IFF_NO_PI;
    83208317            rcVBox = ioctl(maTapFD[slot], TUNSETIFF, &IfReq);
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r47018 r47117  
    19151915            Assert(strlen(macStr) == 12);
    19161916            RTMAC Mac;
    1917             memset(&Mac, 0, sizeof(Mac));
     1917            RT_ZERO(Mac);
    19181918            char *pMac = (char*)&Mac;
    19191919            for (uint32_t i = 0; i < 6; ++i)
     
    43974397                        struct ifreq Req;
    43984398                        RT_ZERO(Req);
    4399                         strncpy(Req.ifr_name, pszBridgedIfName, sizeof(Req.ifr_name) - 1);
     4399                        RTStrCopy(Req.ifr_name, sizeof(Req.ifr_name), pszBridgedIfName);
    44004400                        if (ioctl(iSock, SIOCGIFFLAGS, &Req) >= 0)
    44014401                            if ((Req.ifr_flags & IFF_UP) == 0)
     
    44464446                    struct iwreq WRq;
    44474447
    4448                     memset(&WRq, 0, sizeof(WRq));
     4448                    RT_ZERO(WRq);
    44494449                    strncpy(WRq.ifr_name, pszBridgedIfName, IFNAMSIZ);
    44504450                    bool fSharedMacOnWire = ioctl(iSock, SIOCGIWNAME, &WRq) >= 0;
     
    44674467                    uint8_t abData[32];
    44684468
    4469                     memset(&WReq, 0, sizeof(WReq));
     4469                    RT_ZERO(WReq);
    44704470                    strncpy(WReq.i_name, pszBridgedIfName, sizeof(WReq.i_name));
    44714471                    WReq.i_type = IEEE80211_IOC_SSID;
  • trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp

    r47113 r47117  
    13511351    m_InputSynch.fClientScrollLock = false;
    13521352
    1353     memset(maFramebuffers, 0, sizeof(maFramebuffers));
     1353    RT_ZERO(maFramebuffers);
    13541354
    13551355    {
     
    13771377     */
    13781378    m_fInterfaceImage = false;
    1379     memset(&m_interfaceImage, 0, sizeof (m_interfaceImage));
    1380     memset(&m_interfaceCallbacksImage, 0, sizeof (m_interfaceCallbacksImage));
     1379    RT_ZERO(m_interfaceImage);
     1380    RT_ZERO(m_interfaceCallbacksImage);
    13811381    RT_ZERO(m_interfaceMousePtr);
    13821382    RT_ZERO(m_interfaceSCard);
     
    14161416    {
    14171417        RTCritSectDelete(&mCritSect);
    1418         memset(&mCritSect, 0, sizeof(mCritSect));
     1418        RT_ZERO(mCritSect);
    14191419    }
    14201420
     
    14221422    {
    14231423        RTCritSectDelete(&mTSMFLock);
    1424         memset(&mTSMFLock, 0, sizeof(mTSMFLock));
     1424        RT_ZERO(mTSMFLock);
    14251425    }
    14261426}
     
    25862586                pThis->tsmfUnlock();
    25872587
    2588                 memset(pVRDPCtx, 0, sizeof(*pVRDPCtx));
     2588                RT_ZERO(*pVRDPCtx);
    25892589                RTMemFree(pVRDPCtx);
    25902590            }
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r46828 r47117  
    149149    {
    150150        RTCritSectDelete (&mVBVALock);
    151         memset (&mVBVALock, 0, sizeof (mVBVALock));
     151        RT_ZERO(mVBVALock);
    152152    }
    153153
     
    155155    {
    156156        RTCritSectDelete(&mSaveSeamlessRectLock);
    157         memset(&mSaveSeamlessRectLock, 0, sizeof (mSaveSeamlessRectLock));
     157        RT_ZERO(mSaveSeamlessRectLock);
    158158    }
    159159    BaseFinalRelease();
     
    489489        maFramebuffers[ul].mpSavedVisibleRegion = NULL;
    490490
    491         memset (&maFramebuffers[ul].dirtyRect, 0 , sizeof (maFramebuffers[ul].dirtyRect));
    492         memset (&maFramebuffers[ul].pendingResize, 0 , sizeof (maFramebuffers[ul].pendingResize));
     491        RT_ZERO(maFramebuffers[ul].dirtyRect);
     492        RT_ZERO(maFramebuffers[ul].pendingResize);
    493493#ifdef VBOX_WITH_HGSMI
    494494        maFramebuffers[ul].fVBVAEnabled = false;
    495495        maFramebuffers[ul].cVBVASkipUpdate = 0;
    496         memset (&maFramebuffers[ul].vbvaSkippedRect, 0, sizeof (maFramebuffers[ul].vbvaSkippedRect));
     496        RT_ZERO(maFramebuffers[ul].vbvaSkippedRect);
    497497        maFramebuffers[ul].pVBVAHostFlags = NULL;
    498498#endif /* VBOX_WITH_HGSMI */
     
    12441244        DISPLAYFBINFO *pFBInfo = &prgn->paFramebuffers[uScreenId];
    12451245
    1246         memset (&pFBInfo->dirtyRect, 0, sizeof (pFBInfo->dirtyRect));
     1246        RT_ZERO(pFBInfo->dirtyRect);
    12471247    }
    12481248}
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r44528 r47117  
    243243    m_hExtension (NULL)
    244244{
    245     memset (&m_fntable, 0, sizeof (m_fntable));
     245    RT_ZERO(m_fntable);
    246246}
    247247
     
    290290        if (RT_SUCCESS(rc))
    291291        {
    292             memset (&m_fntable, 0, sizeof (m_fntable));
     292            RT_ZERO(m_fntable);
    293293
    294294            m_fntable.cbSize     = sizeof (m_fntable);
     
    346346    }
    347347
    348     memset (&m_fntable, 0, sizeof (m_fntable));
     348    RT_ZERO(m_fntable);
    349349    m_pfnLoad = NULL;
    350350    m_hLdrMod = NIL_RTLDRMOD;
  • trunk/src/VBox/Main/src-client/HGCMThread.cpp

    r44528 r47117  
    221221    m_handle (0)
    222222{
    223     memset (&m_critsect, 0, sizeof (m_critsect));
     223    RT_ZERO(m_critsect);
    224224}
    225225
     
    307307            {
    308308                Log(("hgcmThreadCreate: FAILURE: Can't init a critical section for a hgcm worker thread.\n"));
    309                 memset (&m_critsect, 0, sizeof (m_critsect));
     309                RT_ZERO(m_critsect);
    310310            }
    311311        }
  • trunk/src/VBox/Main/src-client/RemoteUSBBackend.cpp

    r44528 r47117  
    962962    {
    963963        AssertFailed ();
    964         memset (&mCritsect, 0, sizeof (mCritsect));
     964        RT_ZERO(mCritsect);
    965965    }
    966966
  • trunk/src/VBox/Main/src-server/HostImpl.cpp

    r47114 r47117  
    253253
    254254    RT_ZERO(g_aszResolvConf);
    255     RTStrmPrintf(g_aszResolvConf, MAX_PATH, "%/RESOLV2", _PATH_ETC);
     255    RTStrmPrintf(g_aszResolvConf, sizeof(g_aszResolvConf), "%/RESOLV2", _PATH_ETC);
    256256# else
    257     strcpy(g_aszResolvConf, "/etc/resolv.conf");
     257    RTStrCopy(g_aszResolvConf, sizeof(g_aszResolvConf), "/etc/resolv.conf");
    258258# endif   
    259259    return g_aszResolvConf;
  • trunk/src/VBox/Main/src-server/darwin/NetIf-darwin.cpp

    r44742 r47117  
    8686
    8787        struct ifreq IfReq;
    88         strcpy(IfReq.ifr_name, pNew->szShortName);
     88        RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), pNew->szShortName);
    8989        if (ioctl(sock, SIOCGIFFLAGS, &IfReq) < 0)
    9090        {
     
    392392        {
    393393            struct ifreq IfReq;
    394             strcpy(IfReq.ifr_name, pNew->szShortName);
     394            RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), pNew->szShortName);
    395395            if (ioctl(sock, SIOCGIFFLAGS, &IfReq) < 0)
    396396            {
     
    512512
    513513            struct ifreq IfReq;
    514             strcpy(IfReq.ifr_name, pInfo->szShortName);
     514            RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), pInfo->szShortName);
    515515            if (ioctl(sock, SIOCGIFFLAGS, &IfReq) < 0)
    516516            {
  • trunk/src/VBox/Main/src-server/darwin/iokit.cpp

    r44528 r47117  
    374374            CFIndex iCF;
    375375        } u;
    376         memset(&u, 0, sizeof(u));
     376        RT_ZERO(u);
    377377        CFNumberType NumType = CFNumberGetType((CFNumberRef)pvValue);
    378378        if (CFNumberGetValue((CFNumberRef)pvValue, NumType, &u))
  • trunk/src/VBox/Main/src-server/freebsd/HostHardwareFreeBSD.cpp

    r44529 r47117  
    173173        struct dev_match_result *paMatches = NULL;
    174174
    175         memset(&DeviceCCB, 0, sizeof(union ccb));
    176         memset(&DeviceMatchPattern, 0, sizeof(struct device_match_pattern));
     175        RT_ZERO(DeviceCCB);
     176        RT_ZERO(DeviceMatchPattern);
    177177
    178178        /* We want to get all devices. */
     
    237237                        unsigned iPeriphMatch = 0;
    238238
    239                         memset(&PeriphCCB, 0, sizeof(union ccb));
    240                         memset(&PeriphMatchPattern, 0, sizeof(struct dev_match_pattern));
    241                         memset(aPeriphMatches, 0, sizeof(aPeriphMatches));
     239                        RT_ZERO(PeriphCCB);
     240                        RT_ZERO(PeriphMatchPattern);
     241                        RT_ZERO(aPeriphMatches);
    242242
    243243                        /* This time we only want the specific nodes for the device. */
  • trunk/src/VBox/Main/src-server/freebsd/NetIf-freebsd.cpp

    r44742 r47117  
    272272        {
    273273            struct ifreq IfReq;
    274             strcpy(IfReq.ifr_name, pNew->szShortName);
     274            RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), pNew->szShortName);
    275275            if (ioctl(sock, SIOCGIFFLAGS, &IfReq) < 0)
    276276            {
     
    389389
    390390            struct ifreq IfReq;
    391             strcpy(IfReq.ifr_name, pInfo->szShortName);
     391            RTSTrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), pInfo->szShortName);
    392392            if (ioctl(sock, SIOCGIFFLAGS, &IfReq) < 0)
    393393            {
  • trunk/src/VBox/Main/src-server/freebsd/USBProxyServiceFreeBSD.cpp

    r41528 r47117  
    267267
    268268        struct usb_device_info UsbDevInfo;
    269         memset(&UsbDevInfo, 0, sizeof(struct usb_device_info));
     269        RT_ZERO(UsbDevInfo);
    270270
    271271        rc = ioctl(FileUsb, USB_GET_DEVICEINFO, &UsbDevInfo);
  • trunk/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp

    r44528 r47117  
    7979                    uint32_t cAutostartVms = 0;
    8080
    81                     memset(abBuf, 0, sizeof(abBuf));
     81                    RT_ZERO(abBuf);
    8282
    8383                    /* Check if the file was just created. */
  • trunk/src/VBox/Main/src-server/generic/NetIf-generic.cpp

    r46345 r47117  
    381381        return VERR_OUT_OF_RESOURCES;
    382382    struct ifreq Req;
    383     memset(&Req, 0, sizeof(Req));
    384     strncpy(Req.ifr_name, pcszIfName, sizeof(Req.ifr_name) - 1);
     383    RT_ZERO(Req);
     384    RTStrCopy(Req.ifr_name, sizeof(Req.ifr_name), pcszIfName);
    385385    if (ioctl(sock, SIOCGIFFLAGS, &Req) < 0)
    386386    {
  • trunk/src/VBox/Main/src-server/linux/NetIf-linux.cpp

    r46345 r47117  
    119119    // memset(pInfo, 0, sizeof(*pInfo));
    120120    struct ifreq Req;
    121     memset(&Req, 0, sizeof(Req));
    122     strncpy(Req.ifr_name, pszName, sizeof(Req.ifr_name) - 1);
     121    RT_ZERO(Req);
     122    RTStrCopy(Req.ifr_name, sizeof(Req.ifr_name), pszName);
    123123    if (ioctl(iSocket, SIOCGIFHWADDR, &Req) >= 0)
    124124    {
     
    164164            for (;;)
    165165            {
    166                 memset(szName, 0, sizeof(szName));
     166                RT_ZERO(szName);
    167167                int n = fscanf(fp,
    168168                               "%08x%08x%08x%08x"
     
    288288        return VERR_OUT_OF_RESOURCES;
    289289    struct ifreq Req;
    290     memset(&Req, 0, sizeof(Req));
    291     strncpy(Req.ifr_name, pcszIfName, sizeof(Req.ifr_name) - 1);
     290    RT_ZERO(Req);
     291    RTStrCopy(Req.ifr_name, sizeof(Req.ifr_name), pcszIfName);
    292292    if (ioctl(sock, SIOCGIFHWADDR, &Req) >= 0)
    293293    {
  • trunk/src/VBox/Main/src-server/linux/USBGetDevices.cpp

    r46326 r47117  
    594594
    595595                    /* Reset device state */
    596                     memset(&Dev, 0, sizeof (Dev));
     596                    RT_ZERO(Dev);
    597597                    Dev.enmState = USBDEVICESTATE_UNUSED;
    598598                    cHits = 1;
  • trunk/src/VBox/Main/src-server/linux/USBProxyServiceLinux.cpp

    r41528 r47117  
    321321    }
    322322
    323     memset(&PollFds, 0, sizeof(PollFds));
     323    RT_ZERO(PollFds);
    324324    PollFds[0].fd        = RTFileToNative(mhFile);
    325325    PollFds[0].events    = POLLIN;
  • trunk/src/VBox/Main/src-server/solaris/NetIf-solaris.cpp

    r47001 r47117  
    205205    {
    206206        struct lifreq IfReq;
    207         strcpy(IfReq.lifr_name, szNICInstance);
     207        RTStrCopy(IfReq.lifr_name, sizeof(IfReq.lifr_name), szNICInstance);
    208208        if (ioctl(Sock, SIOCGLIFADDR, &IfReq) >= 0)
    209209        {
     
    244244    {
    245245        struct lifreq IfReq;
    246         strcpy(IfReq.lifr_name, szNICInstance);
     246        RTStrCopy(IfReq.lifr_name, sizeof(IfReq.lifr_name), szNICInstance);
    247247        if (ioctl(Sock, SIOCGLIFADDR, &IfReq) >= 0)
    248248        {
  • trunk/src/VBox/Main/src-server/win/NetIf-win.cpp

    r45367 r47117  
    955955        {
    956956            NETIFINFO Info;
    957             memset(&Info, 0, sizeof(Info));
     957            RT_ZERO(Info);
    958958            Info.Uuid = *(Guid(IfGuid).raw());
    959959            rc = collectNetIfInfo(name, Guid(IfGuid), &Info, iDefaultInterface);
  • trunk/src/VBox/Main/src-server/xpcom/server_module.cpp

    r37666 r47117  
    5454#include <iprt/process.h>
    5555#include <iprt/env.h>
     56#include <iprt/string.h>
    5657#include <iprt/thread.h>
    57 
    58 #include <string.h>
    5958
    6059#if defined(RT_OS_SOLARIS)
     
    138137
    139138    char msg[10];
    140     memset(msg, '\0', sizeof(msg));
     139    RT_ZERO(msg);
    141140    if (   PR_Read(readable, msg, sizeof(msg)-1) != 5
    142141        || strcmp(msg, "READY"))
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