summaryrefslogtreecommitdiff
path: root/board/netstar/crcit.c
diff options
context:
space:
mode:
authorLadislav Michl <ladis@linux-mips.org>2009-03-16 23:31:20 +0100
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2009-03-29 16:04:51 +0200
commit3f464b0fc009d41d2734c08e472eb6d445f73a5c (patch)
tree86f2f7a67c0caf5865a378243c41d26cd7f7d6b3 /board/netstar/crcit.c
parent488f5d8790c451fc527fe5d2ef218f2a5e40ea17 (diff)
downloadu-boot-imx-3f464b0fc009d41d2734c08e472eb6d445f73a5c.zip
u-boot-imx-3f464b0fc009d41d2734c08e472eb6d445f73a5c.tar.gz
u-boot-imx-3f464b0fc009d41d2734c08e472eb6d445f73a5c.tar.bz2
NetStar: update crcit utility
Make crc32 function to match its prototype. Use more meaningful identifiers. Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Diffstat (limited to 'board/netstar/crcit.c')
-rw-r--r--board/netstar/crcit.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/board/netstar/crcit.c b/board/netstar/crcit.c
index ce98e20..e0cea9b 100644
--- a/board/netstar/crcit.c
+++ b/board/netstar/crcit.c
@@ -31,11 +31,11 @@
#include <sys/stat.h>
#include "crcek.h"
-extern unsigned long crc32(unsigned long, const unsigned char *, unsigned int);
+extern uint32_t crc32(uint32_t, const unsigned char *, uint);
-uint32_t data[LOADER_SIZE/4 + 3];
+static uint32_t data[LOADER_SIZE/4 + 3];
-int doit(char *path, unsigned version)
+static int do_crc(char *path, unsigned version)
{
uint32_t *p;
ssize_t size;
@@ -56,10 +56,10 @@ int doit(char *path, unsigned version)
fprintf(stderr, "File too large\n");
return EXIT_FAILURE;
}
- size = (((size - 1) >> 2) + 1) << 2;
+ size = (size + 3) & ~3; /* round up to 4 bytes */
data[0] = size + 4; /* add size of version field */
data[1] = version;
- data[(size >> 2) + 2] = crc32(0, (unsigned char *)(data + 1), data[0]);
+ data[2 + (size >> 2)] = crc32(0, (unsigned char *)(data + 1), data[0]);
close(fd);
if (write(STDOUT_FILENO, data, size + 3*4) == -1) {
@@ -73,12 +73,12 @@ int doit(char *path, unsigned version)
int main(int argc, char **argv)
{
if (argc == 2) {
- return doit(argv[1], 0);
+ return do_crc(argv[1], 0);
} else if ((argc == 4) && (strcmp(argv[1], "-v") == 0)) {
char *endptr, *nptr = argv[2];
unsigned ver = strtoul(nptr, &endptr, 0);
if (*nptr != '\0' && *endptr == '\0')
- return doit(argv[3], ver);
+ return do_crc(argv[3], ver);
}
fprintf(stderr, "Usage: crcit [-v version] <image>\n");