mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] crypto: crc32: use uint32_t instead of ulong
Date: Mon, 28 Aug 2023 09:20:03 +0200	[thread overview]
Message-ID: <20230828072003.GH16522@pengutronix.de> (raw)
In-Reply-To: <20230825181749.2861735-1-a.fatoum@pengutronix.de>

On Fri, Aug 25, 2023 at 08:17:49PM +0200, Ahmad Fatoum wrote:
> Using ulong just wastes space on 64-bit platforms, so use fixed size
> 32-bit integers instead.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  crypto/crc32.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/crypto/crc32.c b/crypto/crc32.c
> index 998cbc9de297..95cb2212db2b 100644
> --- a/crypto/crc32.c
> +++ b/crypto/crc32.c
> @@ -24,7 +24,7 @@
>  
>  #ifdef CONFIG_DYNAMIC_CRC_TABLE
>  
> -static ulong *crc_table;
> +static uint32_t *crc_table;
>  
>  /*
>    Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
> @@ -52,22 +52,22 @@ static ulong *crc_table;
>  */
>  static void make_crc_table(void)
>  {
> -  ulong c;
> +  uint32_t c;
>    int n, k;
> -  ulong poly;            /* polynomial exclusive-or pattern */
> +  uint32_t poly;            /* polynomial exclusive-or pattern */
>    /* terms of polynomial defining this crc (except x^32): */
>    static const char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
>  
>    /* make exclusive-or pattern from polynomial (0xedb88320L) */
> -  poly = 0L;
> +  poly = 0;
>    for (n = 0; n < sizeof(p)/sizeof(char); n++)
> -    poly |= 1L << (31 - p[n]);
> +    poly |= 1U << (31 - p[n]);
>  
> -  crc_table = xmalloc(sizeof(ulong) * 256);
> +  crc_table = xmalloc(sizeof(uint32_t) * 256);
>  
>    for (n = 0; n < 256; n++)
>    {
> -    c = (ulong)n;
> +    c = (uint32_t)n;
>      for (k = 0; k < 8; k++)
>        c = c & 1 ? poly ^ (c >> 1) : c >> 1;
>      crc_table[n] = c;
> @@ -77,7 +77,7 @@ static void make_crc_table(void)
>  /* ========================================================================
>   * Table of CRC-32's of all single-byte values (made by make_crc_table)
>   */
> -static const ulong crc_table[256] = {
> +static const uint32_t crc_table[256] = {
>    0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
>    0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
>    0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2023-08-28  7:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25 18:17 Ahmad Fatoum
2023-08-28  7:20 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230828072003.GH16522@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox