Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id E11CFE00FA4; Wed, 17 Aug 2016 14:54:11 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high * trust * [134.134.136.65 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 5FCF1E00F8D for ; Wed, 17 Aug 2016 14:54:08 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 17 Aug 2016 14:54:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,535,1464678000"; d="scan'208";a="1016235525" Received: from chang-s2600cp.jf.intel.com ([10.54.77.22]) by orsmga001.jf.intel.com with ESMTP; 17 Aug 2016 14:54:09 -0700 From: Jianxun Zhang To: yocto@yoctoproject.org Date: Wed, 17 Aug 2016 14:56:28 -0700 Message-Id: <1471470988-9734-1-git-send-email-jianxun.zhang@linux.intel.com> X-Mailer: git-send-email 2.7.4 Subject: [PATCH V2] rmc: fix allocating buffer issue in read_file() (32 bit) X-BeenThere: yocto@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Discussion of all things Yocto Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2016 21:54:12 -0000 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 --- 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 #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 -#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