Greeting,

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!)

TIA!

-------- Vprint.c --------

#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/PrintLib.h>

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to