VirtualBox

Changeset 58096 in vbox for trunk/include/VBox/com


Ignore:
Timestamp:
Oct 7, 2015 2:05:32 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103170
Message:

com/assert.h: Cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/assert.h

    r56291 r58096  
    3333 *  In non-strict builds the result code will be NOREF'ed to kill compiler warnings.
    3434 *
    35  *  @param rc  COM result code
     35 *  @param hrc      The COM result code
    3636 */
    37 #define AssertComRC(rc)      \
    38     do { AssertMsg (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc)); NOREF (rc); } while (0)
     37#define AssertComRC(hrc) \
     38    do { AssertMsg(SUCCEEDED(hrc), ("COM RC = %Rhrc (0x%08X)\n", hrc, hrc)); NOREF(hrc); } while (0)
     39
     40/**
     41 *  Same as AssertComRC, except the caller already knows we failed.
     42 *
     43 *  @param hrc      The COM result code
     44 */
     45#define AssertComRCFailed(hrc) \
     46    do { AssertMsgFailed(("COM RC = %Rhrc (0x%08X)\n", hrc, hrc)); NOREF(hrc); } while (0)
    3947
    4048/**
     
    4250 *  if the result code is failed.
    4351 *
    44  *  @param rc  COM result code
    45  *  @param ret  the expression to return
     52 *  @param hrc      The COM result code
     53 *  @param RetExpr  The expression to return
    4654 */
    47 #define AssertComRCReturn(rc, ret)      \
    48     AssertMsgReturn (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc), ret)
     55#define AssertComRCReturn(hrc, RetExpr) \
     56    AssertMsgReturn(SUCCEEDED(hrc), ("COM RC = %Rhrc (0x%08X)\n", hrc, hrc), RetExpr)
    4957
    5058/**
     
    5260 *  if it is failed.
    5361 *
    54  *  @param rc   COM result code
    55  *  @param ret  the expression to return
     62 *  @param hrc      The COM result code
    5663 */
    57 #define AssertComRCReturnRC(rc)        \
    58     AssertMsgReturn (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc), rc)
     64#define AssertComRCReturnRC(hrc) \
     65    AssertMsgReturn(SUCCEEDED(hrc), ("COM RC = %Rhrc (0x%08X)\n", hrc, hrc), hrc)
    5966
    6067/**
    6168 *  A special version of AssertComRC that returns if the result code is failed.
    6269 *
    63  *  @param rc   COM result code
    64  *  @param ret  the expression to return
     70 *  @param hrc      The COM result code
    6571 */
    66 #define AssertComRCReturnVoid(rc)      \
    67     AssertMsgReturnVoid (SUCCEEDED (rc), ("COM RC = %Rhrc (0x%08X)\n", rc, rc))
     72#define AssertComRCReturnVoid(hrc) \
     73    AssertMsgReturnVoid(SUCCEEDED(hrc), ("COM RC = %Rhrc (0x%08X)\n", hrc, hrc))
    6874
    6975/**
     
    7177 *  breaks if the result code is failed.
    7278 *
    73  *  @param rc  COM result code
    74  *  @param eval the expression to evaluate
     79 *  @param hrc          The COM result code
     80 *  @param PreBreakExpr The expression to evaluate on failure.
    7581 */
    76 #define AssertComRCBreak(rc, eval)      \
    77     if (!SUCCEEDED (rc)) { AssertComRC (rc); eval; break; } else do {} while (0)
     82#define AssertComRCBreak(hrc, PreBreakExpr) \
     83    if (!SUCCEEDED(hrc)) { AssertMsgFailed(hrc); PreBreakExpr; break; } else do {} while (0)
    7884
    7985/**
     
    8187 *  throws it if the result code is failed.
    8288 *
    83  *  @param rc  COM result code
    84  *  @param eval the expression to throw
     89 *  @param hrc          The COM result code
     90 *  @param ThrowMeExpr  The expression which result to be thrown on failure.
    8591 */
    86 #define AssertComRCThrow(rc, eval)      \
    87     if (!SUCCEEDED (rc)) { AssertComRC (rc); throw (eval); } else do {} while (0)
     92#define AssertComRCThrow(hrc, ThrowObjExpr) \
     93    do { if (SUCCEEDED(hrc)) { /*likely*/} else { AssertMsgFailed(hrc); throw (ThrowMeExpr); } } while (0)
    8894
    8995/**
     
    9197 *  failed.
    9298 *
    93  *  @param rc  COM result code
     99 *  @param hrc      The COM result code
    94100 */
    95 #define AssertComRCBreakRC(rc)          \
    96     if (!SUCCEEDED (rc)) { AssertComRC (rc); break; } else do {} while (0)
     101#define AssertComRCBreakRC(hrc) \
     102    if (!SUCCEEDED(hrc)) { AssertMsgFailed(hrc); break; } else do {} while (0)
    97103
    98104/**
    99  *  A special version of AssertComRC that just throws @a rc if the result code is
    100  *  failed.
     105 *  A special version of AssertComRC that just throws @a hrc if the result code
     106 *  is failed.
    101107 *
    102  *  @param rc  COM result code
     108 *  @param hrc      The COM result code
    103109 */
    104 #define AssertComRCThrowRC(rc)          \
    105     if (!SUCCEEDED (rc)) { AssertComRC (rc); throw rc; } else do {} while (0)
     110#define AssertComRCThrowRC(hrc) \
     111    do { if (SUCCEEDED(hrc)) { /*likely*/ } else { AssertMsgFailed(hrc); throw hrc; } } while (0)
    106112
    107113#endif // !___VBox_com_assert_h
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette