Index: /trunk/src/VBox/Storage/DMG.cpp
===================================================================
--- /trunk/src/VBox/Storage/DMG.cpp	(revision 48839)
+++ /trunk/src/VBox/Storage/DMG.cpp	(revision 48840)
@@ -1490,6 +1490,6 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnCheckIfValid} */
-static int dmgCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                           PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
+static DECLCALLBACK(int) dmgCheckIfValid(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
+                                         PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
 {
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n",
@@ -1553,7 +1553,7 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnOpen} */
-static int dmgOpen(const char *pszFilename, unsigned uOpenFlags,
-                   PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                   VDTYPE enmType, void **ppBackendData)
+static DECLCALLBACK(int) dmgOpen(const char *pszFilename, unsigned uOpenFlags,
+                                 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
+                                 VDTYPE enmType, void **ppBackendData)
 {
     LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData));
@@ -1618,11 +1618,11 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnCreate} */
-static int dmgCreate(const char *pszFilename, uint64_t cbSize,
-                     unsigned uImageFlags, const char *pszComment,
-                     PCVDGEOMETRY pPCHSGeometry, PCVDGEOMETRY pLCHSGeometry,
-                     PCRTUUID pUuid, unsigned uOpenFlags,
-                     unsigned uPercentStart, unsigned uPercentSpan,
-                     PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                     PVDINTERFACE pVDIfsOperation, void **ppBackendData)
+static DECLCALLBACK(int) dmgCreate(const char *pszFilename, uint64_t cbSize,
+                                   unsigned uImageFlags, const char *pszComment,
+                                   PCVDGEOMETRY pPCHSGeometry, PCVDGEOMETRY pLCHSGeometry,
+                                   PCRTUUID pUuid, unsigned uOpenFlags,
+                                   unsigned uPercentStart, unsigned uPercentSpan,
+                                   PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
+                                   PVDINTERFACE pVDIfsOperation, void **ppBackendData)
 {
     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));
@@ -1644,11 +1644,10 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnClose} */
-static int dmgClose(void *pBackendData, bool fDelete)
+static DECLCALLBACK(int) dmgClose(void *pBackendData, bool fDelete)
 {
     LogFlowFunc(("pBackendData=%#p fDelete=%d\n", pBackendData, fDelete));
     PDMGIMAGE pThis = (PDMGIMAGE)pBackendData;
-    int rc;
-
-    rc = dmgFreeImage(pThis, fDelete);
+
+    int rc = dmgFreeImage(pThis, fDelete);
     RTMemFree(pThis);
 
@@ -1658,6 +1657,6 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnRead} */
-static int dmgRead(void *pBackendData, uint64_t uOffset,  size_t cbToRead,
-                   PVDIOCTX pIoCtx, size_t *pcbActuallyRead)
+static DECLCALLBACK(int) dmgRead(void *pBackendData, uint64_t uOffset,  size_t cbToRead,
+                                 PVDIOCTX pIoCtx, size_t *pcbActuallyRead)
 {
     LogFlowFunc(("pBackendData=%#p uOffset=%llu pIoCtx=%#p cbToRead=%zu pcbActuallyRead=%#p\n",
@@ -1674,6 +1673,6 @@
         || cbToRead == 0)
     {
-        rc = VERR_INVALID_PARAMETER;
-        goto out;
+        LogFlowFunc(("returns VERR_INVALID_PARAMETER\n"));
+        return VERR_INVALID_PARAMETER;
     }
 
@@ -1743,5 +1742,4 @@
         rc = VERR_INVALID_PARAMETER;
 
-out:
     LogFlowFunc(("returns %Rrc\n", rc));
     return rc;
@@ -1749,7 +1747,7 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnWrite} */
-static int dmgWrite(void *pBackendData, uint64_t uOffset, size_t cbToWrite,
-                    PVDIOCTX pIoCtx, size_t *pcbWriteProcess, size_t *pcbPreRead,
-                    size_t *pcbPostRead, unsigned fWrite)
+static DECLCALLBACK(int) dmgWrite(void *pBackendData, uint64_t uOffset, size_t cbToWrite,
+                                  PVDIOCTX pIoCtx, size_t *pcbWriteProcess, size_t *pcbPreRead,
+                                  size_t *pcbPostRead, unsigned fWrite)
 {
     LogFlowFunc(("pBackendData=%#p uOffset=%llu pIoCtx=%#p cbToWrite=%zu pcbWriteProcess=%#p pcbPreRead=%#p pcbPostRead=%#p\n",
@@ -1762,13 +1760,9 @@
     Assert(cbToWrite % 512 == 0);
 
-    if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-    {
+    if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY))
+        AssertMsgFailed(("Not implemented\n"));
+    else
         rc = VERR_VD_IMAGE_READ_ONLY;
-        goto out;
-    }
-
-    AssertMsgFailed(("Not implemented\n"));
-
-out:
+
     LogFlowFunc(("returns %Rrc\n", rc));
     return rc;
@@ -1776,5 +1770,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnFlush} */
-static int dmgFlush(void *pBackendData, PVDIOCTX pIoCtx)
+static DECLCALLBACK(int) dmgFlush(void *pBackendData, PVDIOCTX pIoCtx)
 {
     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
@@ -1791,5 +1785,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetVersion} */
-static unsigned dmgGetVersion(void *pBackendData)
+static DECLCALLBACK(unsigned) dmgGetVersion(void *pBackendData)
 {
     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
@@ -1805,5 +1799,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetSectorSize} */
-static uint32_t dmgGetSectorSize(void *pBackendData)
+static DECLCALLBACK(uint32_t) dmgGetSectorSize(void *pBackendData)
 {
     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
@@ -1821,5 +1815,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetSize} */
-static uint64_t dmgGetSize(void *pBackendData)
+static DECLCALLBACK(uint64_t) dmgGetSize(void *pBackendData)
 {
     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
@@ -1837,5 +1831,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetFileSize} */
-static uint64_t dmgGetFileSize(void *pBackendData)
+static DECLCALLBACK(uint64_t) dmgGetFileSize(void *pBackendData)
 {
     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
@@ -1861,5 +1855,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetPCHSGeometry} */
-static int dmgGetPCHSGeometry(void *pBackendData, PVDGEOMETRY pPCHSGeometry)
+static DECLCALLBACK(int) dmgGetPCHSGeometry(void *pBackendData, PVDGEOMETRY pPCHSGeometry)
 {
     LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p\n", pBackendData, pPCHSGeometry));
@@ -1887,5 +1881,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnSetPCHSGeometry} */
-static int dmgSetPCHSGeometry(void *pBackendData, PCVDGEOMETRY pPCHSGeometry)
+static DECLCALLBACK(int) dmgSetPCHSGeometry(void *pBackendData, PCVDGEOMETRY pPCHSGeometry)
 {
     LogFlowFunc(("pBackendData=%#p pPCHSGeometry=%#p PCHS=%u/%u/%u\n",
@@ -1898,17 +1892,15 @@
     if (pThis)
     {
-        if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-        {
+        if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY))
+        {
+            pThis->PCHSGeometry = *pPCHSGeometry;
+            rc = VINF_SUCCESS;
+        }
+        else
             rc = VERR_VD_IMAGE_READ_ONLY;
-            goto out;
-        }
-
-        pThis->PCHSGeometry = *pPCHSGeometry;
-        rc = VINF_SUCCESS;
     }
     else
         rc = VERR_VD_NOT_OPENED;
 
-out:
     LogFlowFunc(("returns %Rrc\n", rc));
     return rc;
@@ -1916,5 +1908,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetLCHSGeometry} */
-static int dmgGetLCHSGeometry(void *pBackendData, PVDGEOMETRY pLCHSGeometry)
+static DECLCALLBACK(int) dmgGetLCHSGeometry(void *pBackendData, PVDGEOMETRY pLCHSGeometry)
 {
      LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p\n", pBackendData, pLCHSGeometry));
@@ -1942,5 +1934,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnSetLCHSGeometry} */
-static int dmgSetLCHSGeometry(void *pBackendData, PCVDGEOMETRY pLCHSGeometry)
+static DECLCALLBACK(int) dmgSetLCHSGeometry(void *pBackendData, PCVDGEOMETRY pLCHSGeometry)
 {
     LogFlowFunc(("pBackendData=%#p pLCHSGeometry=%#p LCHS=%u/%u/%u\n",
@@ -1953,17 +1945,15 @@
     if (pThis)
     {
-        if (pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY)
-        {
+        if (!(pThis->uOpenFlags & VD_OPEN_FLAGS_READONLY))
+        {
+            pThis->LCHSGeometry = *pLCHSGeometry;
+            rc = VINF_SUCCESS;
+        }
+        else
             rc = VERR_VD_IMAGE_READ_ONLY;
-            goto out;
-        }
-
-        pThis->LCHSGeometry = *pLCHSGeometry;
-        rc = VINF_SUCCESS;
     }
     else
         rc = VERR_VD_NOT_OPENED;
 
-out:
     LogFlowFunc(("returns %Rrc\n", rc));
     return rc;
@@ -1971,5 +1961,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetImageFlags} */
-static unsigned dmgGetImageFlags(void *pBackendData)
+static DECLCALLBACK(unsigned) dmgGetImageFlags(void *pBackendData)
 {
     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
@@ -1989,5 +1979,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetOpenFlags} */
-static unsigned dmgGetOpenFlags(void *pBackendData)
+static DECLCALLBACK(unsigned) dmgGetOpenFlags(void *pBackendData)
 {
     LogFlowFunc(("pBackendData=%#p\n", pBackendData));
@@ -2007,5 +1997,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnSetOpenFlags} */
-static int dmgSetOpenFlags(void *pBackendData, unsigned uOpenFlags)
+static DECLCALLBACK(int) dmgSetOpenFlags(void *pBackendData, unsigned uOpenFlags)
 {
     LogFlowFunc(("pBackendData=%#p\n uOpenFlags=%#x", pBackendData, uOpenFlags));
@@ -2034,6 +2024,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetComment} */
-static int dmgGetComment(void *pBackendData, char *pszComment,
-                         size_t cbComment)
+static DECLCALLBACK(int) dmgGetComment(void *pBackendData, char *pszComment, size_t cbComment)
 {
     LogFlowFunc(("pBackendData=%#p pszComment=%#p cbComment=%zu\n", pBackendData, pszComment, cbComment));
@@ -2053,5 +2042,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnSetComment} */
-static int dmgSetComment(void *pBackendData, const char *pszComment)
+static DECLCALLBACK(int) dmgSetComment(void *pBackendData, const char *pszComment)
 {
     LogFlowFunc(("pBackendData=%#p pszComment=\"%s\"\n", pBackendData, pszComment));
@@ -2076,5 +2065,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetUuid} */
-static int dmgGetUuid(void *pBackendData, PRTUUID pUuid)
+static DECLCALLBACK(int) dmgGetUuid(void *pBackendData, PRTUUID pUuid)
 {
     LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
@@ -2094,5 +2083,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnSetUuid} */
-static int dmgSetUuid(void *pBackendData, PCRTUUID pUuid)
+static DECLCALLBACK(int) dmgSetUuid(void *pBackendData, PCRTUUID pUuid)
 {
     LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
@@ -2118,5 +2107,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetModificationUuid} */
-static int dmgGetModificationUuid(void *pBackendData, PRTUUID pUuid)
+static DECLCALLBACK(int) dmgGetModificationUuid(void *pBackendData, PRTUUID pUuid)
 {
     LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
@@ -2136,5 +2125,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnSetModificationUuid} */
-static int dmgSetModificationUuid(void *pBackendData, PCRTUUID pUuid)
+static DECLCALLBACK(int) dmgSetModificationUuid(void *pBackendData, PCRTUUID pUuid)
 {
     LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
@@ -2159,5 +2148,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetParentUuid} */
-static int dmgGetParentUuid(void *pBackendData, PRTUUID pUuid)
+static DECLCALLBACK(int) dmgGetParentUuid(void *pBackendData, PRTUUID pUuid)
 {
     LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
@@ -2177,5 +2166,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnSetParentUuid} */
-static int dmgSetParentUuid(void *pBackendData, PCRTUUID pUuid)
+static DECLCALLBACK(int) dmgSetParentUuid(void *pBackendData, PCRTUUID pUuid)
 {
     LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
@@ -2200,5 +2189,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnGetParentModificationUuid} */
-static int dmgGetParentModificationUuid(void *pBackendData, PRTUUID pUuid)
+static DECLCALLBACK(int) dmgGetParentModificationUuid(void *pBackendData, PRTUUID pUuid)
 {
     LogFlowFunc(("pBackendData=%#p pUuid=%#p\n", pBackendData, pUuid));
@@ -2218,5 +2207,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnSetParentModificationUuid} */
-static int dmgSetParentModificationUuid(void *pBackendData, PCRTUUID pUuid)
+static DECLCALLBACK(int) dmgSetParentModificationUuid(void *pBackendData, PCRTUUID pUuid)
 {
     LogFlowFunc(("pBackendData=%#p Uuid=%RTuuid\n", pBackendData, pUuid));
@@ -2241,5 +2230,5 @@
 
 /** @interface_method_impl{VBOXHDDBACKEND,pfnDump} */
-static void dmgDump(void *pBackendData)
+static DECLCALLBACK(void) dmgDump(void *pBackendData)
 {
     PDMGIMAGE pThis = (PDMGIMAGE)pBackendData;
