[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250205005403.136082-2-ebiggers@kernel.org>
Date: Tue, 4 Feb 2025 16:53:59 -0800
From: Eric Biggers <ebiggers@...nel.org>
To: linux-kernel@...r.kernel.org
Cc: linux-crypto@...r.kernel.org,
Ard Biesheuvel <ardb@...nel.org>
Subject: [PATCH 1/5] lib/crc32: use void pointer for data
From: Eric Biggers <ebiggers@...gle.com>
Update crc32_le(), crc32_be(), and __crc32c_le() to take the data as a
'const void *' instead of 'const u8 *'.
This makes them slightly easier to use, as it can eliminate the need for
casts in the calling code. It's the only pointer argument, so there is
no possibility for confusion with another pointer argument.
Also, some of the CRC library functions, for example crc32c() and
crc64_be(), already used 'const void *'. Let's standardize on that, as
it seems like a better choice.
The underlying base and arch functions continue to use 'const u8 *', as
that is often more convenient for the implementation.
Signed-off-by: Eric Biggers <ebiggers@...gle.com>
---
include/linux/crc32.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/crc32.h b/include/linux/crc32.h
index e9bd40056687a..e70977014cfdc 100644
--- a/include/linux/crc32.h
+++ b/include/linux/crc32.h
@@ -13,26 +13,26 @@ u32 __pure crc32_le_base(u32 crc, const u8 *p, size_t len);
u32 __pure crc32_be_arch(u32 crc, const u8 *p, size_t len);
u32 __pure crc32_be_base(u32 crc, const u8 *p, size_t len);
u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len);
u32 __pure crc32c_le_base(u32 crc, const u8 *p, size_t len);
-static inline u32 __pure crc32_le(u32 crc, const u8 *p, size_t len)
+static inline u32 __pure crc32_le(u32 crc, const void *p, size_t len)
{
if (IS_ENABLED(CONFIG_CRC32_ARCH))
return crc32_le_arch(crc, p, len);
return crc32_le_base(crc, p, len);
}
-static inline u32 __pure crc32_be(u32 crc, const u8 *p, size_t len)
+static inline u32 __pure crc32_be(u32 crc, const void *p, size_t len)
{
if (IS_ENABLED(CONFIG_CRC32_ARCH))
return crc32_be_arch(crc, p, len);
return crc32_be_base(crc, p, len);
}
/* TODO: leading underscores should be dropped once callers have been updated */
-static inline u32 __pure __crc32c_le(u32 crc, const u8 *p, size_t len)
+static inline u32 __pure __crc32c_le(u32 crc, const void *p, size_t len)
{
if (IS_ENABLED(CONFIG_CRC32_ARCH))
return crc32c_le_arch(crc, p, len);
return crc32c_le_base(crc, p, len);
}
--
2.48.1
Powered by blists - more mailing lists