diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2013-12-06 08:23:24 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-12-06 08:23:24 +0100 |
commit | e9ea6eeaabb15258dbeefe06a421fca8c2fe9baa (patch) | |
tree | 075fbf70c17a50190c3fb290eb6b362177f0d1e5 /commands | |
parent | 18aa86831ed72380b7c2edba3c27bbf7a999da76 (diff) | |
parent | 1e7f2bd25c28b36c7c40ed4797b2a21cc4e1502e (diff) | |
download | barebox-e9ea6eeaabb15258dbeefe06a421fca8c2fe9baa.tar.gz barebox-e9ea6eeaabb15258dbeefe06a421fca8c2fe9baa.tar.xz |
Merge branch 'for-next/misc'
Conflicts:
scripts/Makefile
Diffstat (limited to 'commands')
-rw-r--r-- | commands/crc.c | 63 | ||||
-rw-r--r-- | commands/detect.c | 1 | ||||
-rw-r--r-- | commands/filetype.c | 2 | ||||
-rw-r--r-- | commands/loadenv.c | 1 | ||||
-rw-r--r-- | commands/nandtest.c | 4 |
5 files changed, 9 insertions, 62 deletions
diff --git a/commands/crc.c b/commands/crc.c index ee8dacff0b..824dda4c7d 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -21,66 +21,8 @@ #include <command.h> #include <fs.h> #include <getopt.h> -#include <fcntl.h> -#include <errno.h> -#include <xfuncs.h> #include <malloc.h> -#include <linux/ctype.h> - -static int file_crc(char* filename, ulong start, ulong size, ulong *crc, - ulong *total) -{ - int fd, now; - int ret = 0; - char *buf; - - *total = 0; - *crc = 0; - - fd = open(filename, O_RDONLY); - if (fd < 0) { - printf("open %s: %s\n", filename, errno_str()); - return fd; - } - - if (start > 0) { - off_t lseek_ret; - errno = 0; - lseek_ret = lseek(fd, start, SEEK_SET); - if (lseek_ret == (off_t)-1 && errno) { - perror("lseek"); - ret = -1; - goto out; - } - } - - buf = xmalloc(4096); - - while (size) { - now = min((ulong)4096, size); - now = read(fd, buf, now); - if (now < 0) { - ret = now; - perror("read"); - goto out_free; - } - if (!now) - break; - *crc = crc32(*crc, buf, now); - size -= now; - *total += now; - } - - printf ("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx", - filename, start, start + *total - 1, *crc); - -out_free: - free(buf); -out: - close(fd); - - return ret; -} +#include <environment.h> static int crc_from_file(const char* file, ulong *crc) { @@ -143,6 +85,9 @@ static int do_crc(int argc, char *argv[]) if (file_crc(filename, start, size, &crc, &total) < 0) return 1; + printf("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx", + filename, (ulong)start, (ulong)start + total - 1, crc); + #ifdef CONFIG_CMD_CRC_CMP if (vfilename) { size = total; diff --git a/commands/detect.c b/commands/detect.c index 15055e78bc..499994ba78 100644 --- a/commands/detect.c +++ b/commands/detect.c @@ -21,6 +21,7 @@ #include <complete.h> #include <driver.h> #include <getopt.h> +#include <errno.h> static int do_detect(int argc, char *argv[]) { diff --git a/commands/filetype.c b/commands/filetype.c index 20d335bd6d..f82a4616b1 100644 --- a/commands/filetype.c +++ b/commands/filetype.c @@ -12,7 +12,7 @@ #include <magicvar.h> #include <getopt.h> #include <linux/stat.h> -#include <fs.h> +#include <errno.h> static int do_filetype(int argc, char *argv[]) { diff --git a/commands/loadenv.c b/commands/loadenv.c index 14b964340b..df0df27a9d 100644 --- a/commands/loadenv.c +++ b/commands/loadenv.c @@ -24,6 +24,7 @@ #include <getopt.h> #include <command.h> #include <envfs.h> +#include <errno.h> #include <fs.h> static int do_loadenv(int argc, char *argv[]) diff --git a/commands/nandtest.c b/commands/nandtest.c index f6e8f99892..0da5444c02 100644 --- a/commands/nandtest.c +++ b/commands/nandtest.c @@ -163,8 +163,8 @@ static void print_stats(int nr_passes, int length) for (i = 0; i < MAX_ECC_BITS; i++) printf("ECC %d bit error(s) : %d\n", i + 1, ecc_stats[i]); - printf("ECC >%d bit error(s) : %d\n", MAX_ECC_BITS, ecc_stats_over); - printf("ECC corrections failed : %d\n", ecc_failed_cnt); + printf("ECC >%d bit error(s) : %u\n", MAX_ECC_BITS, ecc_stats_over); + printf("ECC corrections failed : %u\n", ecc_failed_cnt); printf("-------------------------\n"); } |