From 5272da2e7b371fee2e54dc8282e27c61a22bcf36 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Thu, 26 May 2022 12:53:50 +0900 Subject: [PATCH] Add comments on trailing uint8[1] members in the "Common" structures (#1189) Add comments to avoid abusing these members to store extra data. --- core/iwasm/common/wasm_runtime_common.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/iwasm/common/wasm_runtime_common.h b/core/iwasm/common/wasm_runtime_common.h index cc172f99c..afea574e3 100644 --- a/core/iwasm/common/wasm_runtime_common.h +++ b/core/iwasm/common/wasm_runtime_common.h @@ -303,6 +303,11 @@ typedef struct WASMModuleCommon { Wasm_Module_AoT, and this structure should be treated as AOTModule structure. */ uint32 module_type; + + /* The following uint8[1] member is a dummy just to indicate + some module_type dependent members follow. + Typically it should be accessed by casting to the corresponding + actual module_type dependent structure, not via this member. */ uint8 module_data[1]; } WASMModuleCommon; @@ -314,6 +319,11 @@ typedef struct WASMModuleInstanceCommon { Wasm_Module_AoT, and this structure should be treated as AOTModuleInstance structure. */ uint32 module_type; + + /* The following uint8[1] member is a dummy just to indicate + some module_type dependent members follow. + Typically it should be accessed by casting to the corresponding + actual module_type dependent structure, not via this member. */ uint8 module_inst_data[1]; } WASMModuleInstanceCommon; @@ -377,6 +387,11 @@ typedef struct WASMRegisteredModule { typedef struct WASMMemoryInstanceCommon { uint32 module_type; + + /* The following uint8[1] member is a dummy just to indicate + some module_type dependent members follow. + Typically it should be accessed by casting to the corresponding + actual module_type dependent structure, not via this member. */ uint8 memory_inst_data[1]; } WASMMemoryInstanceCommon;