From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 764FA802A6 for ; Sun, 5 Mar 2017 23:27:59 -0800 (PST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP; 05 Mar 2017 23:27:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,252,1484035200"; d="scan'208";a="831329701" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 05 Mar 2017 23:27:59 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 5 Mar 2017 23:27:59 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.59]) by SHSMSX103.ccr.corp.intel.com ([10.239.4.69]) with mapi id 14.03.0248.002; Mon, 6 Mar 2017 15:27:57 +0800 From: "Wu, Hao A" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdePkg/SafeString.c: Fix code to be more readable Thread-Index: AQHSlkqy7xNXJSTmi0GfyN6gU6xsv6GHaYPQ Date: Mon, 6 Mar 2017 07:27:57 +0000 Message-ID: References: <20170306072427.601984-1-ruiyu.ni@intel.com> In-Reply-To: <20170306072427.601984-1-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg/SafeString.c: Fix code to be more readable 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: Mon, 06 Mar 2017 07:27:59 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: Ni, Ruiyu > Sent: Monday, March 06, 2017 3:24 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A > Subject: [PATCH] MdePkg/SafeString.c: Fix code to be more readable >=20 > The change doesn't impact the functionality. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni > Cc: Hao A Wu > --- > MdePkg/Library/BaseLib/SafeString.c | 26 ++++++++++++++++---------- > 1 file changed, 16 insertions(+), 10 deletions(-) >=20 > diff --git a/MdePkg/Library/BaseLib/SafeString.c > b/MdePkg/Library/BaseLib/SafeString.c > index b7895ad..249fe47 100644 > --- a/MdePkg/Library/BaseLib/SafeString.c > +++ b/MdePkg/Library/BaseLib/SafeString.c > @@ -1234,6 +1234,7 @@ StrToIpv6Address ( > // > // Uintn won't exceed MAX_UINT16 if number of hexadecimal digit > characters is no more than 4. > // > + ASSERT (AddressIndex + 1 < ARRAY_SIZE (Address->Addr)); > LocalAddress.Addr[AddressIndex] =3D (UINT8) ((UINT16) Uintn >> 8= ); > LocalAddress.Addr[AddressIndex + 1] =3D (UINT8) Uintn; > AddressIndex +=3D 2; > @@ -1286,11 +1287,13 @@ StrToIpv6Address ( > } > CopyMem (&Address->Addr[0], &LocalAddress.Addr[0], CompressStart); > ZeroMem (&Address->Addr[CompressStart], ARRAY_SIZE (Address->Addr) - > AddressIndex); > - CopyMem ( > - &Address->Addr[CompressStart + ARRAY_SIZE (Address->Addr) - > AddressIndex], > - &LocalAddress.Addr[CompressStart], > - AddressIndex - CompressStart > - ); > + if (AddressIndex > CompressStart) { > + CopyMem ( > + &Address->Addr[CompressStart + ARRAY_SIZE (Address->Addr) - > AddressIndex], > + &LocalAddress.Addr[CompressStart], > + AddressIndex - CompressStart > + ); > + } >=20 > if (PrefixLength !=3D NULL) { > *PrefixLength =3D LocalPrefixLength; > @@ -3204,6 +3207,7 @@ AsciiStrToIpv6Address ( > // > // Uintn won't exceed MAX_UINT16 if number of hexadecimal digit > characters is no more than 4. > // > + ASSERT (AddressIndex + 1 < ARRAY_SIZE (Address->Addr)); > LocalAddress.Addr[AddressIndex] =3D (UINT8) ((UINT16) Uintn >> 8= ); > LocalAddress.Addr[AddressIndex + 1] =3D (UINT8) Uintn; > AddressIndex +=3D 2; > @@ -3256,11 +3260,13 @@ AsciiStrToIpv6Address ( > } > CopyMem (&Address->Addr[0], &LocalAddress.Addr[0], CompressStart); > ZeroMem (&Address->Addr[CompressStart], ARRAY_SIZE (Address->Addr) - > AddressIndex); > - CopyMem ( > - &Address->Addr[CompressStart + ARRAY_SIZE (Address->Addr) - > AddressIndex], > - &LocalAddress.Addr[CompressStart], > - AddressIndex - CompressStart > - ); > + if (AddressIndex > CompressStart) { > + CopyMem ( > + &Address->Addr[CompressStart + ARRAY_SIZE (Address->Addr) - > AddressIndex], > + &LocalAddress.Addr[CompressStart], > + AddressIndex - CompressStart > + ); >=20 > + } >=20 > if (PrefixLength !=3D NULL) { > *PrefixLength =3D LocalPrefixLength; > -- > 2.9.0.windows.1