Skip to content

Commit 2d7da4f

Browse files
committed
lib/crc32: use void pointer for data
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. Reviewed-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent 92ef2ce commit 2d7da4f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/linux/crc32.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ u32 __pure crc32_be_base(u32 crc, const u8 *p, size_t len);
1515
u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len);
1616
u32 __pure crc32c_le_base(u32 crc, const u8 *p, size_t len);
1717

18-
static inline u32 __pure crc32_le(u32 crc, const u8 *p, size_t len)
18+
static inline u32 __pure crc32_le(u32 crc, const void *p, size_t len)
1919
{
2020
if (IS_ENABLED(CONFIG_CRC32_ARCH))
2121
return crc32_le_arch(crc, p, len);
2222
return crc32_le_base(crc, p, len);
2323
}
2424

25-
static inline u32 __pure crc32_be(u32 crc, const u8 *p, size_t len)
25+
static inline u32 __pure crc32_be(u32 crc, const void *p, size_t len)
2626
{
2727
if (IS_ENABLED(CONFIG_CRC32_ARCH))
2828
return crc32_be_arch(crc, p, len);
2929
return crc32_be_base(crc, p, len);
3030
}
3131

3232
/* TODO: leading underscores should be dropped once callers have been updated */
33-
static inline u32 __pure __crc32c_le(u32 crc, const u8 *p, size_t len)
33+
static inline u32 __pure __crc32c_le(u32 crc, const void *p, size_t len)
3434
{
3535
if (IS_ENABLED(CONFIG_CRC32_ARCH))
3636
return crc32c_le_arch(crc, p, len);

0 commit comments

Comments
 (0)