]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmLib: Fix compilation error with -O3 switch
authorOlivier Martin <olivier.martin@arm.com>
Sat, 1 Mar 2014 10:59:25 +0000 (10:59 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 1 Mar 2014 10:59:25 +0000 (10:59 +0000)
A warning is reported because ArmArchTimerReadReg may theoretically result
in an unititialised value.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15275 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/ArmLib/ArmV7/ArmV7ArchTimer.c

index d04211b29d34600fbb4eb53bd0acb66c7ea38068..fd82ef927bb29801e5181dfd02d400a9d188c36d 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.\r
 *  \r
 *  This program and the accompanying materials                          \r
 *  are licensed and made available under the terms and conditions of the BSD License         \r
@@ -12,7 +12,7 @@
 *\r
 **/\r
 \r
-#include <Uefi.h> \r
+#include <Uefi.h>\r
 #include <Chipset/ArmV7.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
@@ -32,58 +32,56 @@ ArmArchTimerReadReg (
 {\r
   // Check if the Generic/Architecture timer is implemented\r
   if (ArmIsArchTimerImplemented ()) {\r
-\r
     switch (Reg) {\r
-\r
     case CntFrq:\r
       *((UINTN *)DstBuf) = ArmReadCntFrq ();\r
-      break;\r
+      return;\r
 \r
     case CntPct:\r
       *((UINT64 *)DstBuf) = ArmReadCntPct ();\r
-      break;\r
+      return;\r
 \r
     case CntkCtl:\r
       *((UINTN *)DstBuf) = ArmReadCntkCtl();\r
-      break;\r
+      return;\r
 \r
     case CntpTval:\r
       *((UINTN *)DstBuf) = ArmReadCntpTval ();\r
-      break;\r
+      return;\r
 \r
     case CntpCtl:\r
       *((UINTN *)DstBuf) = ArmReadCntpCtl ();\r
-      break;\r
+      return;\r
 \r
     case CntvTval:\r
       *((UINTN *)DstBuf) = ArmReadCntvTval ();\r
-      break;\r
+      return;\r
 \r
     case CntvCtl:\r
       *((UINTN *)DstBuf) = ArmReadCntvCtl ();\r
-      break;\r
+      return;\r
 \r
     case CntvCt:\r
       *((UINT64 *)DstBuf) = ArmReadCntvCt ();\r
-      break;\r
+      return;\r
 \r
     case CntpCval:\r
       *((UINT64 *)DstBuf) = ArmReadCntpCval ();\r
-      break;\r
+      return;\r
 \r
     case CntvCval:\r
       *((UINT64 *)DstBuf) = ArmReadCntvCval ();\r
-      break;\r
+      return;\r
 \r
     case CntvOff:\r
       *((UINT64 *)DstBuf) = ArmReadCntvOff ();\r
-      break;\r
+      return;\r
 \r
     case CnthCtl:\r
     case CnthpTval:\r
     case CnthpCtl:\r
     case CnthpCval:\r
-    DEBUG ((EFI_D_ERROR, "The register is related to Hypervisor Mode. Can't perform requested operation\n "));\r
+      DEBUG ((EFI_D_ERROR, "The register is related to Hypervisor Mode. Can't perform requested operation\n "));\r
       break;\r
 \r
     default:\r
@@ -93,6 +91,8 @@ ArmArchTimerReadReg (
     DEBUG ((EFI_D_ERROR, "Attempt to read ARM Generic Timer registers. But ARM Generic Timer extension is not implemented \n "));\r
     ASSERT (0);\r
   }\r
+\r
+  *((UINT64 *)DstBuf) = 0;\r
 }\r
 \r
 VOID\r
@@ -208,7 +208,7 @@ ArmArchTimerGetTimerFreq (
     VOID\r
     )\r
 {\r
-  UINTN ArchTimerFreq = 0;\r
+  UINTN ArchTimerFreq;\r
   ArmArchTimerReadReg (CntFrq, (VOID *)&ArchTimerFreq);\r
   return ArchTimerFreq;\r
 }\r