Make CopyMemC call CopyMem

* The last part of this: I hope :)
* ISO C permits overwriting of Src even if it marks Src as CONST
* UEFI marks Src as NON CONST, so forward calls via this function
* Allows us to keep in-line with shim without causing Werror havoc with other downstreams

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
This commit is contained in:
Callum Farmer 2024-06-03 15:49:20 +01:00
parent c03d395571
commit d9b395ac03
No known key found for this signature in database
GPG Key ID: 9A5B19E18CD0013C
1 changed files with 5 additions and 10 deletions

View File

@ -100,16 +100,11 @@ RtCopyMemC (
IN UINTN len
)
{
CHAR8 *d = (CHAR8*)Dest;
CONST CHAR8 *s = (CONST CHAR8*)Src;
if (d == NULL || s == NULL || s == d)
return;
/* CONST Src: UB if Src and Dest overlap */
while (len--)
*d++ = *s++;
/* CopyMem matches ISO C apart from the change to NON-CONST Src
Overwriting Src is an intended outcome if overlapping occurs (per memmove)
This function is useful to avoid GCC dying in changing pointer setup
*/
RtCopyMem(Dest, (VOID*)Src, len);
}
#ifndef __GNUC__