rmc: fix allocating buffer issue in read_file() (32 bit)
PATCH v2 1/1 rmc: fix allocating buffer issue in read_file() (32 bit)
Runtime test script failed on T100TA (32 bit) machine because read_file() function in rmc.c gets a wrong value of st_size from the buffer returned by stat(). We include rmc header files prior to the rest of standard header files in rmc.c, so standard data subsequently defined could be affected by "#pragma pack(1)" in rmc header files.
We save and restore the previous pragma pack setting in rmc header files to fix this issue.
Runtime test passes on T100TA and other two boards with this change.
---
This V2 addresses Khem's suggestion to restore the previous setting of pack, so order of header files won't matter.
V2 generates identical binaries as V1, without reordering header files in rmc.c. Test's skipped.
inc/rmcl.h | 4 +++- inc/rsmp.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
inc/rmcl.h +3 -1
@@ -14,7 +14,7 @@#include <stdlib.h> #endif -#pragma pack(1) +#pragma pack(push, 1)/* * RMC Fingerprint
@@ -131,6 +131,8 @@ typedef struct rmc_record_file {struct rmc_record_file *next;/* next rmc record file, or null as terminator for the last element */ } rmc_record_file_t; +#pragma pack(pop) +/* * Generate RMC record file (This function allocate memory) * (in) fingerprint : fingerprint of board, usually generated by rmc tool with rsmp.
inc/rsmp.h +3 -1
@@ -8,7 +8,7 @@#include <rmcl.h> -#pragma pack(1) +#pragma pack(push, 1)/* * SMBIOS Entry Point Structure
@@ -60,6 +60,8 @@ typedef struct smbios_struct_hdr {#define SMBIOS_ENTRY_TAB_LEN sizeof(smbios_ep_t) +#pragma pack(pop) +/* * get smbios structure start address and total len * (in) start: pointer of smbios entry table address
Signature · 1 line
2.7.4