From: Hao Wu Date: Tue, 15 Nov 2016 08:12:30 +0000 (+0800) Subject: MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic X-Git-Tag: edk2-stable201903~4885 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=81a108434041f6bed629123922772279d98d91a8 MdeModulePkg/UefiPxeBcDxe: Refine the CvtNum function logic This commit refines the logic for the CvtNum function. It avoids using the decrement operator '--' for array index to prevent possible mis-reports by static code checkers. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Fu Siyuan Reviewed-by: Ye Ting Reviewed-by: Wu Jiaxin --- diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c index 0865ddd7cd..077905671e 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c @@ -132,11 +132,10 @@ CvtNum ( { UINTN Remainder; - while (Length > 0) { + for (; Length > 0; Length--) { Remainder = Number % 10; Number /= 10; - Length--; - Buffer[Length] = (UINT8) ('0' + Remainder); + Buffer[Length - 1] = (UINT8) ('0' + Remainder); } }