lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250619183414.100082-3-ebiggers@kernel.org>
Date: Thu, 19 Jun 2025 11:34:13 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: linux-kernel@...r.kernel.org
Cc: Ard Biesheuvel <ardb@...nel.org>,
	linux-crypto@...r.kernel.org
Subject: [PATCH 2/3] lib/crc/crc32: change crc32() from macro to inline function and remove cast

From: Eric Biggers <ebiggers@...gle.com>

There's no need for crc32() to be a macro.  Make it an inline function
instead.  Also, remove the cast of the data pointer to
'unsigned char const *', which is no longer necessary now that the type
used in the function prototype is 'const void *'.

Signed-off-by: Eric Biggers <ebiggers@...gle.com>
---
 include/linux/crc32.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/crc32.h b/include/linux/crc32.h
index f9c173206d4d1..da78b215ff2e9 100644
--- a/include/linux/crc32.h
+++ b/include/linux/crc32.h
@@ -28,10 +28,16 @@
  * Context: Any context
  * Return: The new CRC value
  */
 u32 crc32_le(u32 crc, const void *p, size_t len);
 
+/* This is just an alias for crc32_le(). */
+static inline u32 crc32(u32 crc, const void *p, size_t len)
+{
+	return crc32_le(crc, p, len);
+}
+
 /**
  * crc32_be() - Compute most-significant-bit-first IEEE CRC-32
  * @crc: Initial CRC value.  ~0 (recommended) or 0 for a new CRC computation, or
  *	 the previous CRC value if computing incrementally.
  * @p: Pointer to the data buffer
@@ -88,12 +94,10 @@ u32 crc32c(u32 crc, const void *p, size_t len);
 u32 crc32_optimizations(void);
 #else
 static inline u32 crc32_optimizations(void) { return 0; }
 #endif
 
-#define crc32(seed, data, length)  crc32_le(seed, (unsigned char const *)(data), length)
-
 /*
  * Helpers for hash table generation of ethernet nics:
  *
  * Ethernet sends the least significant bit of a byte first, thus crc32_le
  * is used. The output of crc32_le is bit reversed [most significant bit
-- 
2.50.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ