Fix InternalMemScanMem* functions so that they return the pointer to the matched object, as specified, instead of the following object.

Replaces the fix instituted in rev. 10821 with a more understandable, sustainable, and efficient fix that behaves the same regardless of compiler.

Reviewed by two peers.
Fixes HSD tracker 204556.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11237 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
darylm503 2011-01-07 23:00:16 +00:00
parent 2183cf2353
commit af072124e4
1 changed files with 12 additions and 8 deletions

View File

@ -162,9 +162,10 @@ InternalMemScanMem8 (
Pointer = (CONST UINT8*)Buffer; Pointer = (CONST UINT8*)Buffer;
do { do {
if (*(Pointer++) == Value) { if (*Pointer == Value) {
return --Pointer; return Pointer;
} }
++Pointer;
} while (--Length != 0); } while (--Length != 0);
return NULL; return NULL;
} }
@ -192,9 +193,10 @@ InternalMemScanMem16 (
Pointer = (CONST UINT16*)Buffer; Pointer = (CONST UINT16*)Buffer;
do { do {
if (*(Pointer++) == Value) { if (*Pointer == Value) {
return --Pointer; return Pointer;
} }
++Pointer;
} while (--Length != 0); } while (--Length != 0);
return NULL; return NULL;
} }
@ -222,9 +224,10 @@ InternalMemScanMem32 (
Pointer = (CONST UINT32*)Buffer; Pointer = (CONST UINT32*)Buffer;
do { do {
if (*(Pointer++) == Value) { if (*Pointer == Value) {
return --Pointer; return Pointer;
} }
++Pointer;
} while (--Length != 0); } while (--Length != 0);
return NULL; return NULL;
} }
@ -252,9 +255,10 @@ InternalMemScanMem64 (
Pointer = (CONST UINT64*)Buffer; Pointer = (CONST UINT64*)Buffer;
do { do {
if (*(Pointer++) == Value) { if (*Pointer == Value) {
return --Pointer; return Pointer;
} }
++Pointer;
} while (--Length != 0); } while (--Length != 0);
return NULL; return NULL;
} }