diff mbox series

[v1,2/2] crypto: Fix sha1 signed pointer comparison compile error

Message ID 20250614000828.311722-3-yuzhuo@google.com
State New
Headers show
Series crypto: Fix sha1 compile error | expand

Commit Message

Yuzhuo Jing June 14, 2025, 12:08 a.m. UTC
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@google.com>
---
 crypto/sha1_generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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));