VirtualBox

Changeset 5889 in vbox


Ignore:
Timestamp:
Nov 30, 2007 12:39:22 PM (17 years ago)
Author:
vboxsync
Message:

r=bird: Use the right asserts (no function names in the msg, please). RTMem*Alloc* assers for you. Mark enum. You don't cast to void *. Doxygen autobrief.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp

    r5824 r5889  
    3535/** The VBoxGuest device handle. */
    3636static RTFILE g_File = NIL_RTFILE;
     37
    3738
    3839VBGLR3DECL(int) VbglR3Init(void)
     
    167168}
    168169
     170
    169171VBGLR3DECL(int) VbglR3GRAlloc(VMMDevRequestHeader **ppReq, uint32_t cbSize,
    170                               VMMDevRequestType reqType)
     172                              VMMDevRequestType enmReqType)
    171173{
    172174    VMMDevRequestHeader *pReq;
    173     int rc = VINF_SUCCESS;
    174 
    175     if (!ppReq || cbSize < sizeof (VMMDevRequestHeader))
    176     {
    177         AssertMsgFailed(("VbglR3GRAlloc: Invalid parameter: ppReq = %p, cbSize = %d\n",
    178                          ppReq, cbSize));
    179         return VERR_INVALID_PARAMETER;
    180     }
    181     pReq = (VMMDevRequestHeader *)RTMemTmpAlloc (cbSize);
    182     if (!pReq)
    183     {
    184         AssertMsgFailed(("VbglR3GRAlloc: no memory\n"));
    185         rc = VERR_NO_MEMORY;
    186     }
    187     else
    188     {
    189         pReq->size        = cbSize;
    190         pReq->version     = VMMDEV_REQUEST_HEADER_VERSION;
    191         pReq->requestType = reqType;
    192         pReq->rc          = VERR_GENERAL_FAILURE;
    193         pReq->reserved1   = 0;
    194         pReq->reserved2   = 0;
    195 
    196         *ppReq = pReq;
    197     }
    198 
    199     return rc;
    200 }
     175
     176    AssertPtrReturn(ppReq, VERR_INVALID_PARAMETER);
     177    AssertMsgReturn(cb >= sizeof(VMMDevRequestHeader), ("%#x vs %#zx\n", cb, sizeof(VMMDevRequestHeader)),
     178                    VERR_INVALID_PARAMETER);
     179
     180    pReq = (VMMDevRequestHeader *)RTMemTmpAlloc(cb);
     181    if (RT_UNLIKELY(!pReq))
     182        return VERR_NO_MEMORY;
     183
     184    pReq->size        = cbSize;
     185    pReq->version     = VMMDEV_REQUEST_HEADER_VERSION;
     186    pReq->requestType = enmReqType;
     187    pReq->rc          = VERR_GENERAL_FAILURE;
     188    pReq->reserved1   = 0;
     189    pReq->reserved2   = 0;
     190
     191    *ppReq = pReq;
     192
     193    return VINF_SUCCESS;
     194}
     195
    201196
    202197VBGLR3DECL(int) VbglR3GRPerform(VMMDevRequestHeader *pReq)
     
    205200}
    206201
    207 VBGLR3DECL(void) VbglR3GRFree (VMMDevRequestHeader *pReq)
    208 {
    209     RTMemTmpFree((void *)pReq);
    210 }
     202
     203VBGLR3DECL(void) VbglR3GRFree(VMMDevRequestHeader *pReq)
     204{
     205    RTMemTmpFree(pReq);
     206}
     207
    211208
    212209VBGLR3DECL(int) VbglR3GetHostTime(PRTTIMESPEC pTime)
     
    221218}
    222219
     220
    223221/**
    224  * Cause any pending WaitEvent calls (VBOXGUEST_IOCTL_WAITEVENT) to return with a
    225  * VERR_INTERRUPTED error.  Can be used in combination with a termination flag variable for
    226  * interrupting event loops.  Avoiding race conditions is the responsibility of the caller.
     222 * Cause any pending WaitEvent calls (VBOXGUEST_IOCTL_WAITEVENT) to return
     223 * with a VERR_INTERRUPTED status.
     224 *
     225 * Can be used in combination with a termination flag variable for interrupting
     226 * event loops. Avoiding race conditions is the responsibility of the caller.
    227227 *
    228228 * @returns IPRT status code
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