This avoids unnecessary explicit initialization by allocating zeroed memory.
Signed-off-by: Maxin B. John<[email protected]>
---
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c
b/arch/cris/arch-v32/drivers/cryptocop.c
index c03bc3b..f51b524 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -1394,11 +1394,10 @@ static int create_md5_pad(int alloc_flag,
unsigned long long hashed_length, char
if (padlen < MD5_MIN_PAD_LENGTH) padlen += MD5_BLOCK_LENGTH;
- p = kmalloc(padlen, alloc_flag);
+ p = kzalloc(padlen, alloc_flag);
if (!p) return -ENOMEM;
*p = 0x80;
- memset(p+1, 0, padlen - 1);
DEBUG(printk("create_md5_pad: hashed_length=%lld bits == %lld
bytes\n", bit_length, hashed_length));
@@ -1426,11 +1425,10 @@ static int create_sha1_pad(int alloc_flag,
unsigned long long hashed_length, cha
if (padlen < SHA1_MIN_PAD_LENGTH) padlen += SHA1_BLOCK_LENGTH;
- p = kmalloc(padlen, alloc_flag);
+ p = kzalloc(padlen, alloc_flag);
if (!p) return -ENOMEM;
*p = 0x80;
- memset(p+1, 0, padlen - 1);
DEBUG(printk("create_sha1_pad: hashed_length=%lld bits == %lld
bytes\n", bit_length, hashed_length));
---
ping ..
On Sun, Mar 27, 2011 at 1:17 PM, Maxin John <[email protected]> wrote:
> This avoids unnecessary explicit initialization by allocating zeroed memory.
>
> Signed-off-by: Maxin B. John<[email protected]>
> ---
> diff --git a/arch/cris/arch-v32/drivers/cryptocop.c
> b/arch/cris/arch-v32/drivers/cryptocop.c
> index c03bc3b..f51b524 100644
> --- a/arch/cris/arch-v32/drivers/cryptocop.c
> +++ b/arch/cris/arch-v32/drivers/cryptocop.c
> @@ -1394,11 +1394,10 @@ static int create_md5_pad(int alloc_flag,
> unsigned long long hashed_length, char
>
> ? ? ? ?if (padlen < MD5_MIN_PAD_LENGTH) padlen += MD5_BLOCK_LENGTH;
>
> - ? ? ? p = kmalloc(padlen, alloc_flag);
> + ? ? ? p = kzalloc(padlen, alloc_flag);
> ? ? ? ?if (!p) return -ENOMEM;
>
> ? ? ? ?*p = 0x80;
> - ? ? ? memset(p+1, 0, padlen - 1);
>
> ? ? ? ?DEBUG(printk("create_md5_pad: hashed_length=%lld bits == %lld
> bytes\n", bit_length, hashed_length));
>
> @@ -1426,11 +1425,10 @@ static int create_sha1_pad(int alloc_flag,
> unsigned long long hashed_length, cha
>
> ? ? ? ?if (padlen < SHA1_MIN_PAD_LENGTH) padlen += SHA1_BLOCK_LENGTH;
>
> - ? ? ? p = kmalloc(padlen, alloc_flag);
> + ? ? ? p = kzalloc(padlen, alloc_flag);
> ? ? ? ?if (!p) return -ENOMEM;
>
> ? ? ? ?*p = 0x80;
> - ? ? ? memset(p+1, 0, padlen - 1);
>
> ? ? ? ?DEBUG(printk("create_sha1_pad: hashed_length=%lld bits == %lld
> bytes\n", bit_length, hashed_length));
>
> ---
>
On Sun, Mar 27, 2011 at 12:17:23PM +0200, Maxin John wrote:
> This avoids unnecessary explicit initialization by allocating zeroed memory.
>
> Signed-off-by: Maxin B. John<[email protected]>
Applied, thanks!
/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]