public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ladislav Michl <ladis@linux-mips.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/5] NetStar: update crcit utility
Date: Mon, 16 Mar 2009 23:31:20 +0100	[thread overview]
Message-ID: <20090316223120.GF1879@localhost.localdomain> (raw)
In-Reply-To: <20090316222620.GA1879@localhost.localdomain>

Make crc32 function to match its prototype. Use more meaningful identifiers.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>

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");
 

      parent reply	other threads:[~2009-03-16 22:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-13 13:31 [U-Boot] [PATCH] Update board NetStar Ladislav Michl
2009-03-16 22:26 ` Ladislav Michl
2009-03-16 22:27   ` [U-Boot] [PATCH 1/5] NetStar: config reindentation Ladislav Michl
2009-03-18 19:42     ` Wolfgang Denk
2009-03-16 22:28   ` [U-Boot] [PATCH 2/5] NetStar: Fix NAND Ladislav Michl
2009-03-17 17:17     ` Scott Wood
2009-03-17 19:50       ` Ladislav Michl
2009-03-17 19:10         ` Scott Wood
2009-03-16 22:29   ` [U-Boot] [PATCH 3/5] NetStar: use generic flash driver Ladislav Michl
2009-03-18 19:44     ` Wolfgang Denk
2009-03-25  0:14       ` Ladislav Michl
2009-03-16 22:30   ` [U-Boot] [PATCH 4/5] NetStar: add RTC support Ladislav Michl
2009-03-16 22:31   ` Ladislav Michl [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090316223120.GF1879@localhost.localdomain \
    --to=ladis@linux-mips.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox