]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
md2: omit confusing casts
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 8 May 2026 20:07:19 +0000 (13:07 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 9 May 2026 03:25:25 +0000 (20:25 -0700)
* lib/md2.c (md2_process_bytes):
Use size_t, not unsigned long, for size.
Although the code was correct it was unclear.
(md2_update_chksum, md2_compress): Omit confusing casts.

ChangeLog
lib/md2.c

index 326797527bab5eb718d402682e2566dfb3a2647d..282f86f3dd51af0ecca5bccf1229637b360022bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2026-05-08  Paul Eggert  <eggert@cs.ucla.edu>
 
+       md2: omit confusing casts
+       * lib/md2.c (md2_process_bytes):
+       Use size_t, not unsigned long, for size.
+       Although the code was correct it was unclear.
+       (md2_update_chksum, md2_compress): Omit confusing casts.
+
        Pacify -Wuseless-cast for pthread_self
        * lib/glthread/thread.h (gl_thread_self_pointer):
        * tests/test-pthread-mutex.c, tests/test-pthread-once2.c:
index ea9a1f15e43e347e9dfedc59162eb8dfe51b7d03..e02a940590de705b1268f812267706c226fc3f32 100644 (file)
--- a/lib/md2.c
+++ b/lib/md2.c
@@ -103,8 +103,8 @@ md2_process_bytes (void const *restrict buffer, size_t len,
 
   while (len > 0)
     {
-      unsigned long n = MIN (len, (16 - ctx->curlen));
-      memcpy (ctx->buf + ctx->curlen, in, (size_t) n);
+      size_t n = MIN (len, (16 - ctx->curlen));
+      memcpy (ctx->buf + ctx->curlen, in, n);
       ctx->curlen += n;
       in += n;
       len -= n;
@@ -149,7 +149,7 @@ md2_update_chksum (struct md2_ctx *ctx)
     {
       /* caution, the RFC says its "C[j] = S[M[i*16+j] xor L]" but the
          reference source code [and test vectors] say otherwise. */
-      L = (ctx->chksum[j] ^= PI_SUBST[(int) (ctx->buf[j] ^ L)] & 255);
+      L = (ctx->chksum[j] ^= PI_SUBST[ctx->buf[j] ^ L] & 255);
     }
 }
 
@@ -170,7 +170,7 @@ md2_compress (struct md2_ctx *ctx)
     {
       for (size_t k = 0; k < 48; k++)
         {
-          t = (ctx->X[k] ^= PI_SUBST[(int) (t & 255)]);
+          t = (ctx->X[k] ^= PI_SUBST[t & 255]);
         }
       t = (t + (unsigned char) j) & 255;
     }