From 632fad9a5e2f4b7db41c405ab5f48ea19e1e18a9 Mon Sep 17 00:00:00 2001 From: Mike Crowe Date: Wed, 12 Jan 2022 09:26:42 +0000 Subject: [PATCH] HelloWorld: Use ConsolePrint to simplify code and fix GCC build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AsciiSprint takes a CHAR8 buffer to write to whereas ConsoleWrite expects a UINT8 buffer. This causes GCC to complain: /.../sources/slimbootloader/PayloadPkg/HelloWorld/HelloWorld.c: In function ‘PayloadMain’: /.../sources/slimbootloader/PayloadPkg/HelloWorld/HelloWorld.c:36:25: error: pointer targets in passing argument 1 of ‘ConsoleWrite’ differ in signedness [-Werror=pointer-sign] 36 | ConsoleWrite (Message, Len); | ^~~~~~~ | | | CHAR8 * {aka char *} In file included from /.../sources/slimbootloader/PayloadPkg/HelloWorld/HelloWorld.h:18, from /.../sources/slimbootloader/PayloadPkg/HelloWorld/HelloWorld.c:8: /.../sources/slimbootloader/BootloaderCommonPkg/Include/Library/ConsoleOutLib.h:103:17: note: expected ‘UINT8 *’ {aka ‘unsigned char *’} but argument is of type ‘CHAR8 *’ {aka ‘char *’} 103 | IN UINT8 *Buffer, | ~~~~~~~~~~~^~~~~~ Let's avoid the whole problem and simplify the code too by just calling ConsolePrint instead. Signed-off-by: Mike Crowe --- PayloadPkg/HelloWorld/HelloWorld.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/PayloadPkg/HelloWorld/HelloWorld.c b/PayloadPkg/HelloWorld/HelloWorld.c index 9b3dbf93..6dd97ab2 100644 --- a/PayloadPkg/HelloWorld/HelloWorld.c +++ b/PayloadPkg/HelloWorld/HelloWorld.c @@ -22,8 +22,6 @@ PayloadMain ( ) { UINT8 Key; - CHAR8 Message[64]; - UINTN Len; DEBUG ((DEBUG_INFO, "\n\n==================== Hello World ====================\n\n")); @@ -32,8 +30,7 @@ PayloadMain ( if (ConsolePoll ()) { if (ConsoleRead (&Key, 1) > 0) { if ((Key >= 0x20) && (Key < 0x7F)) { - Len = AsciiSPrint (Message, sizeof (Message), "Key '%c' pressed !\n", Key); - ConsoleWrite (Message, Len); + ConsolePrint("Key '%c' pressed !\n", Key); } } }