mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-28 16:14:04 +02:00
MdePkg/MemoryLib: Refine InternalMemSetMem16|32|64 functions logic
This commit refines the logic for InternalMemSetMem16|32|64 functions. It avoids using the decrement operator '--' for array index to prevent possible mis-reports by static code checkers. Please note that those modified functions are only consumed within MemoryLib by APIs SetMem16|32|64, and those APIs will handle the case when the input number of bytes to set is 0. Hence, the behavior of APIs SetMem16|32|64 is not changed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
This commit is contained in:
parent
753a18f965
commit
9088c61e2d
@ -37,9 +37,9 @@ InternalMemSetMem16 (
|
|||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT16*)Buffer)[--Length] = Value;
|
((UINT16*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ InternalMemSetMem32 (
|
|||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT32*)Buffer)[--Length] = Value;
|
((UINT32*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,9 +85,9 @@ InternalMemSetMem64 (
|
|||||||
IN UINT64 Value
|
IN UINT64 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT64*)Buffer)[--Length] = Value;
|
((UINT64*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ InternalMemSetMem16 (
|
|||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT16*)Buffer)[--Length] = Value;
|
((UINT16*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ InternalMemSetMem32 (
|
|||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT32*)Buffer)[--Length] = Value;
|
((UINT32*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,9 +85,9 @@ InternalMemSetMem64 (
|
|||||||
IN UINT64 Value
|
IN UINT64 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT64*)Buffer)[--Length] = Value;
|
((UINT64*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ InternalMemSetMem16 (
|
|||||||
IN UINT16 Value
|
IN UINT16 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT16*)Buffer)[--Length] = Value;
|
((UINT16*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ InternalMemSetMem32 (
|
|||||||
IN UINT32 Value
|
IN UINT32 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT32*)Buffer)[--Length] = Value;
|
((UINT32*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,9 +85,9 @@ InternalMemSetMem64 (
|
|||||||
IN UINT64 Value
|
IN UINT64 Value
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
do {
|
for (; Length != 0; Length--) {
|
||||||
((UINT64*)Buffer)[--Length] = Value;
|
((UINT64*)Buffer)[Length - 1] = Value;
|
||||||
} while (Length != 0);
|
}
|
||||||
return Buffer;
|
return Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user