Package: mtd-utils
Version: 1:2.0.0-1
Tags: patch, fixed-upstream, stretch

mtd-utils 2.0.0 uses the same printf format specifier for both off_t and loff_t,
but on some 32 bit platforms, the size of the two can differ, resulting in
nonsensical progress reports from tools like flash_erase.

This was fixed in upstream commit 5a806911, shortly after the release of
mtd-utils 2.0.0.

This patch includes the changes made by commit 5a806911 for Debian stretch
which currently contains an unpatched mtd-utils 2.0.0.

Signed-off-by: Torsten Fleischer <torfl6...@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollen...@sigma-star.at>
---
 configure.ac                   |  2 +-
 include/common.h               | 14 +++++++++-----
 tests/mtd-tests/nandpagetest.c |  2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index a5fc3a5..fbef15c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -149,7 +149,7 @@ AM_COND_IF([WITHOUT_LZO], [], [
        test "${have_lzo}" != "yes" && AC_MSG_ERROR([lzo missing])
 ])
 
-AC_CHECK_SIZEOF([long])
+AC_CHECK_SIZEOF([off_t])
 
 AC_CHECK_SIZEOF([loff_t])
 
diff --git a/include/common.h b/include/common.h
index 2812f49..d0c706d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -70,17 +70,21 @@ extern "C" {
 #endif
 
 /* define a print format specifier for off_t */
-#ifdef __USE_FILE_OFFSET64
+#if (SIZEOF_OFF_T >= 8)
 #define PRIxoff_t PRIx64
 #define PRIdoff_t PRId64
 #else
-#if (SIZEOF_LONG == SIZEOF_LOFF_T)
 #define PRIxoff_t "l"PRIx32
 #define PRIdoff_t "l"PRId32
-#else
-#define PRIxoff_t "ll"PRIx32
-#define PRIdoff_t "ll"PRId32
 #endif
+
+/* define a print format specifier for loff_t */
+#if (SIZEOF_LOFF_T >= 8)
+#define PRIxloff_t PRIx64
+#define PRIdloff_t PRId64
+#else
+#define PRIxloff_t "l"PRIx32
+#define PRIdloff_t "l"PRId32
 #endif
 
 /* Verbose messages */
diff --git a/tests/mtd-tests/nandpagetest.c b/tests/mtd-tests/nandpagetest.c
index faf5fe3..4145ef7 100644
--- a/tests/mtd-tests/nandpagetest.c
+++ b/tests/mtd-tests/nandpagetest.c
@@ -230,7 +230,7 @@ static int verify_eraseblock(int ebnum)
                        return err;
 
                if (lseek(fd, addr, SEEK_SET) != addr) {
-                       fprintf(stderr, "cannot seek mtd%d to offset 
%"PRIdoff_t,
+                       fprintf(stderr, "cannot seek mtd%d to offset 
%"PRIdloff_t,
                                        mtd.mtd_num, addr);
                        return -1;
                }
-- 
2.17.1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to