Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/crc32: don't bother with pure and const function attributes

Drop the use of __pure and __attribute_const__ from the CRC32 library
functions that had them. Both of these are unusual optimizations that
don't help properly written code. They seem more likely to cause
problems than have any real benefit.

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20250208024911.14936-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>

+27 -29
+3 -3
arch/arm64/lib/crc32-glue.c
··· 22 22 asmlinkage u32 crc32c_le_arm64_4way(u32 crc, unsigned char const *p, size_t len); 23 23 asmlinkage u32 crc32_be_arm64_4way(u32 crc, unsigned char const *p, size_t len); 24 24 25 - u32 __pure crc32_le_arch(u32 crc, const u8 *p, size_t len) 25 + u32 crc32_le_arch(u32 crc, const u8 *p, size_t len) 26 26 { 27 27 if (!alternative_has_cap_likely(ARM64_HAS_CRC32)) 28 28 return crc32_le_base(crc, p, len); ··· 43 43 } 44 44 EXPORT_SYMBOL(crc32_le_arch); 45 45 46 - u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len) 46 + u32 crc32c_le_arch(u32 crc, const u8 *p, size_t len) 47 47 { 48 48 if (!alternative_has_cap_likely(ARM64_HAS_CRC32)) 49 49 return crc32c_le_base(crc, p, len); ··· 64 64 } 65 65 EXPORT_SYMBOL(crc32c_le_arch); 66 66 67 - u32 __pure crc32_be_arch(u32 crc, const u8 *p, size_t len) 67 + u32 crc32_be_arch(u32 crc, const u8 *p, size_t len) 68 68 { 69 69 if (!alternative_has_cap_likely(ARM64_HAS_CRC32)) 70 70 return crc32_be_base(crc, p, len);
+6 -7
arch/riscv/lib/crc32-riscv.c
··· 175 175 return crc; 176 176 } 177 177 178 - static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p, 179 - size_t len, u32 poly, 180 - unsigned long poly_qt, 181 - fallback crc_fb) 178 + static inline u32 crc32_le_generic(u32 crc, unsigned char const *p, size_t len, 179 + u32 poly, unsigned long poly_qt, 180 + fallback crc_fb) 182 181 { 183 182 size_t offset, head_len, tail_len; 184 183 unsigned long const *p_ul; ··· 217 218 return crc_fb(crc, p, len); 218 219 } 219 220 220 - u32 __pure crc32_le_arch(u32 crc, const u8 *p, size_t len) 221 + u32 crc32_le_arch(u32 crc, const u8 *p, size_t len) 221 222 { 222 223 return crc32_le_generic(crc, p, len, CRC32_POLY_LE, CRC32_POLY_QT_LE, 223 224 crc32_le_base); 224 225 } 225 226 EXPORT_SYMBOL(crc32_le_arch); 226 227 227 - u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len) 228 + u32 crc32c_le_arch(u32 crc, const u8 *p, size_t len) 228 229 { 229 230 return crc32_le_generic(crc, p, len, CRC32C_POLY_LE, 230 231 CRC32C_POLY_QT_LE, crc32c_le_base); ··· 255 256 return crc; 256 257 } 257 258 258 - u32 __pure crc32_be_arch(u32 crc, const u8 *p, size_t len) 259 + u32 crc32_be_arch(u32 crc, const u8 *p, size_t len) 259 260 { 260 261 size_t offset, head_len, tail_len; 261 262 unsigned long const *p_ul;
+11 -11
include/linux/crc32.h
··· 8 8 #include <linux/types.h> 9 9 #include <linux/bitrev.h> 10 10 11 - u32 __pure crc32_le_arch(u32 crc, const u8 *p, size_t len); 12 - u32 __pure crc32_le_base(u32 crc, const u8 *p, size_t len); 13 - u32 __pure crc32_be_arch(u32 crc, const u8 *p, size_t len); 14 - u32 __pure crc32_be_base(u32 crc, const u8 *p, size_t len); 15 - u32 __pure crc32c_le_arch(u32 crc, const u8 *p, size_t len); 16 - u32 __pure crc32c_le_base(u32 crc, const u8 *p, size_t len); 11 + u32 crc32_le_arch(u32 crc, const u8 *p, size_t len); 12 + u32 crc32_le_base(u32 crc, const u8 *p, size_t len); 13 + u32 crc32_be_arch(u32 crc, const u8 *p, size_t len); 14 + u32 crc32_be_base(u32 crc, const u8 *p, size_t len); 15 + u32 crc32c_le_arch(u32 crc, const u8 *p, size_t len); 16 + u32 crc32c_le_base(u32 crc, const u8 *p, size_t len); 17 17 18 - static inline u32 __pure crc32_le(u32 crc, const void *p, size_t len) 18 + static inline u32 crc32_le(u32 crc, const void *p, size_t len) 19 19 { 20 20 if (IS_ENABLED(CONFIG_CRC32_ARCH)) 21 21 return crc32_le_arch(crc, p, len); 22 22 return crc32_le_base(crc, p, len); 23 23 } 24 24 25 - static inline u32 __pure crc32_be(u32 crc, const void *p, size_t len) 25 + static inline u32 crc32_be(u32 crc, const void *p, size_t len) 26 26 { 27 27 if (IS_ENABLED(CONFIG_CRC32_ARCH)) 28 28 return crc32_be_arch(crc, p, len); ··· 30 30 } 31 31 32 32 /* TODO: leading underscores should be dropped once callers have been updated */ 33 - static inline u32 __pure __crc32c_le(u32 crc, const void *p, size_t len) 33 + static inline u32 __crc32c_le(u32 crc, const void *p, size_t len) 34 34 { 35 35 if (IS_ENABLED(CONFIG_CRC32_ARCH)) 36 36 return crc32c_le_arch(crc, p, len); ··· 70 70 * with the same initializer as crc1, and crc2 seed was 0. See 71 71 * also crc32_combine_test(). 72 72 */ 73 - u32 __attribute_const__ crc32_le_shift(u32 crc, size_t len); 73 + u32 crc32_le_shift(u32 crc, size_t len); 74 74 75 75 static inline u32 crc32_le_combine(u32 crc1, u32 crc2, size_t len2) 76 76 { ··· 95 95 * seeded with the same initializer as crc1, and crc2 seed 96 96 * was 0. See also crc32c_combine_test(). 97 97 */ 98 - u32 __attribute_const__ __crc32c_le_shift(u32 crc, size_t len); 98 + u32 __crc32c_le_shift(u32 crc, size_t len); 99 99 100 100 static inline u32 __crc32c_le_combine(u32 crc1, u32 crc2, size_t len2) 101 101 {
+7 -8
lib/crc32.c
··· 37 37 MODULE_DESCRIPTION("Various CRC32 calculations"); 38 38 MODULE_LICENSE("GPL"); 39 39 40 - u32 __pure crc32_le_base(u32 crc, const u8 *p, size_t len) 40 + u32 crc32_le_base(u32 crc, const u8 *p, size_t len) 41 41 { 42 42 while (len--) 43 43 crc = (crc >> 8) ^ crc32table_le[(crc & 255) ^ *p++]; ··· 45 45 } 46 46 EXPORT_SYMBOL(crc32_le_base); 47 47 48 - u32 __pure crc32c_le_base(u32 crc, const u8 *p, size_t len) 48 + u32 crc32c_le_base(u32 crc, const u8 *p, size_t len) 49 49 { 50 50 while (len--) 51 51 crc = (crc >> 8) ^ crc32ctable_le[(crc & 255) ^ *p++]; ··· 58 58 * This follows the "little-endian" CRC convention that the lsbit 59 59 * represents the highest power of x, and the msbit represents x^0. 60 60 */ 61 - static u32 __attribute_const__ gf2_multiply(u32 x, u32 y, u32 modulus) 61 + static u32 gf2_multiply(u32 x, u32 y, u32 modulus) 62 62 { 63 63 u32 product = x & 1 ? y : 0; 64 64 int i; ··· 84 84 * as appending len bytes of zero to the data), in time proportional 85 85 * to log(len). 86 86 */ 87 - static u32 __attribute_const__ crc32_generic_shift(u32 crc, size_t len, 88 - u32 polynomial) 87 + static u32 crc32_generic_shift(u32 crc, size_t len, u32 polynomial) 89 88 { 90 89 u32 power = polynomial; /* CRC of x^32 */ 91 90 int i; ··· 113 114 return crc; 114 115 } 115 116 116 - u32 __attribute_const__ crc32_le_shift(u32 crc, size_t len) 117 + u32 crc32_le_shift(u32 crc, size_t len) 117 118 { 118 119 return crc32_generic_shift(crc, len, CRC32_POLY_LE); 119 120 } 120 121 121 - u32 __attribute_const__ __crc32c_le_shift(u32 crc, size_t len) 122 + u32 __crc32c_le_shift(u32 crc, size_t len) 122 123 { 123 124 return crc32_generic_shift(crc, len, CRC32C_POLY_LE); 124 125 } 125 126 EXPORT_SYMBOL(crc32_le_shift); 126 127 EXPORT_SYMBOL(__crc32c_le_shift); 127 128 128 - u32 __pure crc32_be_base(u32 crc, const u8 *p, size_t len) 129 + u32 crc32_be_base(u32 crc, const u8 *p, size_t len) 129 130 { 130 131 while (len--) 131 132 crc = (crc << 8) ^ crc32table_be[(crc >> 24) ^ *p++];