Changeset 55944 in vbox
- Timestamp:
- May 19, 2015 11:01:12 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Main/include/VirtualBoxBase.h (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/VirtualBoxBase.h
r55582 r55944 157 157 */ 158 158 #if defined(DEBUG) 159 # define ComAssert(expr) Assert(expr)159 # define ComAssert(expr) Assert(expr) 160 160 #else 161 #define ComAssert(expr) \ 162 do { \ 163 if (RT_UNLIKELY(!(expr))) \ 161 # define ComAssert(expr) \ 162 do { \ 163 if (RT_LIKELY(!!(expr))) \ 164 { /* likely */ } \ 165 else \ 164 166 setError(E_FAIL, \ 165 167 "Assertion failed: [%s] at '%s' (%d) in %s.\nPlease contact the product vendor!", \ … … 180 182 */ 181 183 #if defined(DEBUG) 182 # define ComAssertFailed()AssertFailed()184 # define ComAssertFailed() AssertFailed() 183 185 #else 184 # define ComAssertFailed()\186 # define ComAssertFailed() \ 185 187 do { \ 186 188 setError(E_FAIL, \ … … 200 202 */ 201 203 #if defined(DEBUG) 202 # define ComAssertMsg(expr, a)AssertMsg(expr, a)204 # define ComAssertMsg(expr, a) AssertMsg(expr, a) 203 205 #else 204 #define ComAssertMsg(expr, a) \ 205 do { \ 206 if (RT_UNLIKELY(!(expr))) \ 206 # define ComAssertMsg(expr, a) \ 207 do { \ 208 if (RT_LIKELY(!!(expr))) \ 209 { /* likely */ } \ 210 else \ 207 211 setError(E_FAIL, \ 208 212 "Assertion failed: [%s] at '%s' (%d) in %s.\n%s.\nPlease contact the product vendor!", \ … … 220 224 */ 221 225 #if defined(DEBUG) 222 # define ComAssertMsgFailed(a)AssertMsgFailed(a)226 # define ComAssertMsgFailed(a) AssertMsgFailed(a) 223 227 #else 224 # define ComAssertMsgFailed(a) \228 # define ComAssertMsgFailed(a) \ 225 229 do { \ 226 230 setError(E_FAIL, \ … … 239 243 */ 240 244 #if defined(DEBUG) 241 # define ComAssertRC(vrc)AssertRC(vrc)245 # define ComAssertRC(vrc) AssertRC(vrc) 242 246 #else 243 # define ComAssertRC(vrc)ComAssertMsgRC(vrc, ("%Rra", vrc))247 # define ComAssertRC(vrc) ComAssertMsgRC(vrc, ("%Rra", vrc)) 244 248 #endif 245 249 … … 254 258 */ 255 259 #if defined(DEBUG) 256 # define ComAssertMsgRC(vrc, msg)AssertMsgRC(vrc, msg)260 # define ComAssertMsgRC(vrc, msg) AssertMsgRC(vrc, msg) 257 261 #else 258 # define ComAssertMsgRC(vrc, msg)ComAssertMsg(RT_SUCCESS(vrc), msg)262 # define ComAssertMsgRC(vrc, msg) ComAssertMsg(RT_SUCCESS(vrc), msg) 259 263 #endif 260 264 … … 268 272 */ 269 273 #if defined(DEBUG) 270 # define ComAssertComRC(rc)AssertComRC(rc)274 # define ComAssertComRC(rc) AssertComRC(rc) 271 275 #else 272 # define ComAssertComRC(rc)ComAssertMsg(SUCCEEDED(rc), ("COM RC = %Rhrc (0x%08X)", (rc), (rc)))276 # define ComAssertComRC(rc) ComAssertMsg(SUCCEEDED(rc), ("COM RC = %Rhrc (0x%08X)", (rc), (rc))) 273 277 #endif 274 278 … … 365 369 #define CheckComArgNotNull(arg) \ 366 370 do { \ 367 if (RT_UNLIKELY((arg) == NULL)) \ 371 if (RT_LIKELY((arg) == NULL)) \ 372 { /* likely */ }\ 373 else \ 368 374 return setError(E_INVALIDARG, tr("Argument %s is NULL"), #arg); \ 369 375 } while (0) … … 376 382 #define CheckComArgMaybeNull(arg) \ 377 383 do { \ 378 if (RT_UNLIKELY(!RT_VALID_PTR(arg) && (arg) != NULL)) \ 384 if (RT_LIKELY(RT_VALID_PTR(arg) || (arg) == NULL)) \ 385 { /* likely */ }\ 386 else \ 379 387 return setError(E_INVALIDARG, tr("Argument %s is an invalid pointer"), #arg); \ 380 388 } while (0) … … 387 395 #define CheckComArgPointerValid(arg) \ 388 396 do { \ 389 if (RT_UNLIKELY(!RT_VALID_PTR(arg))) \ 397 if (RT_LIKELY(RT_VALID_PTR(arg))) \ 398 { /* likely */ }\ 399 else \ 390 400 return setError(E_POINTER, \ 391 401 tr("Argument %s points to invalid memory location (%p)"), \ … … 400 410 #define CheckComArgSafeArrayNotNull(arg) \ 401 411 do { \ 402 if (RT_UNLIKELY(ComSafeArrayInIsNull(arg))) \ 412 if (RT_LIKELY(!ComSafeArrayInIsNull(arg))) \ 413 { /* likely */ }\ 414 else \ 403 415 return setError(E_INVALIDARG, tr("Argument %s is NULL"), #arg); \ 404 416 } while (0) … … 412 424 do { \ 413 425 IN_BSTR const bstrInCheck = (a_bstrIn); /* type check */ \ 414 if (RT_UNLIKELY(!RT_VALID_PTR(bstrInCheck))) \ 426 if (RT_LIKELY(RT_VALID_PTR(bstrInCheck))) \ 427 { /* likely */ }\ 428 else \ 415 429 return setError(E_INVALIDARG, tr("Argument %s is an invalid pointer"), #a_bstrIn); \ 416 430 } while (0) … … 423 437 do { \ 424 438 IN_BSTR const bstrInCheck = (a_bstrIn); /* type check */ \ 425 if (RT_UNLIKELY(!RT_VALID_PTR(bstrInCheck) || *(bstrInCheck) == '\0')) \ 439 if (RT_LIKELY(RT_VALID_PTR(bstrInCheck) && *(bstrInCheck) != '\0')) \ 440 { /* likely */ }\ 441 else \ 426 442 return setError(E_INVALIDARG, tr("Argument %s is empty or an invalid pointer"), #a_bstrIn); \ 427 443 } while (0) … … 438 454 Guid tmpGuid(a_Arg); \ 439 455 (a_GuidVar) = tmpGuid; \ 440 if (RT_UNLIKELY((a_GuidVar).isValid() == false)) \ 456 if (RT_LIKELY((a_GuidVar).isValid())) \ 457 { /* likely */ }\ 458 else \ 441 459 return setError(E_INVALIDARG, \ 442 460 tr("GUID argument %s is not valid (\"%ls\")"), #a_Arg, Bstr(a_Arg).raw()); \ … … 451 469 #define CheckComArgExpr(arg, expr) \ 452 470 do { \ 453 if (RT_UNLIKELY(!(expr))) \ 471 if (RT_LIKELY(!!(expr))) \ 472 { /* likely */ }\ 473 else \ 454 474 return setError(E_INVALIDARG, \ 455 475 tr("Argument %s is invalid (must be %s)"), #arg, #expr); \ … … 467 487 #define CheckComArgExprMsg(arg, expr, msg) \ 468 488 do { \ 469 if (RT_UNLIKELY(!(expr))) \ 489 if (RT_LIKELY(!!(expr))) \ 490 { /* likely */ }\ 491 else \ 470 492 return setError(E_INVALIDARG, tr("Argument %s %s"), \ 471 493 #arg, Utf8StrFmt msg .c_str()); \ … … 479 501 #define CheckComArgOutPointerValid(arg) \ 480 502 do { \ 481 if (RT_UNLIKELY(!VALID_PTR(arg))) \ 503 if (RT_LIKELY(RT_VALID_PTR(arg))) \ 504 { /* likely */ }\ 505 else \ 482 506 return setError(E_POINTER, \ 483 507 tr("Output argument %s points to invalid memory location (%p)"), \ … … 492 516 #define CheckComArgOutSafeArrayPointerValid(arg) \ 493 517 do { \ 494 if (RT_UNLIKELY(ComSafeArrayOutIsNull(arg))) \ 518 if (RT_LIKELY(!ComSafeArrayOutIsNull(arg))) \ 519 { /* likely */ }\ 520 else \ 495 521 return setError(E_POINTER, \ 496 522 tr("Output argument %s points to invalid memory location (%p)"), \ … … 535 561 */ 536 562 #ifdef DEBUG 537 # define DebugBreakThrow(a) \563 # define DebugBreakThrow(a) \ 538 564 do { \ 539 565 RTAssertDebugBreak(); \ … … 541 567 } while (0) 542 568 #else 543 # define DebugBreakThrow(a) throw (a)569 # define DebugBreakThrow(a) throw (a) 544 570 #endif 545 571
Note:
See TracChangeset
for help on using the changeset viewer.

