Replace crc32 with tinf_crc32 everywhere.
authorTobias Diedrich <ranma+coreboot@tdiedrich.de>
Wed, 21 Oct 2015 20:03:35 +0000 (22:03 +0200)
committerTobias Diedrich <ranma+coreboot@tdiedrich.de>
Wed, 21 Oct 2015 20:03:35 +0000 (22:03 +0200)
u-boot/common/cmd_bootm.c
u-boot/common/env_common.c
u-boot/common/env_flash.c
u-boot/include/common.h
u-boot/lib_bootstrap/bootstrap_board.c
u-boot/tools/envcrc.c
u-boot/tools/mkimage.c

index d8fd262e92cbf99d0d051a6f4f3252187ae3538f..3c11b59f5187bf3f33a8602f6f82c6da7067328a 100644 (file)
@@ -31,6 +31,7 @@
 #include <LzmaWrapper.h>
 #include <environment.h>
 #include <asm/byteorder.h>
+#include <tinf.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -464,7 +465,7 @@ static int image_info(ulong addr){
        checksum = ntohl(hdr->ih_hcrc);
        hdr->ih_hcrc = 0;
 
-       if(crc32(0, (uchar *)data, len) != checksum){
+       if(tinf_crc32((uchar *)data, len) != checksum){
                puts("## Error: bad header checksum!\n");
                return 1;
        }
@@ -477,7 +478,7 @@ static int image_info(ulong addr){
 
        puts("   Verifying checksum... ");
 
-       if(crc32(0, (uchar *)data, len) != ntohl(hdr->ih_dcrc)){
+       if(tinf_crc32((uchar *)data, len) != ntohl(hdr->ih_dcrc)){
                puts("bad data CRC!\n");
                return(1);
        }
index 155e4d0f95c3ae0c021b6d7cf0174440c1533a8d..f73fb320c9c5b7a73f6bb5e980cadc1738d01db2 100644 (file)
@@ -29,6 +29,7 @@
 #include <environment.h>
 #include <linux/stddef.h>
 #include <malloc.h>
+#include <tinf.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -134,7 +135,7 @@ int default_environment_size = sizeof(default_environment);
 #endif
 
 void env_crc_update(void){
-       env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
+       env_ptr->crc = tinf_crc32(env_ptr->data, ENV_SIZE);
 }
 
 static uchar env_get_char_init(int index){
index e49b600fdda3b4a48cb9a698b94ba2923c3948a4..1398fbe388f1c3a0447fec2549585189bdbca68b 100644 (file)
@@ -34,6 +34,7 @@
 #include <environment.h>
 #include <linux/stddef.h>
 #include <malloc.h>
+#include <tinf.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -99,8 +100,8 @@ int env_init(void){
        ulong addr1 = (ulong)&(flash_addr->data);
        ulong addr2 = (ulong)&(flash_addr_new->data);
 
-       crc1_ok = (crc32(0, flash_addr->data, ENV_SIZE) == flash_addr->crc);
-       crc2_ok = (crc32(0, flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc);
+       crc1_ok = (tinf_crc32(flash_addr->data, ENV_SIZE) == flash_addr->crc);
+       crc2_ok = (tinf_crc32(flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc);
 
        if(crc1_ok && !crc2_ok){
                gd->env_addr  = addr1;
@@ -193,7 +194,7 @@ Done:
 
 #else /* ! CFG_ENV_ADDR_REDUND */
 int env_init(void){
-       if(crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc){
+       if(tinf_crc32(env_ptr->data, ENV_SIZE) == env_ptr->crc){
                gd->env_addr = (ulong)&(env_ptr->data);
                gd->env_valid = 1;
 
@@ -273,7 +274,7 @@ void env_relocate_spec(void){
                end_addr_new = ltmp;
        }
 
-       if(flash_addr_new->flags != OBSOLETE_FLAG && crc32(0, flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc){
+       if(flash_addr_new->flags != OBSOLETE_FLAG && tinf_crc32(flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc){
                char flag = OBSOLETE_FLAG;
 
                gd->env_valid = 2;
index 82d6614e694584c9e780d9e192671e2184ac0bf1..bb08d77191d6941c5de52453df0cda226a702fc7 100644 (file)
@@ -534,12 +534,6 @@ long       simple_strtol(const char *cp,char **endp,unsigned int base);
 int    sprintf(char * buf, const char *fmt, ...);
 int    vsprintf(char *buf, const char *fmt, va_list args);
 
-/* lib_generic/crc32.c */
-/* Hack: Forces compilation failure if must_be_zero is not zero. */
-#define crc32(must_be_zero, buf, len) \
-       tinf_crc32(buf, len*(sizeof(char[1 - 2*!!(must_be_zero)])))
-uint tinf_crc32(const void *data, uint length);
-
 /* common/console.c */
 int    console_init_f(void);   /* Before relocation; uses the serial  stuff    */
 int    console_init_r(void);   /* After  relocation; uses the console stuff    */
index 8cc6dd317702778351785946320559f4270fb0d5..25e160add8f694b8de2da383eba2bc40efb27265 100644 (file)
@@ -28,6 +28,7 @@
 #include <version.h>
 #include <net.h>
 #include <environment.h>
+#include <tinf.h>
 #include "LzmaWrapper.h"
 
 //#define DEBUG_ENABLE_BOOTSTRAP_PRINTF
@@ -243,7 +244,7 @@ void bootstrap_board_init_r(gd_t *id, ulong dest_addr){
        checksum = ntohl(hdr->ih_hcrc);
        hdr->ih_hcrc = 0;
 
-       if(crc32(0, (unsigned char *)data, len) != checksum){
+       if(tinf_crc32((unsigned char *)data, len) != checksum){
                return;
        }
 
index 7b7718324e13860f9167ffc0ebec600ff59ad9f8..179e44b2c0e665e571f174745e73f8d7113a69b3 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <tinf.h>
 
 #ifndef __ASSEMBLY__
 #define        __ASSEMBLY__                    /* Dirty trick to get only #defines     */
@@ -66,8 +67,6 @@
 #define ENV_SIZE (CFG_ENV_SIZE - ENV_HEADER_SIZE)
 
 
-extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
-
 #ifdef ENV_IS_EMBEDDED
 extern unsigned int env_size;
 extern unsigned char environment;
@@ -81,7 +80,7 @@ int main (int argc, char **argv)
                *dataptr = envptr + ENV_HEADER_SIZE;
        unsigned int datasize = ENV_SIZE;
 
-       crc = crc32 (0, dataptr, datasize);
+       crc = tinf_crc32 (dataptr, datasize);
 
        /* Check if verbose mode is activated passing a parameter to the program */
        if (argc > 1) {
index de8af90d1afbb8d032998f27f33c113649631358..2d4ab04d2065194c42eec1a9548585a4768fa7a8 100644 (file)
@@ -32,6 +32,7 @@
 #include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
+#include <tinf.h>
 
 #if defined(__BEOS__) || defined(__NetBSD__) || defined(__APPLE__)
 #include <inttypes.h>
@@ -68,11 +69,6 @@ extern int errno;
 
 char *cmdname;
 
-#include <tinf.h>
-/* Hack: Forces compilation failure if must_be_zero is not zero. */
-#define crc32(must_be_zero, buf, len) \
-       tinf_crc32(buf, len*(sizeof(char[1 - 2*!!(must_be_zero)])))
-
 typedef struct table_entry {
        int     val;            /* as defined in image.h        */
        char    *sname;         /* short (input) name           */
@@ -349,7 +345,7 @@ NXTARG:             ;
                checksum = ntohl(hdr->ih_hcrc);
                hdr->ih_hcrc = htonl(0);        /* clear for re-calculation */
 
-               if (crc32 (0, data, len) != checksum) {
+               if (tinf_crc32 (data, len) != checksum) {
                        fprintf (stderr,
                                "*** Warning: \"%s\" has bad header checksum!\n",
                                imagefile);
@@ -358,7 +354,7 @@ NXTARG:             ;
                data = (char *)(ptr + sizeof(image_header_t));
                len  = sbuf.st_size - sizeof(image_header_t) ;
 
-               if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) {
+               if (tinf_crc32 (data, len) != ntohl(hdr->ih_dcrc)) {
                        fprintf (stderr,
                                "*** Warning: \"%s\" has corrupted data!\n",
                                imagefile);
@@ -467,7 +463,7 @@ NXTARG:             ;
 
        hdr = (image_header_t *)ptr;
 
-       checksum = crc32 (0,
+       checksum = tinf_crc32 (
                          (const char *)(ptr + sizeof(image_header_t)),
                          sbuf.st_size - sizeof(image_header_t)
                         );
@@ -486,7 +482,7 @@ NXTARG:             ;
 
        strncpy((char *)hdr->ih_name, name, IH_NMLEN);
 
-       checksum = crc32(0,(const char *)hdr,sizeof(image_header_t));
+       checksum = tinf_crc32((const char *)hdr,sizeof(image_header_t));
 
        hdr->ih_hcrc = htonl(checksum);