From: David Laight <david.laight.linux@gmail.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] genksyms: use uint32_t instead of unsigned long for calculating CRC
Date: Fri, 3 Jan 2025 08:34:35 +0000 [thread overview]
Message-ID: <20250103083435.1785f86e@pumpkin> (raw)
In-Reply-To: <20250103073046.2609911-6-masahiroy@kernel.org>
On Fri, 3 Jan 2025 16:30:43 +0900
Masahiro Yamada <masahiroy@kernel.org> wrote:
> Currently, 'unsigned long' is used for intermediate variables when
> calculating CRCs.
>
> The size of 'long' differs depending on the architecture: it is 32 bits
> on 32-bit architectures and 64 bits on 64-bit architectures.
>
> The CRC values generated by genksyms represent the compatibility of
> exported symbols. Therefore, reproducibility is important. In other
> words, we need to ensure that the output is the same when the kernel
> source is identical, regardless of whether genksyms is running on a
> 32-bit or 64-bit build machine.
>
> Fortunately, the output from genksyms is not affected by the build
> machine's architecture because only the lower 32 bits of the
> 'unsigned long' variables are used.
>
> To make it even clearer that the CRC calculation is independent of
> the build machine's architecture, this commit explicitly uses the
> fixed-width type, uint32_t.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> scripts/genksyms/genksyms.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
> index e2cd3dcb469f..8b0d7ac73dbb 100644
> --- a/scripts/genksyms/genksyms.c
> +++ b/scripts/genksyms/genksyms.c
>...
> - printf("#SYMVER %s 0x%08lx\n", name, crc);
> + printf("#SYMVER %s 0x%08lx\n", name, (unsigned long)crc);
That should use PRIu32, but the whole patch could just use 'unsigned int'.
No one is going to try to build this where 'int' is 16bit.
All the hex constants assume that int is 32bits as well.
David
next prev parent reply other threads:[~2025-01-03 8:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 7:30 [PATCH 1/6] genksyms: fix memory leak when the same symbol is added from source Masahiro Yamada
2025-01-03 7:30 ` [PATCH 2/6] genksyms: fix memory leak when the same symbol is read from *.symref file Masahiro Yamada
2025-01-03 12:50 ` Markus Elfring
2025-01-03 7:30 ` [PATCH 3/6] genksyms: reduce the indentation in the for-loop in __add_symbol() Masahiro Yamada
2025-01-03 7:30 ` [PATCH 4/6] genksyms: refactor the return points " Masahiro Yamada
2025-01-03 7:30 ` [PATCH 5/6] genksyms: use generic macros for hash table implementation Masahiro Yamada
2025-01-03 7:30 ` [PATCH 6/6] genksyms: use uint32_t instead of unsigned long for calculating CRC Masahiro Yamada
2025-01-03 8:34 ` David Laight [this message]
2025-01-10 17:34 ` Masahiro Yamada
2025-01-03 11:56 ` [PATCH 1/6] genksyms: fix memory leak when the same symbol is added from source Markus Elfring
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=20250103083435.1785f86e@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.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