[SHELLUTILS] Fix FAILED_UNEXPECTEDLY macro evaluating twice

This commit is contained in:
Mark Jansen 2021-07-23 20:24:13 +02:00
parent d039653959
commit 61e7ea5be5
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B

View file

@ -23,7 +23,7 @@
extern "C" { extern "C" {
#endif /* defined(__cplusplus) */ #endif /* defined(__cplusplus) */
static inline ULONG inline ULONG
Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...) Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
{ {
char szMsg[512]; char szMsg[512];
@ -68,7 +68,18 @@ Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
#endif #endif
#if 1 #if 1
#define FAILED_UNEXPECTEDLY(hr) (FAILED(hr) && (Win32DbgPrint(__FILE__, __LINE__, "Unexpected failure %08x.\n", hr), TRUE))
inline BOOL _ROS_FAILED_HELPER(HRESULT hr, const char* expr, const char* filename, int line)
{
if (FAILED(hr))
{
Win32DbgPrint(filename, line, "Unexpected failure (%s)=%08x.\n", expr, hr);
return TRUE;
}
return FALSE;
}
#define FAILED_UNEXPECTEDLY(hr) _ROS_FAILED_HELPER((hr), #hr, __FILE__, __LINE__)
#else #else
#define FAILED_UNEXPECTEDLY(hr) FAILED(hr) #define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
#endif #endif