Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler warnings in blake2s.c #48

Open
wjssz opened this issue Dec 15, 2024 · 0 comments
Open

compiler warnings in blake2s.c #48

wjssz opened this issue Dec 15, 2024 · 0 comments

Comments

@wjssz
Copy link

wjssz commented Dec 15, 2024

If defined __SSE4_1__, and compile with MSVC, there are some data cast warnings.
Patch to fix (this patch is for Python 3.10's bundled blake2 code):

 Modules/_blake2/impl/blake2s.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Modules/_blake2/impl/blake2s.c b/Modules/_blake2/impl/blake2s.c
index 47514685b8f..781588ea26d 100644
--- a/Modules/_blake2/impl/blake2s.c
+++ b/Modules/_blake2/impl/blake2s.c
@@ -214,7 +214,7 @@ int blake2s_init( blake2s_state *S, size_t outlen )
 
   const blake2s_param P =
   {
-    outlen,
+    ( uint8_t ) outlen,
     0,
     1,
     1,
@@ -237,8 +237,8 @@ int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t k
 
   const blake2s_param P =
   {
-    outlen,
-    keylen,
+    ( uint8_t ) outlen,
+    ( uint8_t ) keylen,
     1,
     1,
     0,
@@ -325,8 +325,8 @@ int blake2s_update( blake2s_state *S, const uint8_t *in, size_t inlen )
 {
   while( inlen > 0 )
   {
-    size_t left = S->buflen;
-    size_t fill = 2 * BLAKE2S_BLOCKBYTES - left;
+    uint32_t left = S->buflen;
+    uint32_t fill = 2 * BLAKE2S_BLOCKBYTES - left;
 
     if( inlen > fill )
     {
@@ -342,7 +342,7 @@ int blake2s_update( blake2s_state *S, const uint8_t *in, size_t inlen )
     else /* inlen <= fill */
     {
       memcpy( S->buf + left, in, inlen );
-      S->buflen += inlen; // Be lazy, do not compress
+      S->buflen += ( uint32_t ) inlen; // Be lazy, do not compress
       in += inlen;
       inlen -= inlen;
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant