]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
NetStar: make crcit utility more readable
authorLadislav Michl <Ladislav.Michl@seznam.cz>
Wed, 27 Jan 2010 16:12:23 +0000 (11:12 -0500)
committerTom Rix <Tom.Rix@windriver.com>
Fri, 12 Feb 2010 18:31:54 +0000 (12:31 -0600)
This patch makes the crcit utility more readable

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
board/netstar/crcit.c

index e0cea9b3fb6e12f2e6ac0fe3cb123f4b153862eb..0eef41a11ed50a6c65f9db970abb19c4a3ec9c2a 100644 (file)
@@ -56,13 +56,14 @@ static int do_crc(char *path, unsigned version)
                fprintf(stderr, "File too large\n");
                return EXIT_FAILURE;
        }
-       size = (size + 3) & ~3; /* round up to 4 bytes */
-       data[0] = size + 4;     /* add size of version field */
+       size  = (size + 3) & ~3;        /* round up to 4 bytes */
+       size += 4;                      /* add size of version field */
+       data[0] = size;
        data[1] = version;
-       data[2 + (size >> 2)] = crc32(0, (unsigned char *)(data + 1), data[0]);
+       data[size/4 + 1] = crc32(0, (unsigned char *)(data + 1), size);
        close(fd);
 
-       if (write(STDOUT_FILENO, data, size + 3*4) == -1) {
+       if (write(STDOUT_FILENO, data, size + 4 /*size*/ + 4 /*crc*/) == -1) {
                perror("Error writing file");
                return EXIT_FAILURE;
        }