From f3f3a208048eac5f8b5752a17ebcd44db9230fd8 Mon Sep 17 00:00:00 2001 From: Richard Genoud Date: Wed, 12 Sep 2012 16:38:34 +0200 Subject: consistency between u_int32_t / off_t / off64_t We should use the off_t type instead of off64_t or u_int32_t as its length is controlled by the WITHOUT_LARGEFILE flag. Signed-off-by: Richard Genoud Signed-off-by: Artem Bityutskiy --- mtd_debug.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'mtd_debug.c') diff --git a/mtd_debug.c b/mtd_debug.c index 2d307a9..9110e9b 100644 --- a/mtd_debug.c +++ b/mtd_debug.c @@ -103,7 +103,7 @@ void printsize(u_int32_t x) printf("(%u%c)", x, flags[i]); } -int flash_to_file(int fd, u_int32_t offset, size_t len, const char *filename) +int flash_to_file(int fd, off_t offset, size_t len, const char *filename) { u_int8_t *buf = NULL; int outfd, err; @@ -157,7 +157,7 @@ retry: if (buf != NULL) free(buf); close(outfd); - printf("Copied %zu bytes from address 0x%.8x in flash to %s\n", len, offset, filename); + printf("Copied %zu bytes from address 0x%.8"PRIxoff_t" in flash to %s\n", len, offset, filename); return 0; err2: @@ -169,7 +169,7 @@ err0: return 1; } -int file_to_flash(int fd, u_int32_t offset, u_int32_t len, const char *filename) +int file_to_flash(int fd, off_t offset, u_int32_t len, const char *filename) { u_int8_t *buf = NULL; FILE *fp; @@ -221,7 +221,7 @@ retry: if (buf != NULL) free(buf); fclose(fp); - printf("Copied %d bytes from %s to address 0x%.8x in flash\n", len, filename, offset); + printf("Copied %d bytes from %s to address 0x%.8"PRIxoff_t" in flash\n", len, filename, offset); return 0; } @@ -376,13 +376,13 @@ int main(int argc, char *argv[]) showinfo(fd); break; case OPT_READ: - err = flash_to_file(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0), argv[5]); + err = flash_to_file(fd, strtoll(argv[3], NULL, 0), strtoul(argv[4], NULL, 0), argv[5]); break; case OPT_WRITE: - err = file_to_flash(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0), argv[5]); + err = file_to_flash(fd, strtoll(argv[3], NULL, 0), strtoul(argv[4], NULL, 0), argv[5]); break; case OPT_ERASE: - err = erase_flash(fd, strtol(argv[3], NULL, 0), strtol(argv[4], NULL, 0)); + err = erase_flash(fd, strtoul(argv[3], NULL, 0), strtoul(argv[4], NULL, 0)); break; } -- cgit v1.2.3