<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top: 0px; margin-bottom: 0px;margin-top:0px; margin-bottom:0px">
Alexei<br>
</p>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Sami Mujawar <sami.mujawar@arm.com><br>
<b>Sent:</b> 23 August 2019 11:55<br>
<b>To:</b> devel@edk2.groups.io <devel@edk2.groups.io><br>
<b>Cc:</b> Sami Mujawar <Sami.Mujawar@arm.com>; Alexei Fedorov <Alexei.Fedorov@arm.com>; ard.biesheuvel@linaro.org <ard.biesheuvel@linaro.org>; leif.lindholm@linaro.org <leif.lindholm@linaro.org>; Matteo Carlini <Matteo.Carlini@arm.com>; michael.d.kinney@intel.com
 <michael.d.kinney@intel.com>; liming.gao@intel.com <liming.gao@intel.com>; nd <nd@arm.com><br>
<b>Subject:</b> [PATCH v1 19/19] MdePkg: Initialise VA_LIST variables before use</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">The VS2017 compiler reports 'warning C6001: Using<br>
uninitialized memory 'Marker'.' for VA_LIST<br>
variables.<br>
<br>
To fix this issue declare a VA_LIST global variable<br>
and use this to initialise VA_LIST variables before<br>
use.<br>
<br>
Note: The VA_LIST cannot be assigned a NULL value<br>
because some compilers define VA_LIST to be a<br>
structure.<br>
<br>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com><br>
---<br>
 MdePkg/Library/BaseLib/SwitchStack.c           | 9 +++++++++<br>
 MdePkg/Library/BasePrintLib/PrintLib.c         | 5 +++++<br>
 MdePkg/Library/BasePrintLib/PrintLibInternal.c | 9 +++++++++<br>
 3 files changed, 23 insertions(+)<br>
<br>
diff --git a/MdePkg/Library/BaseLib/SwitchStack.c b/MdePkg/Library/BaseLib/SwitchStack.c<br>
index cb9f69f1eaceba690b48e9ca6b8a9af2e348bddd..e1bb524819b3de3521c5461ce681aa3a6c186f2c 100644<br>
--- a/MdePkg/Library/BaseLib/SwitchStack.c<br>
+++ b/MdePkg/Library/BaseLib/SwitchStack.c<br>
@@ -2,12 +2,20 @@<br>
   Switch Stack functions.<br>
 <br>
   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR><br>
+  Copyright (c) 2019, ARM Ltd. All rights reserved.<BR><br>
   SPDX-License-Identifier: BSD-2-Clause-Patent<br>
 <br>
 **/<br>
 <br>
 #include "BaseLibInternals.h"<br>
 <br>
+//<br>
+// Declare a VA_LIST global variable that is used to initialise VA_LIST<br>
+// variables before use. The VA_LIST cannot be assigned a NULL value<br>
+// because some compilers define VA_LIST to be a structure.<br>
+//<br>
+STATIC VA_LIST gNullVaList;<br>
+<br>
 /**<br>
   Transfers control to a function starting with a new stack.<br>
 <br>
@@ -57,6 +65,7 @@ SwitchStack (<br>
   //<br>
   ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);<br>
 <br>
+  Marker = gNullVaList;<br>
   VA_START (Marker, NewStack);<br>
 <br>
   InternalSwitchStack (EntryPoint, Context1, Context2, NewStack, Marker);<br>
diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c<br>
index af771652e4b0aebd616973ba1089ae5bc2b6f0c0..67c5f3dd547cea5447075ef88d697879883ba5ab 100644<br>
--- a/MdePkg/Library/BasePrintLib/PrintLib.c<br>
+++ b/MdePkg/Library/BasePrintLib/PrintLib.c<br>
@@ -3,6 +3,7 @@<br>
 <br>
   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR><br>
   Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR><br>
+  Copyright (c) 2019, ARM Ltd. All rights reserved.<BR><br>
   SPDX-License-Identifier: BSD-2-Clause-Patent<br>
 <br>
 **/<br>
@@ -177,6 +178,7 @@ UnicodeSPrint (<br>
   VA_LIST Marker;<br>
   UINTN   NumberOfPrinted;<br>
 <br>
+  Marker = gNullVaList;<br>
   VA_START (Marker, FormatString);<br>
   NumberOfPrinted = UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);<br>
   VA_END (Marker);<br>
@@ -337,6 +339,7 @@ UnicodeSPrintAsciiFormat (<br>
   VA_LIST Marker;<br>
   UINTN   NumberOfPrinted;<br>
 <br>
+  Marker = gNullVaList;<br>
   VA_START (Marker, FormatString);<br>
   NumberOfPrinted = UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);<br>
   VA_END (Marker);<br>
@@ -614,6 +617,7 @@ AsciiSPrint (<br>
   VA_LIST Marker;<br>
   UINTN   NumberOfPrinted;<br>
 <br>
+  Marker = gNullVaList;<br>
   VA_START (Marker, FormatString);<br>
   NumberOfPrinted = AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);<br>
   VA_END (Marker);<br>
@@ -774,6 +778,7 @@ AsciiSPrintUnicodeFormat (<br>
   VA_LIST Marker;<br>
   UINTN   NumberOfPrinted;<br>
 <br>
+  Marker = gNullVaList;<br>
   VA_START (Marker, FormatString);<br>
   NumberOfPrinted = AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);<br>
   VA_END (Marker);<br>
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c<br>
index b6ec5ac4fbb98982f8ccaf3908c2a91ce583e31e..11392f2a5d12eb059611c3ff77b27b602f9b9a40 100644<br>
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c<br>
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c<br>
@@ -2,12 +2,20 @@<br>
   Print Library internal worker functions.<br>
 <br>
   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR><br>
+  Copyright (c) 2019, ARM Ltd. All rights reserved.<BR><br>
   SPDX-License-Identifier: BSD-2-Clause-Patent<br>
 <br>
 **/<br>
 <br>
 #include "PrintLibInternal.h"<br>
 <br>
+//<br>
+// Declare a VA_LIST global variable that is used to initialise VA_LIST<br>
+// variables before use. The VA_LIST cannot be assigned a NULL value<br>
+// because some compilers define VA_LIST to be a structure.<br>
+//<br>
+extern VA_LIST gNullVaList;<br>
+<br>
 #define WARNING_STATUS_NUMBER         5<br>
 #define ERROR_STATUS_NUMBER           33<br>
 <br>
@@ -1256,6 +1264,7 @@ BasePrintLibSPrint (<br>
   VA_LIST  Marker;<br>
   UINTN    NumberOfPrinted;<br>
 <br>
+  Marker = gNullVaList;<br>
   VA_START (Marker, FormatString);<br>
   NumberOfPrinted = BasePrintLibSPrintMarker (StartOfBuffer, BufferSize, Flags, FormatString, Marker, NULL);<br>
   VA_END (Marker);<br>
-- <br>
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'<br>
<br>
<br>
</div>
</span></font></div>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose,
 or store or copy the information in any medium. Thank you.
</body>
</html>

<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>

You receive all messages sent to this group.


<p>

<a target="_blank" href="https://edk2.groups.io/g/devel/message/46283">View/Reply Online (#46283)</a> |


  


|


  
    <a target="_blank" href="https://groups.io/mt/32999803/1813853">Mute This Topic</a>
  

| <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>



<br>

<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>