Harden Windows macros against dangling-else ambiguity (#41513)
* Harden Windows macros against dangling-else ambiguity * Harden Windows macros against dangling-else ambiguity
Eamon committed
Sep 4, 2026 at 01:12 UTC
4896a6968f924a1bc35b56e93d07074ab7d6137e
1 file changed
+12
-6
src/windows/common/ExecutionContext.h
+12
-6
@@ -29,16 +29,22 @@ namespace wsl::windows::common {
29
} while (false);
30
31
#define THROW_HR_WITH_USER_ERROR_IF(Result, Message, Condition) \
32
- if (Condition) \
32
+ do \
33
{ \
34
- THROW_HR_WITH_USER_ERROR(Result, Message); \
35
- }
34
+ if (Condition) \
35
+ { \
36
+ THROW_HR_WITH_USER_ERROR(Result, Message); \
37
+ } \
38
+ } while (false);
39
40
#define EMIT_USER_WARNING(Warning) \
38
- if (::wsl::windows::common::ExecutionContext* context = ::wsl::windows::common::ExecutionContext::Current(); context != nullptr) \
41
+ do \
42
{ \
40
- context->EmitUserWarning(Warning); \
41
- }
43
+ if (::wsl::windows::common::ExecutionContext* context = ::wsl::windows::common::ExecutionContext::Current(); context != nullptr) \
44
+ { \
45
+ context->EmitUserWarning(Warning); \
46
+ } \
47
+ } while (false);
48
49
/* List of ExecutionContext that can be passed to ExecutionContext().
50
* Note: ExecutionContext makes the assumption that the parent context always has