[PATCH] crypto/crc32c.c (was Re: CRC32c warning on sparc64)

From: Clay Haapala
Date: Thu May 06 2004 - 14:41:46 EST


On Thu, 6 May 2004, Meelis Roos uttered the following:
> This is 2.6.6-rc3+BK as of today on a sparc64 (gcc 3.3.3 on Debian):
>
> CC [M] crypto/crc32c.o crypto/crc32c.c:89: warning: initialization
> from incompatible pointer type
>
> This is because chksum_update uses size_t (64-bit unsigned long on
> sparc64) length argument but dia_update seems to want unsigned int
> as the type of length.
>
> What is the right fix - change the length in chksum_update() and
> crc32c() to unsigned int?

Well, it's my opinion that using "size_t" is correct usage of type in
this case. So here's my thinking:

* we leave lib/crc32c() as it is with size_t, as it is meant to be
derived from crc32() and that uses size_t.

* crypto/crc32c is a wrapper for lib/crc32c. The interface it
presents to the rest of the crypto routines should agree. My bad.
So, let us let it translate with a cast, as in the patch below.
--
Clay Haapala (chaapala@xxxxxxxxx) Cisco Systems SRBU +1 763-398-1056
6450 Wedgwood Rd, Suite 130 Maple Grove MN 55311 PGP: C89240AD
"Oh, *that* Physics Prize. Well, I just substituted 'stupidity' for
'dark matter' in the equations, and it all came together."

--- linux-2.6.6-rc3-bk.orig/crypto/crc32c.c 2004-05-06 14:11:54.000000000 -0500
+++ linux-2.6.6-rc3-bk/crypto/crc32c.c 2004-05-06 14:12:56.000000000 -0500
@@ -56,12 +56,12 @@
return 0;
}

-static void chksum_update(void *ctx, const u8 *data, size_t length)
+static void chksum_update(void *ctx, const u8 *data, unsigned int length)
{
struct chksum_ctx *mctx = ctx;
u32 mcrc;

- mcrc = crc32c(mctx->crc, data, length);
+ mcrc = crc32c(mctx->crc, data, (size_t)length);

mctx->crc = mcrc;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/