On Fri, Jan 3, 2025 at 5:34 PM David Laight <david.laight.linux@xxxxxxxxx> wrote: > > On Fri, 3 Jan 2025 16:30:43 +0900 > Masahiro Yamada <masahiroy@xxxxxxxxxx> 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@xxxxxxxxxx> > > --- > > > > 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. The point is, uint32_t is the clearest way to ensure the variables are fixed width. Casting to (unsigned long) vs PRIu32 is just a matter of preference. -- Best Regards Masahiro Yamada