Alexei:
  I agree 1) and 2) are issues. But, they should not happen. Before 
UnicodeFiFoRemoveOneKey() is called, while statement has checked 
IsUnicodeFiFoEmpty() to make sure Fifo buffer is not empty. So, 
UnicodeFiFoRemoveOneKey() doesn't enter into Fifo empty case. Do you meet with 
the real problem or just compiler issue?

Line 1202:  while (!IsUnicodeFiFoEmpty (TerminalDevice) && !IsEfiKeyFiFoFull 
(TerminalDevice)) {
Line 1218:      UnicodeFiFoRemoveOneKey (TerminalDevice, &UnicodeChar);

Thanks
Liming
From: Alexei Fedorov [mailto:[email protected]]
Sent: Thursday, January 30, 2014 2:28 AM
To: [email protected]
Subject: [edk2] Bug in TerminalDxe UnicodeFiFoRemoveOneKey() function

I'm getting the following error for TerminalDxe when compiling with -O3 option:

q:\edk2\MdeModulePkg\Universal\Console\TerminalDxe\TerminalConIn.c: In function 
'UnicodeToEfiKey':
q:\edk2\MdeModulePkg\Universal\Console\TerminalDxe\TerminalConIn.c:1571:8: 
error: 'UnicodeChar' may be used uninitialized in this function 
[-Werror=maybe-uninitialized]
     if (UnicodeChar == DEL) {
        ^
cc1.exe: all warnings being treated as errors

1) This is because of the following bug in UnicodeFiFoRemoveOneKey() 
(\edk2\MdeModulePkg\Universal\Console\TerminalDxe\TerminalConIn.c):

BOOLEAN
UnicodeFiFoRemoveOneKey (
  TERMINAL_DEV  *TerminalDevice,
  UINT16        *Output
  )
{
  UINT8 Head;

  Head = TerminalDevice->UnicodeFiFo->Head;
  ASSERT (Head < FIFO_MAX_NUMBER + 1);

  if (IsUnicodeFiFoEmpty (TerminalDevice)) {
    //
    //  FIFO is empty
    //
    Output = NULL;
    return FALSE;
  }

  *Output = TerminalDevice->UnicodeFiFo->Data[Head];

  TerminalDevice->UnicodeFiFo->Head = (UINT8) ((Head + 1) % (FIFO_MAX_NUMBER + 
1));

  return TRUE;
}

Line #968:
    Output = NULL;

should be replaced with

    *Output = 0;

2) line '950: 'FLASE' should be replaced with 'FALSE'
  @retval FLASE                If Unicode FIFO buffer is empty before remove 
operation.


3) Shouldn't the calling UnicodeToEfiKey() function @line #1218:

    //
    // Fetch one Unicode character from the Unicode FIFO
    //
    UnicodeFiFoRemoveOneKey (TerminalDevice, &UnicodeChar);

check return value of UnicodeFiFoRemoveOneKey() for FALSE & return in the case 
if Unicode FIFO buffer is empty?

Alexei.




-- 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.

ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered 
in England & Wales, Company No: 2557590
ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, 
Registered in England & Wales, Company No: 2548782
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to