[yocto] [PATCH V2] rmc: fix allocating buffer issue in read_file() (32 bit)

Jianxun Zhang jianxun.zhang at linux.intel.com
Wed Aug 17 14:56:28 PDT 2016


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.

Signed-off-by: Jianxun Zhang <jianxun.zhang at linux.intel.com>
---
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(-)

diff --git a/inc/rmcl.h b/inc/rmcl.h
index 225c7bd..a7aa2a2 100644
--- a/inc/rmcl.h
+++ b/inc/rmcl.h
@@ -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.
diff --git a/inc/rsmp.h b/inc/rsmp.h
index 90efc8c..c4258cd 100644
--- a/inc/rsmp.h
+++ b/inc/rsmp.h
@@ -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
-- 
2.7.4




More information about the yocto mailing list