[PATCH RFC 2/6] purgatory: No need to sha256 update if ptr->len is zero
Pratyush Anand
panand at redhat.com
Sun Apr 19 20:18:24 PDT 2015
On Monday 20 April 2015 08:31 AM, Baoquan He wrote:
> 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 <panand at redhat.com>
>> ---
>> 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.
>
I think you are right, we can skip this.
~Pratyush
> 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 at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/kexec
>
> _______________________________________________
> kexec mailing list
> kexec at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
>
More information about the kexec
mailing list