Skip to content

Commit 121454c

Browse files
lifeixlijinxia
authored andcommitted
hv: fix a minor bug of static checks
When a macro is expanded, the two tokens on either side of each ‘##’ operator are combined into a single token, which then replaces the ‘##’ and the two original tokens in the macro expansion. So we need use CAT__ to expand the __LINE__ MACRO and use CAT_ to combine the expaneded MACRO. Tracked-on: #1750 Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent 0800624 commit 121454c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

hypervisor/arch/x86/static_checks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include <hypervisor.h>
77
#include <vm0_boot.h>
88

9-
#define CAT_(A,B) A ## B
9+
#define CAT__(A,B) A ## B
10+
#define CAT_(A,B) CAT__(A,B)
1011
#define CTASSERT(expr) \
1112
typedef int CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1]
1213

hypervisor/common/static_checks.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66
#include <acrn_common.h>
77

8-
#define CAT_(A,B) A ## B
8+
#define CAT__(A,B) A ## B
9+
#define CAT_(A,B) CAT__(A,B)
910
#define CTASSERT(expr) \
1011
typedef int CAT_(CTA_DummyType,__LINE__)[(expr) ? 1 : -1]
1112

0 commit comments

Comments
 (0)