From 0ccabf7bab741234721a8ee78113ef191c0ce8d5 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Sat, 12 Jun 2010 03:14:26 +0000 Subject: [PATCH] Initialize the local variable before refer to them. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10577 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Foundation/Library/Dxe/Graphics/Print.c | 6 ++++-- .../Foundation/Library/Dxe/GraphicsLite/Print.c | 10 ++++++---- .../BaseUefiDecompressLib/BaseUefiDecompressLib.c | 4 ++-- .../Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c | 9 ++++++++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c index 03b66623c9..91f3aaffb5 100644 --- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Graphics/Print.c @@ -188,6 +188,7 @@ Returns: // // For now, allocate an arbitrarily long buffer // + BufferLen = 0; Buffer = EfiLibAllocateZeroPool (0x10000); if (Buffer == NULL) { return 0; @@ -428,14 +429,15 @@ Returns: Handle = gST->ConsoleOutHandle; + GraphicsOutput = NULL; + UgaDraw = NULL; Status = gBS->HandleProtocol ( Handle, &gEfiGraphicsOutputProtocolGuid, (VOID**)&GraphicsOutput ); - UgaDraw = NULL; - if (EFI_ERROR (Status)) { + if (EFI_ERROR (Status) || (GraphicsOutput == NULL)) { GraphicsOutput = NULL; Status = gBS->HandleProtocol ( diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c index 5b815e610e..0988cc2f30 100644 --- a/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c +++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c @@ -155,6 +155,7 @@ Returns: // // For now, allocate an arbitrarily long buffer // + BufferLen = 0; Buffer = EfiLibAllocateZeroPool (0x10000); if (Buffer == NULL) { return 0; @@ -394,14 +395,15 @@ Returns: Handle = gST->ConsoleOutHandle; + GraphicsOutput = NULL; + UgaDraw = NULL; Status = gBS->HandleProtocol ( Handle, &gEfiGraphicsOutputProtocolGuid, (VOID **) &GraphicsOutput ); - UgaDraw = NULL; - if (EFI_ERROR (Status)) { + if (EFI_ERROR (Status) || (GraphicsOutput == NULL)) { GraphicsOutput = NULL; Status = gBS->HandleProtocol ( @@ -410,7 +412,7 @@ Returns: (VOID **) &UgaDraw ); - if (EFI_ERROR (Status) || (UgaDraw != NULL)) { + if (EFI_ERROR (Status) || (UgaDraw == NULL)) { return 0; } } @@ -422,7 +424,7 @@ Returns: (VOID **) &Sto ); - if (EFI_ERROR (Status) || (Sto != NULL)) { + if (EFI_ERROR (Status) || (Sto == NULL)) { return 0; } diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c index 30ec41769e..cc491238fe 100644 --- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c +++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c @@ -155,7 +155,7 @@ GlueMakeTable ( // // TableBits should not be greater than 16. // - if (TableBits >= (sizeof (Count)/sizeof (UINT16))) { + if (TableBits > 16) { return (UINT16) BAD_TABLE; } @@ -170,7 +170,7 @@ GlueMakeTable ( // // Count array index should not be greater than or equal to its size. // - if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) { + if (BitLen[Index] <= 16) { Count[BitLen[Index]]++; } else { return (UINT16) BAD_TABLE; diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c index f73323cf5f..2a52906fc1 100644 --- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c +++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2004, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -42,6 +42,7 @@ Returns: { UINT8 Buffer; + Buffer = 0; EfiIoRead (EfiCpuIoWidthUint8, Address, 1, &Buffer); return Buffer; } @@ -65,6 +66,7 @@ Returns: { UINT16 Buffer; + Buffer = 0; EfiIoRead (EfiCpuIoWidthUint16, Address, 1, &Buffer); return Buffer; } @@ -88,6 +90,7 @@ Returns: { UINT32 Buffer; + Buffer = 0; EfiIoRead (EfiCpuIoWidthUint32, Address, 1, &Buffer); return Buffer; } @@ -177,6 +180,7 @@ Returns: { UINT8 Buffer; + Buffer = 0; EfiMemRead (EfiCpuIoWidthUint8, Address, 1, &Buffer); return Buffer; } @@ -200,6 +204,7 @@ Returns: { UINT16 Buffer; + Buffer = 0; EfiMemRead (EfiCpuIoWidthUint16, Address, 1, &Buffer); return Buffer; } @@ -223,6 +228,7 @@ Returns: { UINT32 Buffer; + Buffer = 0; EfiMemRead (EfiCpuIoWidthUint32, Address, 1, &Buffer); return Buffer; } @@ -246,6 +252,7 @@ Returns: { UINT64 Buffer; + Buffer = 0; EfiMemRead (EfiCpuIoWidthUint64, Address, 1, &Buffer); return Buffer; }