[PATCH v1 2/2] crypto: Fix sha1 signed pointer comparison compile error
From: Yuzhuo Jing
Date: Fri Jun 13 2025 - 20:11:04 EST
In include/crypto/sha1_base.h, sha1_block_fn type is defined as
void(sha1_block_fn)(struct sha1_state *sst, u8 const *src, int blocks);
In lib/crypto/sha1.c, the second argument on sha1_transform is defined
as "const char *", which causes type mismatch when calling
sha1_transform from sha1_generic_block_fn in crypto/sha1_generic.c.
We don't break the widely used sha1_block_fn or sha1_transform function
signatures, so this patch converts the pointer sign at usage to fix the
compile error for environments that enable -Werror=pointer-sign.
Signed-off-by: Yuzhuo Jing <yuzhuo@xxxxxxxxxx>
---
crypto/sha1_generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c
index 325b57fe28dc..3a3f9608b989 100644
--- a/crypto/sha1_generic.c
+++ b/crypto/sha1_generic.c
@@ -33,7 +33,7 @@ static void sha1_generic_block_fn(struct sha1_state *sst, u8 const *src,
u32 temp[SHA1_WORKSPACE_WORDS];
while (blocks--) {
- sha1_transform(sst->state, src, temp);
+ sha1_transform(sst->state, (const char *)src, temp);
src += SHA1_BLOCK_SIZE;
}
memzero_explicit(temp, sizeof(temp));
--
2.50.0.rc1.591.g9c95f17f64-goog