Index: /trunk/src/VBox/HostServices/GuestControl/service.cpp
===================================================================
--- /trunk/src/VBox/HostServices/GuestControl/service.cpp	(revision 75875)
+++ /trunk/src/VBox/HostServices/GuestControl/service.cpp	(revision 75876)
@@ -106,4 +106,13 @@
  * Structure for holding a buffered host command which has
  * not been processed yet.
+ *
+ * @todo r=bird: It would be nice if we could decide on _one_ term for what the
+ *       host passes to the guest.  We currently have:
+ *          - The enum is called eHostFn, implying it's a function
+ *          - The guest retrieves messages, if the eGuestFn enum is anything to
+ *            go by: GUEST_MSG_GET, GUEST_MSG_CANCEL, GUEST_MSG_XXX
+ *          - Here it's called a host command.
+ *          - But this HostCommand structure has a mMsgType rather than command
+ *            number/enum value, impliying it's a message.
  */
 typedef struct HostCommand
@@ -368,7 +377,7 @@
     }
 
-    int Assign(const ClientRequest *pConnection)
-    {
-        AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
+    int Assign(const ClientRequest *pReq)
+    {
+        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
 
         int rc;
@@ -378,8 +387,8 @@
         /* Does the current host command need more parameter space which
          * the client does not provide yet? */
-        if (mParmCount > pConnection->mNumParms)
+        if (mParmCount > pReq->mNumParms)
         {
             LogFlowThisFunc(("[Cmd %RU32] Requires %RU32 parms, only got %RU32 from client\n",
-                             mMsgType, mParmCount, pConnection->mNumParms));
+                             mMsgType, mParmCount, pReq->mNumParms));
             /*
              * So this call apparently failed because the guest wanted to peek
@@ -391,5 +400,5 @@
         else
         {
-            rc = CopyTo(pConnection->mParms, pConnection->mNumParms);
+            rc = CopyTo(pReq->mParms, pReq->mNumParms);
 
             /*
@@ -408,18 +417,18 @@
     }
 
-    int Peek(const ClientRequest *pConnection)
-    {
-        AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
+    int Peek(const ClientRequest *pReq)
+    {
+        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
 
         LogFlowThisFunc(("[Cmd %RU32] mParmCount=%RU32, mpParms=%p\n", mMsgType, mParmCount, mpParms));
 
-        if (pConnection->mNumParms >= 2)
-        {
-            HGCMSvcSetU32(&pConnection->mParms[0], mMsgType);   /* Message ID */
-            HGCMSvcSetU32(&pConnection->mParms[1], mParmCount); /* Required parameters for message */
+        if (pReq->mNumParms >= 2)
+        {
+            HGCMSvcSetU32(&pReq->mParms[0], mMsgType);   /* Message ID */
+            HGCMSvcSetU32(&pReq->mParms[1], mParmCount); /* Required parameters for message */
         }
         else
             LogFlowThisFunc(("Warning: Client has not (yet) submitted enough parameters (%RU32, must be at least 2) to at least peak for the next message\n",
-                             pConnection->mNumParms));
+                             pReq->mNumParms));
 
         /*
@@ -655,14 +664,14 @@
      * @note Only used by GUEST_MSG_WAIT scenarios.
      */
-    int OldRun(ClientRequest const *pConnection, HostCommand *pHostCmd)
-    {
-        AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
+    int OldRun(ClientRequest const *pReq, HostCommand *pHostCmd)
+    {
+        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
         AssertPtrReturn(pHostCmd, VERR_INVALID_POINTER);
         Assert(RTListNodeIsFirst(&m_HostCmdList, &pHostCmd->m_ListEntry));
 
-        LogFlowFunc(("[Client %RU32] pConnection=%p, mHostCmdRc=%Rrc, mHostCmdTries=%RU32, mPeekCount=%RU32\n",
-                      m_idClient, pConnection, mHostCmdRc, mHostCmdTries, mPeekCount));
-
-        int rc = mHostCmdRc = OldSendReply(pConnection, pHostCmd);
+        LogFlowFunc(("[Client %RU32] pReq=%p, mHostCmdRc=%Rrc, mHostCmdTries=%RU32, mPeekCount=%RU32\n",
+                      m_idClient, pReq, mHostCmdRc, mHostCmdTries, mPeekCount));
+
+        int rc = mHostCmdRc = OldSendReply(pReq, pHostCmd);
 
         LogFlowThisFunc(("[Client %RU32] Processing command %RU32 ended with rc=%Rrc\n", m_idClient, pHostCmd->mMsgType, mHostCmdRc));
@@ -717,7 +726,7 @@
      * @note Only used by GUEST_MSG_WAIT scenarios.
      */
-    int OldRunCurrent(const ClientRequest *pConnection)
-    {
-        AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
+    int OldRunCurrent(const ClientRequest *pReq)
+    {
+        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
 
         /*
@@ -731,5 +740,5 @@
                 /* Go to sleep. */
                 ASSERT_GUEST_RETURN(m_enmIsPending == 0, VERR_WRONG_ORDER);
-                m_PendingReq = *pConnection;
+                m_PendingReq = *pReq;
                 m_enmIsPending  = GUEST_MSG_WAIT;
                 LogFlowFunc(("[Client %RU32] Is now in pending mode\n", m_idClient));
@@ -739,9 +748,9 @@
             /* Wait was cancelled. */
             m_fPendingCancel = false;
-            if (pConnection->mNumParms > 0)
-                HGCMSvcSetU32(&pConnection->mParms[0], HOST_CANCEL_PENDING_WAITS);
-            if (pConnection->mNumParms > 1)
-                HGCMSvcSetU32(&pConnection->mParms[1], 0);
-            return pConnection->mNumParms == 2 ? VINF_SUCCESS : VERR_TRY_AGAIN;
+            if (pReq->mNumParms > 0)
+                HGCMSvcSetU32(&pReq->mParms[0], HOST_CANCEL_PENDING_WAITS);
+            if (pReq->mNumParms > 1)
+                HGCMSvcSetU32(&pReq->mParms[1], 0);
+            return pReq->mNumParms == 2 ? VINF_SUCCESS : VERR_TRY_AGAIN;
         }
 
@@ -749,5 +758,5 @@
          * Return first host command.
          */
-        return OldRun(pConnection, pFirstCmd);
+        return OldRun(pReq, pFirstCmd);
     }
 
@@ -756,8 +765,8 @@
      * @note Only used for GUEST_MSG_WAIT.
      */
-    int OldSendReply(ClientRequest const *pConnection,
-                     HostCommand            *pHostCmd)
-    {
-        AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
+    int OldSendReply(ClientRequest const *pReq,
+                     HostCommand         *pHostCmd)
+    {
+        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
         AssertPtrReturn(pHostCmd, VERR_INVALID_POINTER);
 
@@ -771,5 +780,5 @@
         {
             Assert(m_enmIsPending == GUEST_MSG_WAIT);
-            rc = pHostCmd->Peek(pConnection);
+            rc = pHostCmd->Peek(pReq);
             mPeekCount++;
         }
@@ -781,5 +790,5 @@
             if (!mPeekCount)
             {
-                rc = pHostCmd->Peek(pConnection);
+                rc = pHostCmd->Peek(pReq);
                 mPeekCount++;
             }
@@ -788,8 +797,8 @@
                 /* Try assigning the host command to the client and store the
                  * result code for later use. */
-                rc = pHostCmd->Assign(pConnection);
+                rc = pHostCmd->Assign(pReq);
                 if (RT_FAILURE(rc)) /* If something failed, let the client peek (again). */
                 {
-                    rc = pHostCmd->Peek(pConnection);
+                    rc = pHostCmd->Peek(pReq);
                     mPeekCount++;
                 }
@@ -805,5 +814,5 @@
          * the pending call with the result we just got. */
         AssertPtr(m_pSvcHelpers);
-        int rc2 = m_pSvcHelpers->pfnCallComplete(pConnection->mHandle, rc);
+        int rc2 = m_pSvcHelpers->pfnCallComplete(pReq->mHandle, rc);
 
         /* Rollback in case the guest cancelled the call. */
@@ -814,6 +823,6 @@
         }
 
-        LogFlowThisFunc(("[Client %RU32] Command %RU32 ended with %Rrc (mPeekCount=%RU32, pConnection=%p)\n",
-                         m_idClient, pHostCmd->mMsgType, rc, mPeekCount, pConnection));
+        LogFlowThisFunc(("[Client %RU32] Command %RU32 ended with %Rrc (mPeekCount=%RU32, pReq=%p)\n",
+                         m_idClient, pHostCmd->mMsgType, rc, mPeekCount, pReq));
         return rc;
     }
@@ -822,6 +831,4 @@
 } ClientState;
 typedef std::map< uint32_t, ClientState *> ClientStateMap;
-typedef std::map< uint32_t, ClientState *>::iterator ClientStateMapIter;
-typedef std::map< uint32_t, ClientState *>::const_iterator ClientStateMapIterConst;
 
 /**
@@ -1217,10 +1224,10 @@
      * Wait for the host to queue a message for this client.
      */
-    ASSERT_GUEST_MSG_RETURN(pClient->m_enmIsPending == 0, ("Already pending! (idClient=%RU32)\n", pClient->m_idClient), 
+    ASSERT_GUEST_MSG_RETURN(pClient->m_enmIsPending == 0, ("Already pending! (idClient=%RU32)\n", pClient->m_idClient),
                             VERR_RESOURCE_BUSY);
-    pClient->m_PendingReq.mHandle    = hCall;
-    pClient->m_PendingReq.mNumParms  = cParms;
-    pClient->m_PendingReq.mParms     = paParms;
-    pClient->m_enmIsPending             = GUEST_MSG_PEEK_WAIT;
+    pClient->m_PendingReq.mHandle   = hCall;
+    pClient->m_PendingReq.mNumParms = cParms;
+    pClient->m_PendingReq.mParms    = paParms;
+    pClient->m_enmIsPending         = GUEST_MSG_PEEK_WAIT;
     LogFlowFunc(("[Client %RU32] Is now in pending mode...\n", pClient->m_idClient));
     return VINF_HGCM_ASYNC_EXECUTE;
@@ -1822,5 +1829,5 @@
         ASSERT_GUEST_LOGREL_MSG_RETURN(idSession > 0, ("idSession=%u (%#x)\n", idSession, uValue), VERR_OUT_OF_RANGE);
 
-        for (ClientStateMapIter It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)
+        for (ClientStateMap::iterator It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)
             ASSERT_GUEST_LOGREL_MSG_RETURN(It->second->m_idSession != idSession,
                                            ("idSession=%u uValue=%#x idClient=%u; conflicting with client %u\n",
@@ -2138,5 +2145,5 @@
                 rc = VWRN_NOT_FOUND;
                 uint32_t const idSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCmd->m_idContext);
-                for (ClientStateMapIter It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)
+                for (ClientStateMap::iterator It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)
                 {
                     ClientState *pClient = It->second;
