From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yk1xm-0004N9-QG for kexec@lists.infradead.org; Mon, 20 Apr 2015 03:01:35 +0000 Date: Mon, 20 Apr 2015 11:01:08 +0800 From: Baoquan He Subject: Re: [PATCH RFC 2/6] purgatory: No need to sha256 update if ptr->len is zero Message-ID: <20150420030108.GE15033@dhcp-16-116.nay.redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Pratyush Anand Cc: kexec@lists.infradead.org, kexec@lists.fedoraproject.org On 04/16/15 at 10:17pm, Pratyush Anand wrote: > If ptr->len is zero we do not need to update sha256. > > Signed-off-by: Pratyush Anand > --- > purgatory/purgatory.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/purgatory/purgatory.c b/purgatory/purgatory.c > index 3bbcc0935ad5..f8ed69b8fbfb 100644 > --- a/purgatory/purgatory.c > +++ b/purgatory/purgatory.c > @@ -18,6 +18,8 @@ int verify_sha256_digest(void) > sha256_starts(&ctx); > end = &sha256_regions[sizeof(sha256_regions)/sizeof(sha256_regions[0])]; > for(ptr = sha256_regions; ptr < end; ptr++) { > + if (ptr->len == 0) > + continue; Hi Pratyush, I don't think this is necessary, but don't object to it strongly. Since sha256_update will check the length and return immediately if it's 0. void sha256_update( sha256_context *ctx, const uint8_t *input, size_t length ) { size_t left, fill; if( ! length ) return; ... } Thanks Baoquan > sha256_update(&ctx, (uint8_t *)((uintptr_t)ptr->start), > ptr->len); > } > -- > 2.1.0 > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec