VirtualBox

Ignore:
Timestamp:
Jul 13, 2020 9:07:41 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139296
Message:

HostServices: Clang 11++ adjustments. Eliminated pointless auto_ptr. Added a whole bunch of RT_NOEXCEPT to the DnD service abstraction. Misc cleanups. bugref:9790

Location:
trunk/src/VBox/HostServices/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/common/client.cpp

    r82968 r85318  
    2727using namespace HGCM;
    2828
    29 Client::Client(uint32_t uClientID)
    30     : m_uClientID(uClientID)
     29Client::Client(uint32_t idClient)
     30    : m_idClient(idClient)
    3131    , m_uProtocolVer(0)
    3232    , m_fDeferred(false)
     
    4949 * @param   rcOp                Return code to return to the guest side.
    5050 */
    51 int Client::completeInternal(VBOXHGCMCALLHANDLE hHandle, int rcOp)
    52 {
    53     LogFlowThisFunc(("uClientID=%RU32\n", m_uClientID));
     51int Client::completeInternal(VBOXHGCMCALLHANDLE hHandle, int rcOp) RT_NOEXCEPT
     52{
     53    LogFlowThisFunc(("idClient=%RU32\n", m_idClient));
    5454
    5555    if (   m_SvcCtx.pHelpers
     
    6868 * Resets the client's internal state.
    6969 */
    70 void Client::reset(void)
     70void Client::reset(void) RT_NOEXCEPT
    7171{
    7272   m_fDeferred = false;
     
    8383 * @param   rcOp                Return code to return to the guest side.
    8484 */
    85 int Client::Complete(VBOXHGCMCALLHANDLE hHandle, int rcOp /* = VINF_SUCCESS */)
     85int Client::Complete(VBOXHGCMCALLHANDLE hHandle, int rcOp /* = VINF_SUCCESS */) RT_NOEXCEPT
    8686{
    8787    return completeInternal(hHandle, rcOp);
     
    9595 * @param   rcOp                Return code to return to the guest side.
    9696 */
    97 int Client::CompleteDeferred(int rcOp)
     97int Client::CompleteDeferred(int rcOp) RT_NOEXCEPT
    9898{
    9999    if (m_fDeferred)
     
    108108    }
    109109
    110     AssertMsg(m_fDeferred, ("Client %RU32 is not in deferred mode\n", m_uClientID));
     110    AssertMsg(m_fDeferred, ("Client %RU32 is not in deferred mode\n", m_idClient));
    111111    return VERR_INVALID_STATE;
    112112}
     
    117117 * @returns HGCM handle.
    118118 */
    119 VBOXHGCMCALLHANDLE Client::GetHandle(void) const
     119VBOXHGCMCALLHANDLE Client::GetHandle(void) const RT_NOEXCEPT
    120120{
    121121    return m_Deferred.hHandle;
     
    127127 * @returns HGCM handle.
    128128 */
    129 uint32_t Client::GetMsgType(void) const
     129uint32_t Client::GetMsgType(void) const RT_NOEXCEPT
    130130{
    131131    return m_Deferred.uType;
    132132}
    133133
    134 uint32_t Client::GetMsgParamCount(void) const
     134uint32_t Client::GetMsgParamCount(void) const RT_NOEXCEPT
    135135{
    136136    return m_Deferred.cParms;
     
    142142 * @returns The client's (HGCM) ID.
    143143 */
    144 uint32_t Client::GetClientID(void) const
    145 {
    146     return m_uClientID;
     144uint32_t Client::GetClientID(void) const RT_NOEXCEPT
     145{
     146    return m_idClient;
    147147}
    148148
     
    152152 * @returns Protocol version, or 0 if not set.
    153153 */
    154 uint32_t Client::GetProtocolVer(void) const
     154uint32_t Client::GetProtocolVer(void) const RT_NOEXCEPT
    155155{
    156156    return m_uProtocolVer;
     
    162162 * @returns \c True if in deferred mode, \c False if not.
    163163 */
    164 bool Client::IsDeferred(void) const
     164bool Client::IsDeferred(void) const RT_NOEXCEPT
    165165{
    166166    return m_fDeferred;
     
    171171 * until CompleteDeferred() has been called.
    172172 */
    173 void Client::SetDeferred(VBOXHGCMCALLHANDLE hHandle, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    174 {
    175     LogFlowThisFunc(("uClient=%RU32\n", m_uClientID));
     173void Client::SetDeferred(VBOXHGCMCALLHANDLE hHandle, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) RT_NOEXCEPT
     174{
     175    LogFlowThisFunc(("uClient=%RU32\n", m_idClient));
    176176
    177177#ifndef DEBUG_bird /** r=bird: This bugger triggers in the DnD service when restoring saved state.  Not tested?  */
     
    192192 * @param   uVersion            Version number to set.
    193193 */
    194 void Client::SetProtocolVer(uint32_t uVersion)
     194void Client::SetProtocolVer(uint32_t uVersion) RT_NOEXCEPT
    195195{
    196196    m_uProtocolVer = uVersion;
     
    202202 * @param   SvcCtx              Service context to set.
    203203 */
    204 void Client::SetSvcContext(const VBOXHGCMSVCTX &SvcCtx)
     204void Client::SetSvcContext(const VBOXHGCMSVCTX &SvcCtx) RT_NOEXCEPT
    205205{
    206206    m_SvcCtx = SvcCtx;
     
    216216 * @param   cParms              Number of parameters the message needs.
    217217 */
    218 int Client::SetDeferredMsgInfo(uint32_t uMsg, uint32_t cParms)
     218int Client::SetDeferredMsgInfo(uint32_t uMsg, uint32_t cParms) RT_NOEXCEPT
    219219{
    220220    if (m_fDeferred)
     
    243243 * @param   pMessage            Message to get message type and required parameters from.
    244244 */
    245 int Client::SetDeferredMsgInfo(const Message *pMessage)
     245int Client::SetDeferredMsgInfo(const Message *pMessage) RT_NOEXCEPT
    246246{
    247247    AssertPtrReturn(pMessage, VERR_INVALID_POINTER);
  • trunk/src/VBox/HostServices/common/message.cpp

    r82968 r85318  
    2323    : m_uMsg(0)
    2424    , m_cParms(0)
    25     , m_paParms(NULL) { }
     25    , m_paParms(NULL)
     26{
     27}
    2628
    2729Message::Message(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[])
     
    4143 * Resets the message by free'ing all allocated parameters and resetting the rest.
    4244 */
    43 void Message::reset(void)
     45void Message::reset(void) RT_NOEXCEPT
    4446{
    4547    if (m_paParms)
     
    6769 * @returns Parameter count.
    6870 */
    69 uint32_t Message::GetParamCount(void) const
     71uint32_t Message::GetParamCount(void) const RT_NOEXCEPT
    7072{
    7173    return m_cParms;
     
    8082 * @param   aParms          Where to store the HGCM parameter data.
    8183 */
    82 int Message::GetData(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[]) const
     84int Message::GetData(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[]) const RT_NOEXCEPT
    8385{
    8486    if (m_uMsg != uMsg)
     
    103105 * @param   pu32Info        Where to store the parameter value.
    104106 */
    105 int Message::GetParmU32(uint32_t uParm, uint32_t *pu32Info) const
     107int Message::GetParmU32(uint32_t uParm, uint32_t *pu32Info) const RT_NOEXCEPT
    106108{
    107109    AssertPtrNullReturn(pu32Info, VERR_INVALID_PARAMETER);
     
    121123 * @param   pu64Info        Where to store the parameter value.
    122124 */
    123 int Message::GetParmU64(uint32_t uParm, uint64_t *pu64Info) const
     125int Message::GetParmU64(uint32_t uParm, uint64_t *pu64Info) const RT_NOEXCEPT
    124126{
    125127    AssertPtrNullReturn(pu64Info, VERR_INVALID_PARAMETER);
     
    142144 * @remarks Does not copy (store) the actual content of the pointer (deep copy).
    143145 */
    144 int Message::GetParmPtr(uint32_t uParm, void **ppvAddr, uint32_t *pcbSize) const
     146int Message::GetParmPtr(uint32_t uParm, void **ppvAddr, uint32_t *pcbSize) const RT_NOEXCEPT
    145147{
    146148    AssertPtrNullReturn(ppvAddr, VERR_INVALID_PARAMETER);
     
    160162 * @returns Message type.
    161163 */
    162 uint32_t Message::GetType(void) const
     164uint32_t Message::GetType(void) const RT_NOEXCEPT
    163165{
    164166    return m_uMsg;
     
    180182int Message::CopyParms(PVBOXHGCMSVCPARM paParmsDst, uint32_t cParmsDst,
    181183                       PVBOXHGCMSVCPARM paParmsSrc, uint32_t cParmsSrc,
    182                        bool fDeepCopy)
     184                       bool fDeepCopy) RT_NOEXCEPT
    183185{
    184186    AssertPtrReturn(paParmsSrc, VERR_INVALID_POINTER);
     
    188190        return VERR_BUFFER_OVERFLOW;
    189191
    190     int rc = VINF_SUCCESS;
    191192    for (uint32_t i = 0; i < cParmsSrc; i++)
    192193    {
     
    215216                        paParmsDst[i].u.pointer.addr = RTMemAlloc(paParmsDst[i].u.pointer.size);
    216217                        if (!paParmsDst[i].u.pointer.addr)
    217                         {
    218                             rc = VERR_NO_MEMORY;
    219                             break;
    220                         }
     218                            return VERR_NO_MEMORY;
    221219                    }
    222220                }
     
    225223                    /* No, but we have to check if there is enough room. */
    226224                    if (paParmsDst[i].u.pointer.size < paParmsSrc[i].u.pointer.size)
    227                     {
    228                         rc = VERR_BUFFER_OVERFLOW;
    229                         break;
    230                     }
     225                        return VERR_BUFFER_OVERFLOW;
    231226                }
    232227
     
    235230                    if (   paParmsDst[i].u.pointer.addr
    236231                        && paParmsDst[i].u.pointer.size)
    237                     {
    238232                        memcpy(paParmsDst[i].u.pointer.addr,
    239233                               paParmsSrc[i].u.pointer.addr,
    240234                               RT_MIN(paParmsDst[i].u.pointer.size, paParmsSrc[i].u.pointer.size));
    241                     }
    242235                    else
    243                         rc = VERR_INVALID_POINTER;
     236                        return VERR_INVALID_POINTER;
    244237                }
    245238                break;
     
    248241            {
    249242                AssertMsgFailed(("Unknown HGCM type %u\n", paParmsSrc[i].type));
    250                 rc = VERR_INVALID_PARAMETER;
    251                 break;
     243                return VERR_INVALID_PARAMETER;
    252244            }
    253245        }
    254         if (RT_FAILURE(rc))
    255             break;
    256     }
    257     return rc;
     246    }
     247    return VINF_SUCCESS;
    258248}
    259249
     
    266256 * @param   aParms          Array of parameters to set.
    267257 */
    268 int Message::initData(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[])
    269 {
     258int Message::initData(uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM aParms[]) RT_NOEXCEPT
     259{
     260    /** @todo r=bird: There is a define for the max number of HGCM parameters,
     261     *        it's way smaller than 256, something like 61 IIRC. */
    270262    AssertReturn(cParms < 256, VERR_INVALID_PARAMETER);
    271263    AssertPtrNullReturn(aParms, VERR_INVALID_PARAMETER);
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