Dear MdePkg maintainers,

I think this is terribly wrong
----
edk2\mdepkg\library\baselib\x86fxsave.c(47) : warning C6305: Potential mismatch 
between sizeof and countof quantities. Use sizeof() to scale byte sizes.: 
Lines: 42, 47
-----
Look
----------
VOID
EFIAPI
AsmFxSave (
  OUT     IA32_FX_BUFFER            *Buffer
  )
{
  ASSERT (Buffer != NULL);
  ASSERT (0 == ((UINTN)Buffer & 0xf));

  InternalX86FxSave (Buffer);

  //
  // Mark one flag at end of Buffer, it will be check by AsmFxRestor()
  //
  *(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) = 0xAA5555AA;
}

----------
But the definition of the type is follow (BaseLib.h)
-----------
///
/// Byte packed structure for an FP/SSE/SSE2 context.
///
typedef struct {
  UINT8  Buffer[512];
} IA32_FX_BUFFER;

-----------
It is not byte array, this is a structure!!! So Buffer in the procedure 
AsmFxSave is an array of… structures!
Buffer[sizeof (IA32_FX_BUFFER) - 4] will have very other address then expected
I think it will be better to write 
-----------
*(UINT32 *) (&Buffer->Buffer[sizeof (IA32_FX_BUFFER) - 4]) = 0xAA5555AA;
-----------

Am I right?
Sergey
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to