[edk2,4/4] BaseTools: fix unused-result build warnings

Message ID 1481784588-35336-5-git-send-email-heyi.guo@linaro.org
State New
Headers show

Commit Message

Heyi Guo Dec. 15, 2016, 6:49 a.m.
Fix build warnings of "ignoring return value of ‘size_t fread(void*,
size_t, size_t, FILE*)’, declared with attribute warn_unused_result
[-Wunused-result]" for BaseTools, while using "gcc version 4.8.4
(Ubuntu 4.8.4-2ubuntu1~14.04.3)".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 3ca57ed..0ba7102 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -3395,7 +3395,9 @@  CVfrStringDB::GetVarStoreNameFormStringId (
     fclose (pInFile);
     return NULL;
   }
-  fread ((char *)StringPtr, sizeof (UINT8), Length, pInFile);
+  // Fix GCC build warning for ignoring return value
+  unsigned long TempResult = fread ((char *)StringPtr, sizeof (UINT8), Length, pInFile);
+  (void)TempResult;
   fclose (pInFile);
 
   PkgHeader = (EFI_HII_STRING_PACKAGE_HDR *) StringPtr;