From 89cdab788f3716b335fefb60b836ebcf975aceab Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 31 Mar 2008 11:02:01 -0400 Subject: crc32: use uint32_t rather than unsigned long The envcrc.c does sizeof(unsigned long) when calculating the crc, but this is done with the build toolchain instead of the target tool chain, so if the build is a 64bit system but the target is 32bits, the size will obviously be wrong. This converts all unsigned long stuff related to crc32 to uint32_t types. Compile tested only: output of ./tools/envcrc when run on a 32bit build system matches that of a 64bit build system. Signed-off-by: Mike Frysinger Acked-by: Jean-Christophe PLAGNIOL-VILLARD --- tools/envcrc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tools/envcrc.c') diff --git a/tools/envcrc.c b/tools/envcrc.c index 7b7718324e..550cf82d17 100644 --- a/tools/envcrc.c +++ b/tools/envcrc.c @@ -22,6 +22,7 @@ */ #include +#include #include #include @@ -58,15 +59,15 @@ #endif /* CFG_ENV_IS_IN_FLASH */ #ifdef CFG_REDUNDAND_ENVIRONMENT -# define ENV_HEADER_SIZE (sizeof(unsigned long) + 1) +# define ENV_HEADER_SIZE (sizeof(uint32_t) + 1) #else -# define ENV_HEADER_SIZE (sizeof(unsigned long)) +# define ENV_HEADER_SIZE (sizeof(uint32_t)) #endif #define ENV_SIZE (CFG_ENV_SIZE - ENV_HEADER_SIZE) -extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned int); +extern uint32_t crc32 (uint32_t, const unsigned char *, unsigned int); #ifdef ENV_IS_EMBEDDED extern unsigned int env_size; @@ -76,7 +77,7 @@ extern unsigned char environment; int main (int argc, char **argv) { #ifdef ENV_IS_EMBEDDED - int crc; + uint32_t crc; unsigned char *envptr = &environment, *dataptr = envptr + ENV_HEADER_SIZE; unsigned int datasize = ENV_SIZE; -- cgit v1.2.1