VirtualBox

Changeset 48840 in vbox


Ignore:
Timestamp:
Oct 3, 2013 1:56:56 PM (11 years ago)
Author:
vboxsync
Message:

DMG.cpp: All callback method implementation shall be using DECLCALLBACK! Eliminated a few really stupid goto that would've made Dijkstra cry.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/DMG.cpp

    r48839 r48840  
    14901490
    14911491/** @interface_method_impl{VBOXHDDBACKEND,pfnCheckIfValid} */
    1492 static int dmgCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
    1493                            PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
     1492static DECLCALLBACK(int) dmgCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
     1493                                         PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
    14941494{
    14951495    LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n",
     
    15531553
    15541554/** @interface_method_impl{VBOXHDDBACKEND,pfnOpen} */
    1555 static int dmgOpen(const char *pszFilename, unsigned uOpenFlags,
    1556                    PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
    1557                    VDTYPE enmType, void **ppBackendData)
     1555static DECLCALLBACK(int) dmgOpen(const char *pszFilename, unsigned uOpenFlags,
     1556                                 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
     1557                                 VDTYPE enmType, void **ppBackendData)
    15581558{
    15591559    LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
     
    16181618
    16191619/** @interface_method_impl{VBOXHDDBACKEND,pfnCreate} */
    1620 static int dmgCreate(const char *pszFilename, uint64_t cbSize,
    1621                      unsigned uImageFlags, const char *pszComment,
    1622                      PCVDGEOMETRY pPCHSGeometry, PCVDGEOMETRY pLCHSGeometry,
    1623                      PCRTUUID pUuid, unsigned uOpenFlags,
    1624                      unsigned uPercentStart, unsigned uPercentSpan,
    1625                      PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
    1626                      PVDINTERFACE pVDIfsOperation, void **ppBackendData)
     1620static DECLCALLBACK(int) dmgCreate(const char *pszFilename, uint64_t cbSize,
     1621                                   unsigned uImageFlags, const char *pszComment,
     1622                                   PCVDGEOMETRY pPCHSGeometry, PCVDGEOMETRY pLCHSGeometry,
     1623                                   PCRTUUID pUuid, unsigned uOpenFlags,
     1624                                   unsigned uPercentStart, unsigned uPercentSpan,
     1625                                   PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
     1626                                   PVDINTERFACE pVDIfsOperation, void **ppBackendData)
    16271627{
    16281628    LogFlowFunc(("pszFilename=\"%s\" cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x uPercentStart=%u uPercentSpan=%u pVDIfsDisk=%#p pVDIfsImage=%#p pVDIfsOperation=%#p ppBackendData=%#p", pszFilename, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, uPercentStart, uPercentSpan, pVDIfsDisk, pVDIfsImage, pVDIfsOperation, ppBackendData));
     
    16441644
    16451645/** @interface_method_impl{VBOXHDDBACKEND,pfnClose} */
    1646 static int dmgClose(void *pBackendData, bool fDelete)
     1646static DECLCALLBACK(int) dmgClose(void *pBackendData, bool fDelete)
    16471647{
    16481648    LogFlowFunc(("pBackendData=%#p fDelete=%d\n", pBackendData, fDelete));
    16491649    PDMGIMAGE pThis = (PDMGIMAGE)pBackendData;
    1650     int rc;
    1651 
    1652     rc = dmgFreeImage(pThis, fDelete);
     1650
     1651    int rc = dmgFreeImage(pThis, fDelete);
    16531652    RTMemFree(pThis);
    16541653
     
    16581657
    16591658/** @interface_method_impl{VBOXHDDBACKEND,pfnRead} */
    1660 static int dmgRead(void *pBackendData, uint64_t uOffset,  size_t cbToRead,
    1661                    PVDIOCTX pIoCtx, size_t *pcbActuallyRead)
     1659static DECLCALLBACK(int) dmgRead(void *pBackendData, uint64_t uOffset,  size_t cbToRead,
     1660                                 PVDIOCTX pIoCtx, size_t *pcbActuallyRead)
    16621661{
    16631662    LogFlowFunc(("pBackendData=%#p uOffset=%llu pIoCtx=%#p cbToRead=%zu pcbActuallyRead=%#p\n",
     
    16741673        || cbToRead == 0)
    16751674    {
    1676         rc = VERR_INVALID_PARAMETER;
    1677         goto out;
     1675        LogFlowFunc(("returns VERR_INVALID_PARAMETER\n"));
     1676        return VERR_INVALID_PARAMETER;
    16781677    }
    16791678
     
    17431742        rc = VERR_INVALID_PARAMETER;
    17441743
    1745 out:
    17461744    LogFlowFunc(("returns %Rrc\n", rc));
    17471745    return rc;
     
    17491747
    17501748/** @interface_method_impl{VBOXHDDBACKEND,pfnWrite} */
    1751 static int dmgWrite(void *pBackendData, uint64_t uOffset, size_t cbToWrite,
    1752                     PVDIOCTX pIoCtx, size_t *pcbWriteProcess, size_t *pcbPreRead,
    1753                     size_t *pcbPostRead, unsigned fWrite)
     1749static DECLCALLBACK(int) dmgWrite(void *pBackendData, uint64_t uOffset, size_t cbToWrite,
     1750                                  PVDIOCTX pIoCtx, size_t *pcbWriteProcess, size_t *pcbPreRead,
     1751                                  size_t *pcbPostRead, unsigned fWrite)
    17541752{
    17551753    LogFlowFunc(("pBackendData=%#p uOffset=%llu pIoCtx=%#p cbToWrite=%zu pcbWriteProcess=%#p pcbPreRead=%#p pcbPostRead=%#p\n",
     
    17621760    Assert(cbToWrite % 512 == 0);
    17631761
    1764     if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)
    1765     {
     1762    if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     1763        AssertMsgFailed(("Not implemented\n"));
     1764    else
    17661765        rc = VERR_VD_IMAGE_READ_ONLY;
    1767         goto out;
    1768     }
    1769 
    1770     AssertMsgFailed(("Not implemented\n"));
    1771 
    1772 out:
     1766
    17731767    LogFlowFunc(("returns %Rrc\n", rc));
    17741768    return rc;
     
    17761770
    17771771/** @interface_method_impl{VBOXHDDBACKEND,pfnFlush} */
    1778 static int dmgFlush(void *pBackendData, PVDIOCTX pIoCtx)
     1772static DECLCALLBACK(int) dmgFlush(void *pBackendData, PVDIOCTX pIoCtx)
    17791773{
    17801774    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     
    17911785
    17921786/** @interface_method_impl{VBOXHDDBACKEND,pfnGetVersion} */
    1793 static unsigned dmgGetVersion(void *pBackendData)
     1787static DECLCALLBACK(unsigned) dmgGetVersion(void *pBackendData)
    17941788{
    17951789    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     
    18051799
    18061800/** @interface_method_impl{VBOXHDDBACKEND,pfnGetSectorSize} */
    1807 static uint32_t dmgGetSectorSize(void *pBackendData)
     1801static DECLCALLBACK(uint32_t) dmgGetSectorSize(void *pBackendData)
    18081802{
    18091803    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     
    18211815
    18221816/** @interface_method_impl{VBOXHDDBACKEND,pfnGetSize} */
    1823 static uint64_t dmgGetSize(void *pBackendData)
     1817static DECLCALLBACK(uint64_t) dmgGetSize(void *pBackendData)
    18241818{
    18251819    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     
    18371831
    18381832/** @interface_method_impl{VBOXHDDBACKEND,pfnGetFileSize} */
    1839 static uint64_t dmgGetFileSize(void *pBackendData)
     1833static DECLCALLBACK(uint64_t) dmgGetFileSize(void *pBackendData)
    18401834{
    18411835    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     
    18611855
    18621856/** @interface_method_impl{VBOXHDDBACKEND,pfnGetPCHSGeometry} */
    1863 static int dmgGetPCHSGeometry(void *pBackendData, PVDGEOMETRY pPCHSGeometry)
     1857static DECLCALLBACK(int) dmgGetPCHSGeometry(void *pBackendData, PVDGEOMETRY pPCHSGeometry)
    18641858{
    18651859    LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p\n", pBackendData, pPCHSGeometry));
     
    18871881
    18881882/** @interface_method_impl{VBOXHDDBACKEND,pfnSetPCHSGeometry} */
    1889 static int dmgSetPCHSGeometry(void *pBackendData, PCVDGEOMETRY pPCHSGeometry)
     1883static DECLCALLBACK(int) dmgSetPCHSGeometry(void *pBackendData, PCVDGEOMETRY pPCHSGeometry)
    18901884{
    18911885    LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p PCHS=%u/%u/%u\n",
     
    18981892    if (pThis)
    18991893    {
    1900         if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)
    1901         {
     1894        if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     1895        {
     1896            pThis->PCHSGeometry = *pPCHSGeometry;
     1897            rc = VINF_SUCCESS;
     1898        }
     1899        else
    19021900            rc = VERR_VD_IMAGE_READ_ONLY;
    1903             goto out;
    1904         }
    1905 
    1906         pThis->PCHSGeometry = *pPCHSGeometry;
    1907         rc = VINF_SUCCESS;
    19081901    }
    19091902    else
    19101903        rc = VERR_VD_NOT_OPENED;
    19111904
    1912 out:
    19131905    LogFlowFunc(("returns %Rrc\n", rc));
    19141906    return rc;
     
    19161908
    19171909/** @interface_method_impl{VBOXHDDBACKEND,pfnGetLCHSGeometry} */
    1918 static int dmgGetLCHSGeometry(void *pBackendData, PVDGEOMETRY pLCHSGeometry)
     1910static DECLCALLBACK(int) dmgGetLCHSGeometry(void *pBackendData, PVDGEOMETRY pLCHSGeometry)
    19191911{
    19201912     LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p\n", pBackendData, pLCHSGeometry));
     
    19421934
    19431935/** @interface_method_impl{VBOXHDDBACKEND,pfnSetLCHSGeometry} */
    1944 static int dmgSetLCHSGeometry(void *pBackendData, PCVDGEOMETRY pLCHSGeometry)
     1936static DECLCALLBACK(int) dmgSetLCHSGeometry(void *pBackendData, PCVDGEOMETRY pLCHSGeometry)
    19451937{
    19461938    LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p LCHS=%u/%u/%u\n",
     
    19531945    if (pThis)
    19541946    {
    1955         if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)
    1956         {
     1947        if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY))
     1948        {
     1949            pThis->LCHSGeometry = *pLCHSGeometry;
     1950            rc = VINF_SUCCESS;
     1951        }
     1952        else
    19571953            rc = VERR_VD_IMAGE_READ_ONLY;
    1958             goto out;
    1959         }
    1960 
    1961         pThis->LCHSGeometry = *pLCHSGeometry;
    1962         rc = VINF_SUCCESS;
    19631954    }
    19641955    else
    19651956        rc = VERR_VD_NOT_OPENED;
    19661957
    1967 out:
    19681958    LogFlowFunc(("returns %Rrc\n", rc));
    19691959    return rc;
     
    19711961
    19721962/** @interface_method_impl{VBOXHDDBACKEND,pfnGetImageFlags} */
    1973 static unsigned dmgGetImageFlags(void *pBackendData)
     1963static DECLCALLBACK(unsigned) dmgGetImageFlags(void *pBackendData)
    19741964{
    19751965    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     
    19891979
    19901980/** @interface_method_impl{VBOXHDDBACKEND,pfnGetOpenFlags} */
    1991 static unsigned dmgGetOpenFlags(void *pBackendData)
     1981static DECLCALLBACK(unsigned) dmgGetOpenFlags(void *pBackendData)
    19921982{
    19931983    LogFlowFunc(("pBackendData=%#p\n", pBackendData));
     
    20071997
    20081998/** @interface_method_impl{VBOXHDDBACKEND,pfnSetOpenFlags} */
    2009 static int dmgSetOpenFlags(void *pBackendData, unsigned uOpenFlags)
     1999static DECLCALLBACK(int) dmgSetOpenFlags(void *pBackendData, unsigned uOpenFlags)
    20102000{
    20112001    LogFlowFunc(("pBackendData=%#p\n uOpenFlags=%#x", pBackendData, uOpenFlags));
     
    20342024
    20352025/** @interface_method_impl{VBOXHDDBACKEND,pfnGetComment} */
    2036 static int dmgGetComment(void *pBackendData, char *pszComment,
    2037                          size_t cbComment)
     2026static DECLCALLBACK(int) dmgGetComment(void *pBackendData, char *pszComment, size_t cbComment)
    20382027{
    20392028    LogFlowFunc(("pBackendData=%#p pszComment=%#p cbComment=%zu\n", pBackendData, pszComment, cbComment));
     
    20532042
    20542043/** @interface_method_impl{VBOXHDDBACKEND,pfnSetComment} */
    2055 static int dmgSetComment(void *pBackendData, const char *pszComment)
     2044static DECLCALLBACK(int) dmgSetComment(void *pBackendData, const char *pszComment)
    20562045{
    20572046    LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment));
     
    20762065
    20772066/** @interface_method_impl{VBOXHDDBACKEND,pfnGetUuid} */
    2078 static int dmgGetUuid(void *pBackendData, PRTUUID pUuid)
     2067static DECLCALLBACK(int) dmgGetUuid(void *pBackendData, PRTUUID pUuid)
    20792068{
    20802069    LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
     
    20942083
    20952084/** @interface_method_impl{VBOXHDDBACKEND,pfnSetUuid} */
    2096 static int dmgSetUuid(void *pBackendData, PCRTUUID pUuid)
     2085static DECLCALLBACK(int) dmgSetUuid(void *pBackendData, PCRTUUID pUuid)
    20972086{
    20982087    LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
     
    21182107
    21192108/** @interface_method_impl{VBOXHDDBACKEND,pfnGetModificationUuid} */
    2120 static int dmgGetModificationUuid(void *pBackendData, PRTUUID pUuid)
     2109static DECLCALLBACK(int) dmgGetModificationUuid(void *pBackendData, PRTUUID pUuid)
    21212110{
    21222111    LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
     
    21362125
    21372126/** @interface_method_impl{VBOXHDDBACKEND,pfnSetModificationUuid} */
    2138 static int dmgSetModificationUuid(void *pBackendData, PCRTUUID pUuid)
     2127static DECLCALLBACK(int) dmgSetModificationUuid(void *pBackendData, PCRTUUID pUuid)
    21392128{
    21402129    LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
     
    21592148
    21602149/** @interface_method_impl{VBOXHDDBACKEND,pfnGetParentUuid} */
    2161 static int dmgGetParentUuid(void *pBackendData, PRTUUID pUuid)
     2150static DECLCALLBACK(int) dmgGetParentUuid(void *pBackendData, PRTUUID pUuid)
    21622151{
    21632152    LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
     
    21772166
    21782167/** @interface_method_impl{VBOXHDDBACKEND,pfnSetParentUuid} */
    2179 static int dmgSetParentUuid(void *pBackendData, PCRTUUID pUuid)
     2168static DECLCALLBACK(int) dmgSetParentUuid(void *pBackendData, PCRTUUID pUuid)
    21802169{
    21812170    LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
     
    22002189
    22012190/** @interface_method_impl{VBOXHDDBACKEND,pfnGetParentModificationUuid} */
    2202 static int dmgGetParentModificationUuid(void *pBackendData, PRTUUID pUuid)
     2191static DECLCALLBACK(int) dmgGetParentModificationUuid(void *pBackendData, PRTUUID pUuid)
    22032192{
    22042193    LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
     
    22182207
    22192208/** @interface_method_impl{VBOXHDDBACKEND,pfnSetParentModificationUuid} */
    2220 static int dmgSetParentModificationUuid(void *pBackendData, PCRTUUID pUuid)
     2209static DECLCALLBACK(int) dmgSetParentModificationUuid(void *pBackendData, PCRTUUID pUuid)
    22212210{
    22222211    LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
     
    22412230
    22422231/** @interface_method_impl{VBOXHDDBACKEND,pfnDump} */
    2243 static void dmgDump(void *pBackendData)
     2232static DECLCALLBACK(void) dmgDump(void *pBackendData)
    22442233{
    22452234    PDMGIMAGE pThis = (PDMGIMAGE)pBackendData;
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