Hi Hongyan,
On 27/02/2020 11:59, Xia, Hongyan wrote:
On Thu, 2020-02-27 at 11:51 +0000, Julien Grall wrote:
Hi Hongyan,
On 27/02/2020 10:27, Hongyan Xia wrote:
...
diff --git a/xen/include/xen/domain_page.h
b/xen/include/xen/domain_page.h
index 32669a3339..bfc3bf6aeb 100644
--- a/xen/include/xen/domain_page.h
+++ b/xen/include/xen/domain_page.h
@@ -72,4 +72,11 @@ static inline void
unmap_domain_page_global(const void *va) {};
#endif /* !CONFIG_DOMAIN_PAGE */
+#define UNMAP_DOMAIN_PAGE(p) do { \
+ if ( p ) { \
+ unmap_domain_page(p); \
+ (p) = NULL; \
+ } \
+} while ( false )
Do we need to keep the do {} while ()?
I think we do. For example:
if ( cond )
UNMAP_DOMAIN_PAGE(p);
else
blah_blah_blah();
If we remove the do-while, the else clause will be paired with the if
in UNMAP_DOMAIN_PAGE();
GCC will actually throw a compiler error:
test.c: In function ‘f’:
test.c:13:5: error: ‘else’ without a previous ‘if’
else
^~~~
Anyway, yes we do need to keep do while {} to catch any use without the
semicolon. Sorry for the noise.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel