VirtualBox

Changeset 104560 in vbox


Ignore:
Timestamp:
May 8, 2024 3:28:20 PM (7 months ago)
Author:
vboxsync
Message:

HostServices/SharedFolders/testcase/tstSharedFolderService.cpp: Don't call methods with side effects in AssertReleaseRC() as the function will be called twice in case of an error, bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/testcase/tstSharedFolderService.cpp

    r99775 r104560  
    420420    bufferFromPath((char *)pvBuf, cbToRead, g_testRTFileRead_pszData);
    421421    if (pcbRead)
    422         *pcbRead = RT_MIN(cbToRead, strlen(g_testRTFileRead_pszData) + 1);
     422    {
     423        size_t cchData = strlen(g_testRTFileRead_pszData) + 1;
     424        *pcbRead = RT_MIN(cbToRead, cchData);
     425    }
    423426    g_testRTFileRead_pszData = 0;
    424427    return VINF_SUCCESS;
     
    433436    bufferFromPath((char *)pvBuf, cbToRead, g_testRTFileRead_pszData);
    434437    if (pcbRead)
    435         *pcbRead = RT_MIN(cbToRead, strlen(g_testRTFileRead_pszData) + 1);
     438    {
     439        size_t cchData = strlen(g_testRTFileRead_pszData) + 1;
     440        *pcbRead = RT_MIN(cbToRead, cchData);
     441    }
    436442    g_testRTFileRead_pszData = 0;
    437443    return VINF_SUCCESS;
     
    688694
    689695    initTable(psvcTable, psvcHelpers);
    690     AssertReleaseRC(VBoxHGCMSvcLoad(psvcTable));
     696    rc = VBoxHGCMSvcLoad(psvcTable);
     697    AssertReleaseRC(rc);
    691698    AssertRelease(  psvcTable->pvService
    692699                  = RTTestGuardedAllocTail(hTest, psvcTable->cbClient));
     
    916923                     (hTest, "Result=%d\n", (int) Result));
    917924    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    918     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    919     AssertReleaseRC(svcTable.pfnUnload(NULL));
     925    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     926    AssertReleaseRC(rc);
     927    rc = svcTable.pfnUnload(NULL);
     928    AssertReleaseRC(rc);
    920929    RTTestGuardedFree(hTest, svcTable.pvService);
    921930    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile,
     
    951960                     (hTest, "Result=%d\n", (int) Result));
    952961    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    953     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    954     AssertReleaseRC(svcTable.pfnUnload(NULL));
     962    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     963    AssertReleaseRC(rc);
     964    rc = svcTable.pfnUnload(NULL);
     965    AssertReleaseRC(rc);
    955966    RTTestGuardedFree(hTest, svcTable.pvService);
    956967    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile,
     
    987998                     (hTest, "Result=%d\n", (int) Result));
    988999    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    989     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    990     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1000    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1001    AssertReleaseRC(rc);
     1002    rc = svcTable.pfnUnload(NULL);
     1003    AssertReleaseRC(rc);
    9911004    RTTestGuardedFree(hTest, svcTable.pvService);
    9921005    RTTEST_CHECK_MSG(hTest, g_testRTDirClose_hDir == hDir, (hTest, "hDir=%p\n", g_testRTDirClose_hDir));
     
    10241037    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    10251038    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile, (hTest, "File=%u\n", g_testRTFileClose_hFile));
    1026     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1027     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1039    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1040    AssertReleaseRC(rc);
     1041    rc = svcTable.pfnUnload(NULL);
     1042    AssertReleaseRC(rc);
    10281043    RTTestGuardedFree(hTest, svcTable.pvService);
    10291044}
     
    10581073    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    10591074    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile, (hTest, "File=%u\n", g_testRTFileClose_hFile));
    1060     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1061     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1075    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1076    AssertReleaseRC(rc);
     1077    rc = svcTable.pfnUnload(NULL);
     1078    AssertReleaseRC(rc);
    10621079    RTTestGuardedFree(hTest, svcTable.pvService);
    10631080}
     
    10831100    RTTEST_CHECK_MSG(hTest, g_testRTFileFlush_hFile == hFile, (hTest, "File=%u\n", g_testRTFileFlush_hFile));
    10841101    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    1085     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1086     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1102    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1103    AssertReleaseRC(rc);
     1104    rc = svcTable.pfnUnload(NULL);
     1105    AssertReleaseRC(rc);
    10871106    RTTestGuardedFree(hTest, svcTable.pvService);
    10881107    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile, (hTest, "File=%u\n", g_testRTFileClose_hFile));
     
    11171136                     (hTest, "cFiles=%llu\n", LLUIFY(cFiles)));
    11181137    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    1119     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1120     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1138    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1139    AssertReleaseRC(rc);
     1140    rc = svcTable.pfnUnload(NULL);
     1141    AssertReleaseRC(rc);
    11211142    RTTestGuardedFree(hTest, svcTable.pvService);
    11221143    RTTEST_CHECK_MSG(hTest, g_testRTDirClose_hDir == hDir, (hTest, "hDir=%p\n", g_testRTDirClose_hDir));
     
    11581179                     (hTest, "Size=%llu\n", LLUIFY(g_testRTFileSet_fMode)));
    11591180    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    1160     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1161     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1181    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1182    AssertReleaseRC(rc);
     1183    rc = svcTable.pfnUnload(NULL);
     1184    AssertReleaseRC(rc);
    11621185    RTTestGuardedFree(hTest, svcTable.pvService);
    11631186    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile, (hTest, "File=%u\n", g_testRTFileClose_hFile));
     
    12011224                      LLUIFY(RTTimeSpecGetNano(&g_testRTDirSetTimes_ATime))));
    12021225    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    1203     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1204     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1226    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1227    AssertReleaseRC(rc);
     1228    rc = svcTable.pfnUnload(NULL);
     1229    AssertReleaseRC(rc);
    12051230    RTTestGuardedFree(hTest, svcTable.pvService);
    12061231    RTTEST_CHECK_MSG(hTest, g_testRTDirClose_hDir == hDir, (hTest, "hDir=%p\n", g_testRTDirClose_hDir));
     
    12441269                      LLUIFY(RTTimeSpecGetNano(&g_testRTFileSetTimes_ATime))));
    12451270    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    1246     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1247     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1271    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1272    AssertReleaseRC(rc);
     1273    rc = svcTable.pfnUnload(NULL);
     1274    AssertReleaseRC(rc);
    12481275    RTTestGuardedFree(hTest, svcTable.pvService);
    12491276    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile, (hTest, "File=%u\n", g_testRTFileClose_hFile));
     
    12771304                     (hTest, "Size=%llu\n", LLUIFY(g_testRTFileSetSize_cbSize)));
    12781305    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    1279     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1280     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1306    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1307    AssertReleaseRC(rc);
     1308    rc = svcTable.pfnUnload(NULL);
     1309    AssertReleaseRC(rc);
    12811310    RTTestGuardedFree(hTest, svcTable.pvService);
    12821311    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile, (hTest, "File=%u\n", g_testRTFileClose_hFile));
     
    13231352#endif
    13241353    unmapAndRemoveMapping(hTest, &svcTable, Root, "testname");
    1325     AssertReleaseRC(svcTable.pfnDisconnect(NULL, 0, svcTable.pvService));
    1326     AssertReleaseRC(svcTable.pfnUnload(NULL));
     1354    rc = svcTable.pfnDisconnect(NULL, 0, svcTable.pvService);
     1355    AssertReleaseRC(rc);
     1356    rc = svcTable.pfnUnload(NULL);
     1357    AssertReleaseRC(rc);
    13271358    RTTestGuardedFree(hTest, svcTable.pvService);
    13281359    RTTEST_CHECK_MSG(hTest, g_testRTFileClose_hFile == hFile, (hTest, "File=%u\n", g_testRTFileClose_hFile));
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