From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2118882030 for ; Thu, 15 Dec 2016 19:38:48 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP; 15 Dec 2016 19:38:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,355,1477983600"; d="scan'208";a="42940890" Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.34]) by orsmga005.jf.intel.com with ESMTP; 15 Dec 2016 19:38:46 -0800 From: Hao Wu To: edk2-devel@lists.01.org Cc: Hao Wu Date: Fri, 16 Dec 2016 11:37:43 +0800 Message-Id: <1481859463-10536-7-git-send-email-hao.a.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1481859463-10536-1-git-send-email-hao.a.wu@intel.com> References: <1481859463-10536-1-git-send-email-hao.a.wu@intel.com> Subject: [PATCH v2 6/6] NetworkPkg: Refine UintnToAscDecWithFormat functions logic X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2016 03:38:48 -0000 This commit refines the logic for HttpBootUintnToAscDecWithFormat and PxeBcUintnToAscDecWithFormat. 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 --- NetworkPkg/HttpBootDxe/HttpBootSupport.c | 5 ++--- NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/NetworkPkg/HttpBootDxe/HttpBootSupport.c b/NetworkPkg/HttpBootDxe/HttpBootSupport.c index 9410bf9..bdb29ae 100644 --- a/NetworkPkg/HttpBootDxe/HttpBootSupport.c +++ b/NetworkPkg/HttpBootDxe/HttpBootSupport.c @@ -86,11 +86,10 @@ HttpBootUintnToAscDecWithFormat ( { UINTN Remainder; - while (Length > 0) { - Length--; + for (; Length > 0; Length--) { Remainder = Number % 10; Number /= 10; - Buffer[Length] = (UINT8) ('0' + Remainder); + Buffer[Length - 1] = (UINT8) ('0' + Remainder); } } diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c index 00c652d..568360d 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c @@ -1383,11 +1383,10 @@ PxeBcUintnToAscDecWithFormat ( { UINTN Remainder; - while (Length > 0) { - Length--; + for (; Length > 0; Length--) { Remainder = Number % 10; Number /= 10; - Buffer[Length] = (UINT8) ('0' + Remainder); + Buffer[Length - 1] = (UINT8) ('0' + Remainder); } } -- 1.9.5.msysgit.0