Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File:
  4. // reterr.h
  5. //
  6. // Contents:
  7. // Macros that perform an (argument) operation, and on failure,
  8. // give a warning, and branch to error returns
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History:
  15. // 12/30/93 - ChrisWe - redefined Warn macro; added DbgWarn
  16. //
  17. //-----------------------------------------------------------------------------
  18. /* Jason's error handling macros */
  19. #ifndef RETERR_H
  20. #define RETERR_H
  21. #ifdef _DEBUG
  22. #ifdef NEVER
  23. FARINTERNAL_(void) wWarn(LPOLESTR sz, LPOLESTR szFile, int iLine);
  24. #define Warn(sz) wWarn(sz, __FILE__, __LINE__)
  25. #endif // NEVER
  26. FARINTERNAL_(void) DbgWarn(LPSTR psz, LPSTR pszFileName, ULONG uLineno);
  27. #define Warn(sz) DbgWarn(sz, __FILE__, __LINE__)
  28. #else
  29. #define Warn(sz)
  30. #endif // _DEBUG
  31. // Call x. If hresult is not NOERROR, goto errRtn.
  32. #define ErrRtn(x) do {if (NOERROR != (x)) {Warn(NULL); goto errRtn;}} while(0)
  33. // Call x. If hresult is not NOERROR, store it in hresult and goto errRtn.
  34. #define ErrRtnH(x) do {if (NOERROR != (hresult=(x))) {Warn(NULL); goto errRtn;}} while (0)
  35. // If x, goto errRtn.
  36. #define ErrNz(x) do {if (x) {Warn(NULL); goto errRtn;}} while (0)
  37. // If x==0, goto errRtn.
  38. #define ErrZ(x) do {if (!(x)) {Warn(NULL); goto errRtn;}} while (0)
  39. // If x==0, goto errRtn with a specific scode
  40. #define ErrZS(x, scode) do {if (!(x)) {Warn(NULL); hresult=ResultFromScode(scode); goto errRtn;}} while (0)
  41. // Call x. If hresult is not NOERROR, return that hresult.
  42. #define RetErr(x) do {HRESULT hresult; if (NOERROR != (hresult=(x))) {Warn(NULL); return hresult;}} while (0)
  43. // Return unexpected error if x is non-zero
  44. #define RetNz(x) do {if (x) {Warn(NULL); return ReportResult(0, E_UNEXPECTED, 0, 0);}} while (0)
  45. // Return specific scode if x is non-zero
  46. #define RetNzS(x, scode) do {if (x) {Warn(NULL); return ResultFromScode (scode);}} while (0)
  47. // Return unexpected error if x is zero
  48. #define RetZ(x) do {if (!(x)) {Warn(NULL); return ReportResult(0, E_UNEXPECTED, 0, 0);}} while (0)
  49. // Return specific scode if x is zero
  50. #define RetZS(x, scode) do {if (!(x)) {Warn(NULL); return ResultFromScode (scode);}} while (0)
  51. #endif // RETERR_H