From 550d36dca3cdec84d47f05711c2569990d3b4708 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Thu, 25 Aug 2016 19:27:04 +1000 Subject: [PATCH 05/10] error: dereferencing type-punned pointer will break strict-aliasing rules Change-Id: I63accd3e881c941736ece4b4498c2c9d06ff8761 Signed-off-by: Stewart Smith --- src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdAttr.H | 7 +++++++ .../usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.H | 1 - src/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.C | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdAttr.H b/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdAttr.H index e5af2c9..7edf2bf 100755 --- a/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdAttr.H +++ b/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdAttr.H @@ -227,6 +227,13 @@ namespace getAttrData uint8_t iv_systemType; uint8_t iv_systemType_ext; uint8_t iv_dataVersion; + public: + MBvpdVMKeyword() : iv_version(0),iv_systemType(0), + iv_systemType_ext(0),iv_dataVersion(0) {}; + operator uint32_t() const { + return iv_version << 24 | iv_systemType << 16 | + iv_systemType_ext << 8 | iv_dataVersion; + } }; // Attribute definition struct MBvpdAttrDef diff --git a/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.H b/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.H index f172508..85460b2 100644 --- a/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.H +++ b/src/include/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.H @@ -33,7 +33,6 @@ #define _HWP_GETMBVPDMEMDATAVERSION_ #include -#define VM_KEYWORD_DEFAULT_VALUE 0x00000000 // function pointer typedef definition for HWP call support typedef fapi::ReturnCode (*getMBvpdMemoryDataVersion_FP_t) diff --git a/src/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.C b/src/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.C index 2f83fa2..ef64515 100644 --- a/src/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.C +++ b/src/usr/hwpf/hwp/mvpd_accessors/getMBvpdMemoryDataVersion.C @@ -50,7 +50,7 @@ fapi::ReturnCode getMBvpdMemoryDataVersion( fapi::ReturnCode l_fapirc; DimmType l_dimmType = ISDIMM; fapi::MBvpdRecord l_record = fapi::MBVPD_RECORD_SPDX; - uint32_t l_vpdMemoryDataVersion = VM_KEYWORD_DEFAULT_VALUE; + MBvpdVMKeyword l_vpdMemoryDataVersion; uint32_t l_bufSize = sizeof(l_vpdMemoryDataVersion); FAPI_DBG("getMBvpdMemoryDataVersion: entry "); @@ -140,8 +140,8 @@ fapi::ReturnCode getMBvpdMemoryDataVersion( } // Check if the format byte in the value returned is in between valid range - if (( ((MBvpdVMKeyword *)(&l_vpdMemoryDataVersion))->iv_version > VM_SUPPORTED_HIGH_VER )|| - ( ((MBvpdVMKeyword *)(&l_vpdMemoryDataVersion))->iv_version == VM_NOT_SUPPORTED )) + if ((l_vpdMemoryDataVersion.iv_version > VM_SUPPORTED_HIGH_VER )|| + (l_vpdMemoryDataVersion.iv_version == VM_NOT_SUPPORTED )) { FAPI_ERR("getMBvpdMemoryDataVersion:" " keyword data returned is invalid : %d ", -- 2.7.4