VirtualBox

Changeset 62800 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 1, 2016 9:41:36 AM (8 years ago)
Author:
vboxsync
Message:

GuestCtrl/Service: warnings

Location:
trunk/src/VBox/HostServices/GuestControl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestControl/gctrl.cpp

    r62489 r62800  
    4646namespace guestControl {
    4747
     48#if 0 /* unused */
    4849/**
    4950 * Creates the argument list as an array used for executing a program.
    5051 *
    5152 * @returns VBox status code.
    52  *
    53  * @todo
    54  *
    55  * @todo Respect spaces when quoting for arguments, e.g. "c:\\program files\\".
    56  * @todo Handle empty ("") arguments.
    5753 */
    5854int gctrlPrepareExecArgv(char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs)
    5955{
    6056    char **ppaArg;
    61     int iArgs;
    62     int rc = RTGetOptArgvFromString(&ppaArg, &iArgs, pszArgs, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL);
     57    int cArgs;
     58    int rc = RTGetOptArgvFromString(&ppaArg, &cArgs, pszArgs, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL);
    6359    if (RT_SUCCESS(rc))
    6460    {
     61        /** @todo calc size first, allocate buffer, copy stuff. */
    6562        char *pszTemp = NULL;
    6663        *pcbList = 0;
    67         for (int i=0; i<iArgs; i++)
     64        for (int i = 0; i < cArgs; i++)
    6865        {
    6966            if (i > 0) /* Insert space as delimiter. */
     67            {
    7068                rc = RTStrAAppendN(&pszTemp, " ", 1);
    71 
    72             if (RT_FAILURE(rc))
    73                 break;
    74             else
    75             {
    76                 rc = RTStrAAppendN(&pszTemp, ppaArg[i], strlen(ppaArg[i]));
    7769                if (RT_FAILURE(rc))
    7870                    break;
    7971            }
    80         }
     72            rc = RTStrAAppendN(&pszTemp, ppaArg[i], strlen(ppaArg[i]));
     73            if (RT_FAILURE(rc))
     74                break;
     75        }
     76
    8177        RTGetOptArgvFree(ppaArg);
     78
    8279        if (RT_SUCCESS(rc))
    8380        {
    8481            *ppvList = pszTemp;
    85             *pcArgs = iArgs;
    86             *pcbList = strlen(pszTemp) + 1; /* Include zero termination. */
     82            *pcArgs  = cArgs;
     83            *pcbList = (uint32_t)(strlen(pszTemp) + 1); /* Include zero termination. */
    8784        }
    8885        else
     
    9188    return rc;
    9289}
    93 
    94 
     90#endif
     91
     92
     93#if 0 /* unused */
    9594/**
    96  * Appends environment variables to the environment block. Each var=value pair is separated
    97  * by NULL (\0) sequence. The whole block will be stored in one blob and disassembled on the
    98  * guest side later to fit into the HGCM param structure.
     95 * Appends environment variables to the environment block.
     96 *
     97 * Each var=value pair is separated by NULL (\0) sequence. The whole block will
     98 * be stored in one blob and disassembled on the guest side later to fit into
     99 * the HGCM param structure.
    99100 *
    100101 * @returns VBox status code.
    101102 *
    102  * @todo
    103  *
     103 * @todo Write proper documentation
     104 * @remarks currently not used.
    104105 */
    105106int gctrlAddToExecEnvv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv)
    106107{
    107108    int rc = VINF_SUCCESS;
    108     uint32_t cbLen = strlen(pszEnv);
     109    size_t cchLen = strlen(pszEnv);
    109110    if (*ppvList)
    110111    {
    111         uint32_t cbNewLen = *pcbList + cbLen + 1; /* Include zero termination. */
     112        size_t cbNewLen = *pcbList + cchLen + 1; /* Include zero termination. */
    112113        char *pvTmp = (char*)RTMemRealloc(*ppvList, cbNewLen);
    113114        if (NULL == pvTmp)
     
    117118        else
    118119        {
    119             memcpy(pvTmp + *pcbList, pszEnv, cbLen);
     120            memcpy(pvTmp + *pcbList, pszEnv, cchLen);
    120121            pvTmp[cbNewLen - 1] = '\0'; /* Add zero termination. */
    121122            *ppvList = (void**)pvTmp;
     
    135136    if (RT_SUCCESS(rc))
    136137    {
    137         *pcbList += cbLen + 1; /* Include zero termination. */
    138         *pcEnv += 1;           /* Increase env pairs count. */
    139     }
    140     return rc;
    141 }
     138        *pcbList += (uint32_t)(cchLen + 1); /* Include zero termination. */
     139        *pcEnv   += 1;                      /* Increase env pairs count. */
     140    }
     141    return rc;
     142}
     143#endif /* unused */
    142144
    143145/*
  • trunk/src/VBox/HostServices/GuestControl/gctrl.h

    r62489 r62800  
    2323namespace guestControl {
    2424
     25//unused: /** @todo write docs! */
     26//unused: int gctrlPrepareExecArgv(char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs);
     27//unused: /** @todo write docs! */
     28//unused: int gctrlAddToExecEnvv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
     29#if 0
    2530/** @todo write docs! */
    26 int gctrlPrepareExecArgv(char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs);
    27 /** @todo write docs! */
    28 int gctrlAddToExecEnvv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
    29 /** @todo write docs! */
    30 #if 0
    3131int gctrlAllocateExecBlock(PVBOXGUESTCTRLEXECBLOCK *ppBlock,
    3232                           const char *pszCmd, uint32_t fFlags,
  • trunk/src/VBox/HostServices/GuestControl/service.cpp

    r60391 r62800  
    10281028    int sessionClose(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
    10291029    int uninit(void);
     1030
     1031    DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Service);
    10301032};
    10311033
     
    10391041int Service::clientConnect(uint32_t u32ClientID, void *pvClient)
    10401042{
     1043    RT_NOREF1(pvClient);
    10411044    LogFlowFunc(("[Client %RU32] Connected\n", u32ClientID));
    10421045#ifdef VBOX_STRICT
     
    10661069int Service::clientDisconnect(uint32_t u32ClientID, void *pvClient)
    10671070{
     1071    RT_NOREF1(pvClient);
    10681072    LogFlowFunc(("[Client %RU32] Disconnected (%zu clients total)\n",
    10691073                 u32ClientID, mClientStateMap.size()));
     
    11691173                                   uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    11701174{
     1175    RT_NOREF1(callHandle);
     1176
    11711177    /*
    11721178     * Lookup client in our list so that we can assign the context ID of
     
    11821188        return VERR_INVALID_PARAMETER;
    11831189
    1184     uint32_t uValue, uMaskAdd, uMaskRemove;
     1190    uint32_t uValue;
    11851191    int rc = paParms[0].getUInt32(&uValue);
    11861192    if (RT_SUCCESS(rc))
     1193    {
     1194        uint32_t uMaskAdd;
    11871195        rc = paParms[1].getUInt32(&uMaskAdd);
    1188     if (RT_SUCCESS(rc))
    1189         rc = paParms[2].getUInt32(&uMaskRemove);
    1190     /** @todo paParm[3] (flags) not used yet. */
    1191     if (RT_SUCCESS(rc))
    1192     {
    1193         ClientState &clientState = itClientState->second;
    1194 
    1195         clientState.mFlags |= CLIENTSTATE_FLAG_CONTEXTFILTER;
    1196         if (uMaskAdd)
    1197             clientState.mFilterMask |= uMaskAdd;
    1198         if (uMaskRemove)
    1199             clientState.mFilterMask &= ~uMaskRemove;
    1200 
    1201         clientState.mFilterValue = uValue;
    1202 
    1203         LogFlowFunc(("[Client %RU32] Setting message filterMask=0x%x, filterVal=%RU32 set (flags=0x%x, maskAdd=0x%x, maskRemove=0x%x)\n",
    1204                      u32ClientID, clientState.mFilterMask, clientState.mFilterValue,
    1205                      clientState.mFlags, uMaskAdd, uMaskRemove));
     1196        if (RT_SUCCESS(rc))
     1197        {
     1198            uint32_t uMaskRemove;
     1199            rc = paParms[2].getUInt32(&uMaskRemove);
     1200            /** @todo paParm[3] (flags) not used yet. */
     1201            if (RT_SUCCESS(rc))
     1202            {
     1203                ClientState &clientState = itClientState->second;
     1204
     1205                clientState.mFlags |= CLIENTSTATE_FLAG_CONTEXTFILTER;
     1206                if (uMaskAdd)
     1207                    clientState.mFilterMask |= uMaskAdd;
     1208                if (uMaskRemove)
     1209                    clientState.mFilterMask &= ~uMaskRemove;
     1210
     1211                clientState.mFilterValue = uValue;
     1212
     1213                LogFlowFunc(("[Client %RU32] Setting message filterMask=0x%x, filterVal=%RU32 set (flags=0x%x, maskAdd=0x%x, maskRemove=0x%x)\n",
     1214                             u32ClientID, clientState.mFilterMask, clientState.mFilterValue,
     1215                             clientState.mFlags, uMaskAdd, uMaskRemove));
     1216            }
     1217        }
    12061218    }
    12071219
     
    12121224                                     uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    12131225{
     1226    RT_NOREF2(callHandle, paParms);
     1227
    12141228    /*
    12151229     * Lookup client in our list so that we can assign the context ID of
     
    12381252                           uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    12391253{
     1254    RT_NOREF2(callHandle, paParms);
     1255
    12401256    /*
    12411257     * Lookup client in our list so that we can assign the context ID of
     
    15601576int Service::sessionClose(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    15611577{
     1578    RT_NOREF2(u32ClientID, callHandle);
    15621579    if (cParms < 2)
    15631580        return VERR_INVALID_PARAMETER;
     
    15741591
    15751592    LogFlowFunc(("Closing guest session ID=%RU32 (from client ID=%RU32) returned with rc=%Rrc\n",
    1576                  uSessionID, u32ClientID, rc));
     1593                 uSessionID, u32ClientID, rc)); NOREF(uSessionID);
    15771594    return rc;
    15781595}
  • trunk/src/VBox/HostServices/GuestControl/testcase/tstGuestControlSvc.cpp

    r62489 r62800  
    154154    RTTestSub(g_hTest, "Testing host commands ...");
    155155
    156     static VBOXHGCMSVCPARM s_aParms[1];
    157     s_aParms[0].setUInt32(1000 /* Context ID */);
    158 
    159     static CMDHOST s_aCmdHostAll[] =
    160     {
    161         #if 0
     156    VBOXHGCMSVCPARM aParms[1];
     157    aParms[0].setUInt32(1000 /* Context ID */);
     158
     159    CMDHOST aCmdHostAll[] =
     160    {
     161#if 0
    162162        /** No client connected. */
    163163        { 1024 /* Not existing command */, 0, 0, false, VERR_NOT_FOUND },
    164164        { -1 /* Invalid command */, 0, 0, false, VERR_NOT_FOUND },
    165165        { HOST_CANCEL_PENDING_WAITS, 1024, 0, false, VERR_NOT_FOUND },
    166         { HOST_CANCEL_PENDING_WAITS, 0, &s_aParms[0], false, VERR_NOT_FOUND },
     166        { HOST_CANCEL_PENDING_WAITS, 0, &aParms[0], false, VERR_NOT_FOUND },
    167167
    168168        /** No client connected, valid command. */
     
    176176        /** Client connected, valid parameters given. */
    177177        { HOST_CANCEL_PENDING_WAITS, 0, 0, true, VINF_SUCCESS },
    178         { HOST_CANCEL_PENDING_WAITS, 1024, &s_aParms[0], true, VINF_SUCCESS },
    179         { HOST_CANCEL_PENDING_WAITS, 0, &s_aParms[0], true, VINF_SUCCESS},
    180         #endif
     178        { HOST_CANCEL_PENDING_WAITS, 1024, &aParms[0], true, VINF_SUCCESS },
     179        { HOST_CANCEL_PENDING_WAITS, 0, &aParms[0], true, VINF_SUCCESS},
     180#endif
    181181
    182182        /** Client connected, invalid parameters given. */
     
    186186
    187187        /** Client connected, parameters given. */
    188         { HOST_CANCEL_PENDING_WAITS, 1, &s_aParms[0], true, VINF_SUCCESS },
    189         { HOST_EXEC_CMD, 1, &s_aParms[0], true, VINF_SUCCESS },
    190         { HOST_EXEC_SET_INPUT, 1, &s_aParms[0], true, VINF_SUCCESS },
    191         { HOST_EXEC_GET_OUTPUT, 1, &s_aParms[0], true, VINF_SUCCESS },
     188        { HOST_CANCEL_PENDING_WAITS, 1, &aParms[0], true, VINF_SUCCESS },
     189        { HOST_EXEC_CMD, 1, &aParms[0], true, VINF_SUCCESS },
     190        { HOST_EXEC_SET_INPUT, 1, &aParms[0], true, VINF_SUCCESS },
     191        { HOST_EXEC_GET_OUTPUT, 1, &aParms[0], true, VINF_SUCCESS },
    192192
    193193        /** Client connected, unknown command + valid parameters given. */
    194         { -1, 1, &s_aParms[0], true, VINF_SUCCESS }
     194        { -1, 1, &aParms[0], true, VINF_SUCCESS }
    195195    };
    196196
    197     int rc = testHostCmd(pTable, &s_aCmdHostAll[0], RT_ELEMENTS(s_aCmdHostAll));
     197    int rc = testHostCmd(pTable, &aCmdHostAll[0], RT_ELEMENTS(aCmdHostAll));
    198198    RTTestSubDone(g_hTest);
    199199    return rc;
     
    210210
    211211        /* No commands from host yet. */
    212         static VBOXHGCMSVCPARM s_aParmsGuest[8];
    213         s_aParmsGuest[0].setUInt32(0 /* Msg type */);
    214         s_aParmsGuest[1].setUInt32(0 /* Parameters */);
     212        VBOXHGCMSVCPARM aParmsGuest[8];
     213        aParmsGuest[0].setUInt32(0 /* Msg type */);
     214        aParmsGuest[1].setUInt32(0 /* Parameters */);
    215215        pTable->pfnCall(pTable->pvService, &callHandle, 1 /* Client ID */, NULL /* pvClient */,
    216                         GUEST_MSG_WAIT, 2, &s_aParmsGuest[0]);
     216                        GUEST_MSG_WAIT, 2, &aParmsGuest[0]);
    217217        RTTEST_CHECK_RC_RET(g_hTest, callHandle.rc, VINF_SUCCESS, callHandle.rc);
    218218
    219219        /* Host: Add a dummy command. */
    220         static VBOXHGCMSVCPARM s_aParmsHost[8];
    221         s_aParmsHost[0].setUInt32(1000 /* Context ID */);
    222         s_aParmsHost[1].setString("foo.bar");
    223         s_aParmsHost[2].setString("baz");
    224 
    225         rc = pTable->pfnHostCall(pTable->pvService, HOST_EXEC_CMD, 3, &s_aParmsHost[0]);
     220        VBOXHGCMSVCPARM aParmsHost[8];
     221        aParmsHost[0].setUInt32(1000 /* Context ID */);
     222        aParmsHost[1].setString("foo.bar");
     223        aParmsHost[2].setString("baz");
     224
     225        rc = pTable->pfnHostCall(pTable->pvService, HOST_EXEC_CMD, 3, &aParmsHost[0]);
    226226        RTTEST_CHECK_RC_RET(g_hTest, rc, VINF_SUCCESS, rc);
    227227
     
    239239 * Set environment variable "IPRT_TEST_MAX_LEVEL=all" to get more debug output!
    240240 */
    241 int main(int argc, char **argv)
     241int main()
    242242{
    243243    RTEXITCODE rcExit  = RTTestInitAndCreate("tstGuestControlSvc", &g_hTest);
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