From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 7FED22034C0AA for ; Tue, 24 Oct 2017 00:47:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C3CE80C0A; Tue, 24 Oct 2017 07:51:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3C3CE80C0A Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lersek@redhat.com Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-52.rdu2.redhat.com [10.10.120.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 092435DD93; Tue, 24 Oct 2017 07:51:03 +0000 (UTC) To: "Long, Qin" , Peter Jones Cc: "edk2-devel@lists.01.org" , "Shi, Steven" , "Ye, Ting" References: <20171020151018.785-1-pjones@redhat.com> <0a2c301c-58a8-ecf7-8d1a-40dd5ab8bc8e@redhat.com> <20171020182147.4rsisbduvvjweb2z@redhat.com> From: Laszlo Ersek Message-ID: <12b81ebc-a0bb-4d67-9dbb-6687d036729b@redhat.com> Date: Tue, 24 Oct 2017 09:51:03 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 24 Oct 2017 07:51:06 +0000 (UTC) Subject: Re: [PATCH v1 1/1] CryptoPkg/BaseCryptLib: remove some duplicate initializations. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 07:47:23 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Qin, On 10/23/17 05:02, Long, Qin wrote: > This looks good to me. > Reviewed-by: Long Qin qin.long@intel.com Do you want me to push the patch, or do you prefer to push it yourself? Thanks! Laszlo > From: Peter Jones [mailto:pjones@redhat.com] > Sent: Saturday, October 21, 2017 2:22 AM > To: Laszlo Ersek > Cc: edk2-devel@lists.01.org; Shi, Steven ; Long, Qin ; Ye, Ting > Subject: Re: [edk2] [PATCH v1 1/1] CryptoPkg/BaseCryptLib: remove some duplicate initializations. > >> Assuming the maintainers are fine with the patch as well, I suggest that >> they please replace the word "initializations" with "assignments" in the >> subject, to be pedantic on the C-lang level. > > Well, that's why I said "initializations" instead of "initializers", but if > it's more clear to you, I'm fine with your way. > >> (Side note: I would even move OldSize to a lot tighter scope: >> >>> diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c >>> index d564591cb7f9..31a9ecd59ff6 100644 >>> --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c >>> +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7Verify.c >>> @@ -477,7 +477,6 @@ Pkcs7GetCertificatesList ( >>> UINT8 *CertBuf; >>> UINT8 *OldBuf; >>> UINTN BufferSize; >>> - UINTN OldSize; >>> UINT8 *SingleCert; >>> UINTN CertSize; >>> >>> @@ -612,10 +611,11 @@ Pkcs7GetCertificatesList ( >>> >>> if (CtxChain != NULL) { >>> BufferSize = sizeof (UINT8); >>> - OldSize = BufferSize; >>> CertBuf = NULL; >>> >>> for (Index = 0; ; Index++) { >>> + UINTN OldSize; >>> + >>> Status = X509PopCertificate (CtxChain, &SingleCert, &CertSize); >>> if (!Status) { >>> break; >>> @@ -656,10 +656,11 @@ Pkcs7GetCertificatesList ( >>> >>> if (CtxUntrusted != NULL) { >>> BufferSize = sizeof (UINT8); >>> - OldSize = BufferSize; >>> CertBuf = NULL; >>> >>> for (Index = 0; ; Index++) { >>> + UINTN OldSize; >>> + >>> Status = X509PopCertificate (CtxUntrusted, &SingleCert, &CertSize); >>> if (!Status) { >>> break; >> >> However, many edk2 maintainers don't like tight scoping like this.) > > I had considered this and guessed it was probably against the coding style or > it would have been done this way already. IMO it's better in every way. > > -- > Peter >