Re: [edk2] UnicodeVSPrint returns nonsense string length

Subject: Re: [edk2] UnicodeVSPrint returns nonsense string length

From: Jordan Justen <jljusten@gmail.com>

To: edk2-devel@lists.sourceforge.net

Date: 2012-10-23 16:44:56

On Tue, Oct 23, 2012 at 5:43 AM, duck wilson  wrote:
> UnicodeVSPrint is not returning the correct (expected) string length. The
> simple program below demonstrates
> the problem. The build environment is UDK2010.SR1.UP1. This demo was built
> as a module in MdeModulePkg.
> When the demo program is run the output is:
>
> fooprint:Count: 6
> Count = 6
> fooprint:Count: 127
> Count = 127
> fooprint:Count: 127
> Count = 127
>
> Any recommendations? I am not seeing any problem with the code so I have no
> idea what is going on.
> (This has led to a mind-bend debug exercise in live code due to pointer
> arithmetic not being as intended...pfew!)

Are you using GCC44~GCC46? If so, you might be seeing a mismatch in
parameter calling conventions. Can you try adding EFIAPI to fooprint?

The VA_* macros assume EFIAPI...

-Jordan

>
> TIA!
>
> -------- Vprint.c --------
>
> #include 
> #include 
> #include 
> #include 
>
> CHAR16  Buffer[128];
> CHAR16  String1[] = L"a string";
> CHAR16  String2[] = L"a longer string";
> CHAR16  String3[] = L"an even longer string";
>
> UINTN
> fooprint (
>   IN  CONST CHAR16  *Format,
>   ...
>   )
> {
>   UINTN       Count;
>   VA_LIST     Marker;
>
>   VA_START (Marker, Format);
>   Count = UnicodeVSPrint (Buffer, sizeof Buffer, Format, Marker);
>   VA_END (Marker);
>   Print (L"fooprint:Count: %d\n", Count);
>   return Count;
> }
>
> EFI_STATUS
> EFIAPI
> UefiMain (
>   IN EFI_HANDLE        ImageHandle,
>   IN EFI_SYSTEM_TABLE  *SystemTable
>   )
> {
>   UINTN   Count;
>
>   Count = fooprint (L"%s", String1);
>   Print (L"Count = %d\n", Count);
>   Count = fooprint (L"%s", String2);
>   Print (L"Count = %d\n", Count);
>   Count = fooprint (L"%s", String3);
>   Print (L"Count = %d\n", Count);
>
>   return EFI_SUCCESS;
> }
>
> -------- Vprint.inf --------
>
> [Defines]
>   INF_VERSION                    = 0x00010005
>   BASE_NAME                      = Vprint
>   FILE_GUID                      = f9bfca86-a0b5-41f8-ba8a-1f2e9428ec06
>   MODULE_TYPE                    = UEFI_APPLICATION
>   VERSION_STRING                 = 1.0
>   ENTRY_POINT                    = UefiMain
>
>
> [Sources]
>   Vprint.c
>
> [Packages]
>   MdePkg/MdePkg.dec
>   MdeModulePkg/MdeModulePkg.dec
>
> [LibraryClasses]
>   UefiApplicationEntryPoint
>   UefiLib
>   PrintLib
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel