Hello community,

here is the log from the commit of package mtd-utils for openSUSE:Factory 
checked in at 2018-07-10 16:15:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mtd-utils (Old)
 and      /work/SRC/openSUSE:Factory/.mtd-utils.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "mtd-utils"

Tue Jul 10 16:15:50 2018 rev:5 rq:621716 version:2.0.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/mtd-utils/mtd-utils.changes      2017-08-28 
15:33:33.630458088 +0200
+++ /work/SRC/openSUSE:Factory/.mtd-utils.new/mtd-utils.changes 2018-07-10 
16:16:41.569418861 +0200
@@ -1,0 +2,24 @@
+Mon Jul  9 13:13:38 UTC 2018 - [email protected]
+
+- Update to version 2.0.2:
+  * libmtd: Add support to access OOB available size
+  * mkfs.ubifs: Allow root entry in device table
+  * Fix unit-test header and file paths for out of tree builds
+  * Fix unit test mockup for oobavail sysfs file
+  * misc-utils: flash_erase: Fix Jffs2 type flash erase problem
+  * libmtd_legacy: Fix some function description mismatches
+  * mtd-utils: ubifs: fix typo in without_lzo definition
+  * mtd: tests: check erase block count in page test
+  * mtd: unittests: Stop testing stat() calls
+  * mtd: unittests: Decode arg size from ioctl request
+  * mtd: unittests: Use proper unsigned long type for ioctl requests
+  * mtd: tests: Fix check on ebcnt in nandpagetest
+  * ubi-utils: ubicrc32: process command line arguments first
+  * nandbiterrs: Fix erroneous counter increment in for loop body
+  * jittertest: Use the appropriate versions of abs()
+  * Mark or fix switch cases that fall through
+  * mkfs.ubifs: ignore EOPNOTSUPP when listing extended attributes
+  * misc-utils: initialize "ip" in docfdisk to NULL
+  * mkfs.ubifs: Apply squash-uids to the root node
+
+-------------------------------------------------------------------

Old:
----
  mtd-utils-2.0.1.tar.bz2
  mtd-utils-2.0.1.tar.bz2.asc

New:
----
  mtd-utils-2.0.2.tar.bz2
  mtd-utils-2.0.2.tar.bz2.asc

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ mtd-utils.spec ++++++
--- /var/tmp/diff_new_pack.gt3PcG/_old  2018-07-10 16:16:42.033418143 +0200
+++ /var/tmp/diff_new_pack.gt3PcG/_new  2018-07-10 16:16:42.033418143 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package mtd-utils
 #
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,12 +17,12 @@
 
 
 Name:           mtd-utils
-Version:        2.0.1
+Version:        2.0.2
 Release:        0
 Summary:        Tools for maintaining Memory Technology Devices
-License:        GPL-2.0+
+License:        GPL-2.0-or-later
 Group:          System/Filesystems
-Url:            http://www.linux-mtd.infradead.org/
+URL:            http://www.linux-mtd.infradead.org/
 Source0:        
ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-%{version}.tar.bz2
 Source1:        
ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-%{version}.tar.bz2.asc
 Source2:        %{name}.keyring
@@ -49,7 +49,8 @@
 %make_install
 
 %files
-%doc COPYING ubifs-utils/mkfs.ubifs/README
+%license COPYING
+%doc ubifs-utils/mkfs.ubifs/README
 %{_sbindir}/doc_loadbios
 %{_sbindir}/docfdisk
 %{_sbindir}/flash_erase
@@ -92,7 +93,7 @@
 %{_sbindir}/ubirmvol
 %{_sbindir}/ubirsvol
 %{_sbindir}/ubiupdatevol
-%{_mandir}/man1/mkfs.jffs2.1%{ext_man}
-%{_mandir}/man8/ubinize.8%{ext_man}
+%{_mandir}/man1/mkfs.jffs2.1%{?ext_man}
+%{_mandir}/man8/ubinize.8%{?ext_man}
 
 %changelog

++++++ mtd-utils-2.0.1.tar.bz2 -> mtd-utils-2.0.2.tar.bz2 ++++++
++++ 2931 lines of diff (skipped)
++++    retrying with extended exclude list
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/Makefile.am new/mtd-utils-2.0.2/Makefile.am
--- old/mtd-utils-2.0.1/Makefile.am     2017-07-03 22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/Makefile.am     2017-12-05 14:46:02.000000000 +0100
@@ -12,6 +12,7 @@
 
 sbin_PROGRAMS =
 sbin_SCRIPTS =
+check_PROGRAMS =
 noinst_LIBRARIES =
 noinst_PROGRAMS =
 noinst_SCRIPTS =
@@ -20,6 +21,7 @@
 dist_man1_MANS =
 dist_man8_MANS =
 
+TESTS =
 EXTRA_DIST =
 
 GLOBAL_HEADER = \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/compile new/mtd-utils-2.0.2/compile
--- old/mtd-utils-2.0.1/compile 2017-02-10 07:47:11.000000000 +0100
+++ new/mtd-utils-2.0.2/compile 2017-08-15 09:25:07.000000000 +0200
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Wrapper for compilers which do not understand '-c -o'.
 
-scriptversion=2012-10-14.11; # UTC
+scriptversion=2016-01-11.22; # UTC
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2017 Free Software Foundation, Inc.
 # Written by Tom Tromey <[email protected]>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -255,7 +255,8 @@
     echo "compile $scriptversion"
     exit $?
     ;;
-  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+  icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
     func_cl_wrapper "$@"      # Doesn't return...
     ;;
 esac
@@ -342,6 +343,6 @@
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/configure.ac new/mtd-utils-2.0.2/configure.ac
--- old/mtd-utils-2.0.1/configure.ac    2017-08-24 14:36:15.000000000 +0200
+++ new/mtd-utils-2.0.2/configure.ac    2018-04-16 17:54:32.000000000 +0200
@@ -1,6 +1,6 @@
 AC_PREREQ([2.60])
 
-m4_define([RELEASE], 2.0.1)
+m4_define([RELEASE], 2.0.2)
 
 AC_INIT([mtd-utils], [RELEASE], [[email protected]], mtd-utils)
 
@@ -40,6 +40,10 @@
 UL_WARN_ADD([-Wunused-parameter])
 UL_WARN_ADD([-Wunused-result])
 UL_WARN_ADD([-Wunused-variable])
+UL_WARN_ADD([-Wduplicated-cond])
+UL_WARN_ADD([-Wduplicated-branches])
+UL_WARN_ADD([-Wrestrict])
+UL_WARN_ADD([-Wnull-dereference])
 
 UL_WARN_ADD([-Wno-shadow])
 UL_WARN_ADD([-Wno-sign-compare])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/include/common.h new/mtd-utils-2.0.2/include/common.h
--- old/mtd-utils-2.0.1/include/common.h        2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/include/common.h        2018-04-10 20:49:11.000000000 
+0200
@@ -129,6 +129,13 @@
        fprintf(stderr, "%s: warning!: " fmt "\n", PROGRAM_NAME, 
##__VA_ARGS__); \
 } while(0)
 
+/* for tagging functions that always exit */
+#if defined(__GNUC__) || defined(__clang__)
+       #define NORETURN __attribute__((noreturn))
+#else
+       #define NORETURN
+#endif
+
 /**
  * prompt the user for confirmation
  */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/include/config.h new/mtd-utils-2.0.2/include/config.h
--- old/mtd-utils-2.0.1/include/config.h        2017-08-24 14:36:25.000000000 
+0200
+++ new/mtd-utils-2.0.2/include/config.h        2018-04-16 17:54:43.000000000 
+0200
@@ -62,7 +62,7 @@
 #define PACKAGE_NAME "mtd-utils"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "mtd-utils 2.0.1"
+#define PACKAGE_STRING "mtd-utils 2.0.2"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "mtd-utils"
@@ -71,7 +71,7 @@
 #define PACKAGE_URL ""
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "2.0.1"
+#define PACKAGE_VERSION "2.0.2"
 
 /* Define to necessary symbol if this constant uses a non-standard name on
    your system. */
@@ -87,4 +87,4 @@
 #define STDC_HEADERS 1
 
 /* Version number of package */
-#define VERSION "2.0.1"
+#define VERSION "2.0.2"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/include/libmtd.h new/mtd-utils-2.0.2/include/libmtd.h
--- old/mtd-utils-2.0.1/include/libmtd.h        2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/include/libmtd.h        2018-04-10 20:50:00.000000000 
+0200
@@ -66,6 +66,7 @@
  * @min_io_size: minimum input/output unit size
  * @subpage_size: sub-page size
  * @oob_size: OOB size (zero if the device does not have OOB area)
+ * @oobavail: free OOB size
  * @region_cnt: count of additional erase regions
  * @writable: zero if the device is read-only
  * @bb_allowed: non-zero if the MTD device may have bad eraseblocks
@@ -84,6 +85,7 @@
        int min_io_size;
        int subpage_size;
        int oob_size;
+       int oobavail;
        int region_cnt;
        unsigned int writable:1;
        unsigned int bb_allowed:1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/include/libscan.h new/mtd-utils-2.0.2/include/libscan.h
--- old/mtd-utils-2.0.1/include/libscan.h       2016-11-17 12:46:31.000000000 
+0100
+++ new/mtd-utils-2.0.2/include/libscan.h       2017-11-23 00:51:18.000000000 
+0100
@@ -68,7 +68,7 @@
  * @corrupted_cnt: count of eraseblocks with corrupted erase counter header
  * @alien_cnt: count of eraseblock containing non-ubi data
  * @bad_cnt: count of bad eraseblocks
- * @bad_cnt: count of non-bad eraseblocks
+ * @good_cnt: count of non-bad eraseblocks
  * @vid_hdr_offs: volume ID header offset from the found EC headers (%-1 means
  *                undefined)
  * @data_offs: data offset from the found EC headers (%-1 means undefined)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/include/stamp-h1 new/mtd-utils-2.0.2/include/stamp-h1
--- old/mtd-utils-2.0.1/include/stamp-h1        2017-08-24 14:36:25.000000000 
+0200
+++ new/mtd-utils-2.0.2/include/stamp-h1        1970-01-01 01:00:00.000000000 
+0100
@@ -1 +0,0 @@
-timestamp for include/config.h
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/lib/common.c new/mtd-utils-2.0.2/lib/common.c
--- old/mtd-utils-2.0.1/lib/common.c    2016-11-17 12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/lib/common.c    2018-01-30 13:05:25.000000000 +0100
@@ -107,6 +107,9 @@
 void util_print_bytes(long long bytes, int bracket)
 {
        const char *p;
+       int GiB = 1024 * 1024 * 1024;
+       int MiB = 1024 * 1024;
+       int KiB = 1024;
 
        if (bracket)
                p = " (";
@@ -115,12 +118,15 @@
 
        printf("%lld bytes", bytes);
 
-       if (bytes > 1024 * 1024 * 1024)
-               printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
-       else if (bytes > 1024 * 1024)
-               printf("%s%.1f MiB", p, (double)bytes / (1024 * 1024));
-       else if (bytes > 1024 && bytes != 0)
-               printf("%s%.1f KiB", p, (double)bytes / 1024);
+       if (bytes > GiB)
+               printf("%s%lld.%lld GiB", p,
+                      bytes / GiB, bytes % GiB / (GiB / 10));
+       else if (bytes > MiB)
+               printf("%s%lld.%lld MiB", p,
+                       bytes / MiB, bytes % MiB / (MiB / 10));
+       else if (bytes > KiB && bytes != 0)
+               printf("%s%lld.%lld KiB", p,
+                       bytes / KiB, bytes % KiB / (KiB / 10));
        else
                return;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/lib/libmtd.c new/mtd-utils-2.0.2/lib/libmtd.c
--- old/mtd-utils-2.0.1/lib/libmtd.c    2017-07-03 22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/lib/libmtd.c    2018-04-10 20:50:00.000000000 +0200
@@ -422,7 +422,7 @@
 }
 
 /**
- * dev_node2num - find UBI device number by its character device node.
+ * dev_node2num - find MTD device number by its character device node.
  * @lib: MTD library descriptor
  * @node: name of the MTD device node
  * @mtd_num: MTD device number is returned here
@@ -614,6 +614,10 @@
        if (!lib->mtd_oob_size)
                goto out_error;
 
+       lib->mtd_oobavail = mkpath(lib->mtd, MTD_OOBAVAIL);
+       if (!lib->mtd_oobavail)
+               goto out_error;
+
        lib->mtd_region_cnt = mkpath(lib->mtd, MTD_REGION_CNT);
        if (!lib->mtd_region_cnt)
                goto out_error;
@@ -637,6 +641,7 @@
        free(lib->mtd_flags);
        free(lib->mtd_region_cnt);
        free(lib->mtd_oob_size);
+       free(lib->mtd_oobavail);
        free(lib->mtd_subpage_size);
        free(lib->mtd_min_io_size);
        free(lib->mtd_size);
@@ -769,6 +774,15 @@
                return -1;
        if (dev_read_pos_int(lib->mtd_oob_size, mtd_num, &mtd->oob_size))
                return -1;
+       if (dev_read_pos_int(lib->mtd_oobavail, mtd_num, &mtd->oobavail)) {
+               /*
+                * Fail to access oobavail sysfs file,
+                * try ioctl ECCGETLAYOUT. */
+               mtd->oobavail = legacy_get_mtd_oobavail1(mtd_num);
+               /* Set 0 as default if can not get valid ecc layout */
+               if (mtd->oobavail < 0)
+                       mtd->oobavail = 0;
+       }
        if (dev_read_pos_int(lib->mtd_region_cnt, mtd_num, &mtd->region_cnt))
                return -1;
        if (dev_read_hex_int(lib->mtd_flags, mtd_num, &ret))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/lib/libmtd_int.h new/mtd-utils-2.0.2/lib/libmtd_int.h
--- old/mtd-utils-2.0.1/lib/libmtd_int.h        2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/lib/libmtd_int.h        2018-04-10 20:50:00.000000000 
+0200
@@ -44,6 +44,7 @@
 #define MTD_MIN_IO_SIZE  "writesize"
 #define MTD_SUBPAGE_SIZE "subpagesize"
 #define MTD_OOB_SIZE     "oobsize"
+#define MTD_OOBAVAIL     "oobavail"
 #define MTD_REGION_CNT   "numeraseregions"
 #define MTD_FLAGS        "flags"
 
@@ -63,6 +64,7 @@
  * @mtd_min_io_size: minimum I/O unit size file pattern
  * @mtd_subpage_size: sub-page size file pattern
  * @mtd_oob_size: MTD device OOB size file pattern
+ * @mtd_oobavail: MTD device free OOB size file pattern
  * @mtd_region_cnt: count of additional erase regions file pattern
  * @mtd_flags: MTD device flags file pattern
  * @sysfs_supported: non-zero if sysfs is supported by MTD
@@ -92,6 +94,7 @@
        char *mtd_min_io_size;
        char *mtd_subpage_size;
        char *mtd_oob_size;
+       char *mtd_oobavail;
        char *mtd_region_cnt;
        char *mtd_flags;
        unsigned int sysfs_supported:1;
@@ -103,6 +106,8 @@
 int legacy_mtd_get_info(struct mtd_info *info);
 int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd);
 int legacy_get_dev_info1(int dev_num, struct mtd_dev_info *mtd);
+int legacy_get_mtd_oobavail(const char *node);
+int legacy_get_mtd_oobavail1(int mtd_num);
 
 #ifdef __cplusplus
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/lib/libmtd_legacy.c new/mtd-utils-2.0.2/lib/libmtd_legacy.c
--- old/mtd-utils-2.0.1/lib/libmtd_legacy.c     2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/lib/libmtd_legacy.c     2018-04-10 20:50:00.000000000 
+0200
@@ -54,7 +54,7 @@
  * @name: device name
  * @buf: contents of /proc/mtd
  * @data_size: how much data was read into @buf
- * @pos: next string in @buf to parse
+ * @next: next string in @buf to parse
  */
 struct proc_parse_info
 {
@@ -164,8 +164,8 @@
 }
 
 /**
- * legacy_dev_presentl - legacy version of 'mtd_dev_present()'.
- * @info: the MTD device information is returned here
+ * legacy_dev_present - legacy version of 'mtd_dev_present()'.
+ * @mtd_num: MTD device number
  *
  * When the kernel does not provide sysfs files for the MTD subsystem,
  * fall-back to parsing the /proc/mtd file to determine whether an mtd device
@@ -215,6 +215,46 @@
        return 0;
 }
 
+int legacy_get_mtd_oobavail(const char *node)
+{
+       struct stat st;
+       struct nand_ecclayout_user usrlay;
+       int fd, ret;
+
+       if (stat(node, &st))
+               return sys_errmsg("cannot open \"%s\"", node);
+
+       if (!S_ISCHR(st.st_mode)) {
+               errno = EINVAL;
+               return errmsg("\"%s\" is not a character device", node);
+       }
+
+       fd = open(node, O_RDONLY);
+       if (fd == -1)
+               return sys_errmsg("cannot open \"%s\"", node);
+
+       ret = ioctl(fd, ECCGETLAYOUT, &usrlay);
+       if (ret < 0) {
+               sys_errmsg("ECCGETLAYOUT ioctl request failed");
+               goto out_close;
+       }
+
+       ret = usrlay.oobavail;
+
+out_close:
+       close(fd);
+
+       return ret;
+}
+
+int legacy_get_mtd_oobavail1(int mtd_num)
+{
+       char node[sizeof(MTD_DEV_PATT) + 20];
+
+       sprintf(node, MTD_DEV_PATT, mtd_num);
+       return legacy_get_mtd_oobavail(node);
+}
+
 /**
  * legacy_get_dev_info - legacy version of 'mtd_get_dev_info()'.
  * @node: name of the MTD device node
@@ -335,6 +375,9 @@
 
        close(fd);
 
+       ret = legacy_get_mtd_oobavail(node);
+       mtd->oobavail = ret > 0 ? ret : 0;
+
        /*
         * Unfortunately, the device name is not available via ioctl, and
         * we have to parse /proc/mtd to get it.
@@ -361,7 +404,7 @@
 
 /**
  * legacy_get_dev_info1 - legacy version of 'mtd_get_dev_info1()'.
- * @node: name of the MTD device node
+ * @mtd_num: MTD device number
  * @mtd: the MTD device information is returned here
  *
  * This function is similar to 'mtd_get_dev_info1()' and has the same
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/lib/libubi.c new/mtd-utils-2.0.2/lib/libubi.c
--- old/mtd-utils-2.0.1/lib/libubi.c    2017-07-03 22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/lib/libubi.c    2017-11-15 00:29:09.000000000 +0100
@@ -835,8 +835,7 @@
 int ubi_remove_dev(libubi_t desc, const char *node, int ubi_dev)
 {
        int fd, ret;
-
-       desc = desc;
+       (void)desc;
 
        fd = open(node, O_RDONLY);
        if (fd == -1)
@@ -993,10 +992,10 @@
        int fd, ret;
        struct ubi_mkvol_req r;
        size_t n;
+       (void)desc;
 
        memset(&r, 0, sizeof(struct ubi_mkvol_req));
 
-       desc = desc;
        r.vol_id = req->vol_id;
        r.alignment = req->alignment;
        r.bytes = req->bytes;
@@ -1009,7 +1008,6 @@
        strncpy(r.name, req->name, UBI_MAX_VOLUME_NAME + 1);
        r.name_len = n;
 
-       desc = desc;
        fd = open(node, O_RDONLY);
        if (fd == -1)
                return sys_errmsg("cannot open \"%s\"", node);
@@ -1029,8 +1027,8 @@
 int ubi_rmvol(libubi_t desc, const char *node, int vol_id)
 {
        int fd, ret;
+       (void)desc;
 
-       desc = desc;
        fd = open(node, O_RDONLY);
        if (fd == -1)
                return sys_errmsg("cannot open \"%s\"", node);
@@ -1049,8 +1047,8 @@
 int ubi_rnvols(libubi_t desc, const char *node, struct ubi_rnvol_req *rnvol)
 {
        int fd, ret;
+       (void)desc;
 
-       desc = desc;
        fd = open(node, O_RDONLY);
        if (fd == -1)
                return -1;
@@ -1070,8 +1068,8 @@
 {
        int fd, ret;
        struct ubi_rsvol_req req;
+       (void)desc;
 
-       desc = desc;
        fd = open(node, O_RDONLY);
        if (fd == -1)
                return sys_errmsg("cannot open \"%s\"", node);
@@ -1096,7 +1094,7 @@
 
 int ubi_update_start(libubi_t desc, int fd, long long bytes)
 {
-       desc = desc;
+       (void)desc;
        if (ioctl(fd, UBI_IOCVOLUP, &bytes))
                return -1;
        return 0;
@@ -1105,8 +1103,8 @@
 int ubi_leb_change_start(libubi_t desc, int fd, int lnum, int bytes)
 {
        struct ubi_leb_change_req req;
+       (void)desc;
 
-       desc = desc;
        memset(&req, 0, sizeof(struct ubi_leb_change_req));
        req.lnum = lnum;
        req.bytes = bytes;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/misc-utils/docfdisk.c 
new/mtd-utils-2.0.2/misc-utils/docfdisk.c
--- old/mtd-utils-2.0.1/misc-utils/docfdisk.c   2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/misc-utils/docfdisk.c   2017-11-15 00:29:09.000000000 
+0100
@@ -148,7 +148,7 @@
        int ret, i, mhblock, unitsize, block;
        unsigned int nblocks[4], npart;
        unsigned int totblocks;
-       struct INFTLPartition *ip;
+       struct INFTLPartition *ip = NULL;
        unsigned char *oobbuf;
        struct mtd_oob_buf oob;
        char line[20];
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/misc-utils/flash_erase.c 
new/mtd-utils-2.0.2/misc-utils/flash_erase.c
--- old/mtd-utils-2.0.1/misc-utils/flash_erase.c        2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/misc-utils/flash_erase.c        2018-04-10 
20:50:00.000000000 +0200
@@ -92,7 +92,7 @@
 {
        libmtd_t mtd_desc;
        struct mtd_dev_info mtd;
-       int fd;
+       int fd, cmlen = 8;
        unsigned long long start;
        unsigned int eb, eb_start, eb_cnt;
        bool isNAND;
@@ -155,8 +155,10 @@
        default:
        case 0:
                errmsg("no MTD device specified");
+               /* fall-through */
        case 1:
                errmsg("no start erase block specified");
+               /* fall-through */
        case 2:
                errmsg("no erase block count specified");
                error = 1;
@@ -188,10 +190,11 @@
        if (jffs2) {
                cleanmarker.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);
                cleanmarker.nodetype = cpu_to_je16 (JFFS2_NODETYPE_CLEANMARKER);
-               if (!isNAND)
+               if (!isNAND) {
                        cleanmarker.totlen = cpu_to_je32(sizeof(cleanmarker));
-               else {
+               } else {
                        cleanmarker.totlen = cpu_to_je32(8);
+                       cmlen = min(mtd.oobavail, 8);
                }
                cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, 
sizeof(cleanmarker) - 4));
        }
@@ -240,7 +243,7 @@
 
                /* write cleanmarker */
                if (isNAND) {
-                       if (mtd_write(mtd_desc, &mtd, fd, eb, 0, NULL, 0, 
&cleanmarker, 0,
+                       if (mtd_write(mtd_desc, &mtd, fd, eb, 0, NULL, 0, 
&cleanmarker, cmlen,
                                        MTD_OPS_AUTO_OOB) != 0) {
                                sys_errmsg("%s: MTD writeoob failure", 
mtd_device);
                                continue;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/misc-utils/flash_unlock.c 
new/mtd-utils-2.0.2/misc-utils/flash_unlock.c
--- old/mtd-utils-2.0.1/misc-utils/flash_unlock.c       2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/misc-utils/flash_unlock.c       2017-11-15 
00:29:09.000000000 +0100
@@ -36,7 +36,7 @@
        [ REQUEST_ISLOCKED ]    = "check lock status",
 };
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fprintf(status ? stderr : stdout,
                "Utility to lock, unlock, or check the lock status of the 
flash.\n"
@@ -88,7 +88,6 @@
                switch (c) {
                case 'h':
                        usage(EXIT_SUCCESS);
-                       break;
                case 'i':
                        req = REQUEST_ISLOCKED;
                        req_set++;
@@ -106,7 +105,6 @@
                        exit(0);
                default:
                        usage(EXIT_FAILURE);
-                       break;
                }
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/misc-utils/flashcp.c 
new/mtd-utils-2.0.2/misc-utils/flashcp.c
--- old/mtd-utils-2.0.1/misc-utils/flashcp.c    2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/misc-utils/flashcp.c    2017-11-15 00:29:09.000000000 
+0100
@@ -81,7 +81,7 @@
        fflush (fp);
 }
 
-static void showusage(bool error)
+static NORETURN void showusage(bool error)
 {
        int level = error ? LOG_ERROR : LOG_NORMAL;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/misc-utils/mtd_debug.c 
new/mtd-utils-2.0.2/misc-utils/mtd_debug.c
--- old/mtd-utils-2.0.1/misc-utils/mtd_debug.c  2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/misc-utils/mtd_debug.c  2018-02-01 15:49:24.000000000 
+0100
@@ -272,6 +272,7 @@
                        break;
                case MTD_UBIVOLUME:
                        printf("MTD_UBIVOLUME");
+                       break;
                default:
                        printf("(unknown type - new MTD API maybe?)");
        }
@@ -285,8 +286,6 @@
                printf("MTD_CAP_NORFLASH");
        else if (mtd.flags == MTD_CAP_NANDFLASH)
                printf("MTD_CAP_NANDFLASH");
-       else if (mtd.flags == MTD_WRITEABLE)
-               printf("MTD_WRITEABLE");
        else {
                int first = 1;
                static struct {
@@ -339,7 +338,7 @@
        return 0;
 }
 
-static void showusage(void)
+static NORETURN void showusage(void)
 {
        fprintf(stderr, "usage: %1$s info <device>\n"
                        "       %1$s read <device> <offset> <len> 
<dest-filename>\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/missing new/mtd-utils-2.0.2/missing
--- old/mtd-utils-2.0.1/missing 2017-02-10 07:47:11.000000000 +0100
+++ new/mtd-utils-2.0.2/missing 2017-08-15 09:25:07.000000000 +0200
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Common wrapper for a few potentially missing GNU programs.
 
-scriptversion=2013-10-28.13; # UTC
+scriptversion=2016-01-11.22; # UTC
 
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2017 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <[email protected]>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
@@ -210,6 +210,6 @@
 # eval: (add-hook 'write-file-hooks 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/nand-utils/nanddump.c 
new/mtd-utils-2.0.2/nand-utils/nanddump.c
--- old/mtd-utils-2.0.1/nand-utils/nanddump.c   2017-01-18 19:24:11.000000000 
+0100
+++ new/mtd-utils-2.0.2/nand-utils/nanddump.c   2017-11-15 00:29:09.000000000 
+0100
@@ -180,6 +180,7 @@
                                break;
                        case 'c':
                                canonical = true;
+                               /* fall-through */
                        case 'p':
                                pretty_print = true;
                                break;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/nand-utils/nandtest.c 
new/mtd-utils-2.0.2/nand-utils/nandtest.c
--- old/mtd-utils-2.0.1/nand-utils/nandtest.c   2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/nand-utils/nandtest.c   2017-11-15 00:29:09.000000000 
+0100
@@ -17,7 +17,7 @@
 #include "mtd/mtd-user.h"
 #include "common.h"
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fprintf(status ? stderr : stdout,
                "usage: %s [OPTIONS] <device>\n\n"
@@ -184,14 +184,12 @@
                switch (c) {
                case 'h':
                        usage(EXIT_SUCCESS);
-                       break;
                case 'V':
                        common_print_version();
                        exit(EXIT_SUCCESS);
                        break;
                case '?':
                        usage(EXIT_FAILURE);
-                       break;
 
                case 'm':
                        markbad = 1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/nand-utils/nftl_format.c 
new/mtd-utils-2.0.2/nand-utils/nftl_format.c
--- old/mtd-utils-2.0.1/nand-utils/nftl_format.c        2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/nand-utils/nftl_format.c        2017-11-15 
00:29:09.000000000 +0100
@@ -198,7 +198,7 @@
        return (0);
 }
 
-static void usage(int rc)
+static NORETURN void usage(int rc)
 {
        fprintf(stderr, "Usage: %s [-ib] <mtddevice> [<start offset> 
[<size>]]\n", PROGRAM_NAME);
        exit(rc);
@@ -250,13 +250,11 @@
                        case 'h':
                        case '?':
                                usage(EXIT_SUCCESS);
-                               break;
                        case 'V':
                                display_version();
                                break;
                        default:
                                usage(EXIT_FAILURE);
-                               break;
                }
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/test-driver new/mtd-utils-2.0.2/test-driver
--- old/mtd-utils-2.0.1/test-driver     1970-01-01 01:00:00.000000000 +0100
+++ new/mtd-utils-2.0.2/test-driver     2017-08-15 09:25:07.000000000 +0200
@@ -0,0 +1,148 @@
+#! /bin/sh
+# test-driver - basic testsuite driver script.
+
+scriptversion=2016-01-11.22; # UTC
+
+# Copyright (C) 2011-2017 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <[email protected]> or send patches to
+# <[email protected]>.
+
+# Make unconditional expansion of undefined variables an error.  This
+# helps a lot in preventing typo-related bugs.
+set -u
+
+usage_error ()
+{
+  echo "$0: $*" >&2
+  print_usage >&2
+  exit 2
+}
+
+print_usage ()
+{
+  cat <<END
+Usage:
+  test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
+              [--expect-failure={yes|no}] [--color-tests={yes|no}]
+              [--enable-hard-errors={yes|no}] [--]
+              TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
+The '--test-name', '--log-file' and '--trs-file' options are mandatory.
+END
+}
+
+test_name= # Used for reporting.
+log_file=  # Where to save the output of the test script.
+trs_file=  # Where to save the metadata of the test run.
+expect_failure=no
+color_tests=no
+enable_hard_errors=yes
+while test $# -gt 0; do
+  case $1 in
+  --help) print_usage; exit $?;;
+  --version) echo "test-driver $scriptversion"; exit $?;;
+  --test-name) test_name=$2; shift;;
+  --log-file) log_file=$2; shift;;
+  --trs-file) trs_file=$2; shift;;
+  --color-tests) color_tests=$2; shift;;
+  --expect-failure) expect_failure=$2; shift;;
+  --enable-hard-errors) enable_hard_errors=$2; shift;;
+  --) shift; break;;
+  -*) usage_error "invalid option: '$1'";;
+   *) break;;
+  esac
+  shift
+done
+
+missing_opts=
+test x"$test_name" = x && missing_opts="$missing_opts --test-name"
+test x"$log_file"  = x && missing_opts="$missing_opts --log-file"
+test x"$trs_file"  = x && missing_opts="$missing_opts --trs-file"
+if test x"$missing_opts" != x; then
+  usage_error "the following mandatory options are missing:$missing_opts"
+fi
+
+if test $# -eq 0; then
+  usage_error "missing argument"
+fi
+
+if test $color_tests = yes; then
+  # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
+  red='' # Red.
+  grn='' # Green.
+  lgn='' # Light green.
+  blu='' # Blue.
+  mgn='' # Magenta.
+  std=''     # No color.
+else
+  red= grn= lgn= blu= mgn= std=
+fi
+
+do_exit='rm -f $log_file $trs_file; (exit $st); exit $st'
+trap "st=129; $do_exit" 1
+trap "st=130; $do_exit" 2
+trap "st=141; $do_exit" 13
+trap "st=143; $do_exit" 15
+
+# Test script is run here.
+"$@" >$log_file 2>&1
+estatus=$?
+
+if test $enable_hard_errors = no && test $estatus -eq 99; then
+  tweaked_estatus=1
+else
+  tweaked_estatus=$estatus
+fi
+
+case $tweaked_estatus:$expect_failure in
+  0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
+  0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
+  77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
+  99:*)  col=$mgn res=ERROR recheck=yes gcopy=yes;;
+  *:yes) col=$lgn res=XFAIL recheck=no  gcopy=yes;;
+  *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
+esac
+
+# Report the test outcome and exit status in the logs, so that one can
+# know whether the test passed or failed simply by looking at the '.log'
+# file, without the need of also peaking into the corresponding '.trs'
+# file (automake bug#11814).
+echo "$res $test_name (exit status: $estatus)" >>$log_file
+
+# Report outcome to console.
+echo "${col}${res}${std}: $test_name"
+
+# Register the test result, and other relevant metadata.
+echo ":test-result: $res" > $trs_file
+echo ":global-test-result: $res" >> $trs_file
+echo ":recheck: $recheck" >> $trs_file
+echo ":copy-in-global-log: $gcopy" >> $trs_file
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC0"
+# time-stamp-end: "; # UTC"
+# End:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/checkfs/Makemodule.am 
new/mtd-utils-2.0.2/tests/checkfs/Makemodule.am
--- old/mtd-utils-2.0.1/tests/checkfs/Makemodule.am     2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/checkfs/Makemodule.am     2017-11-15 
00:29:09.000000000 +0100
@@ -1,7 +1,7 @@
 checkfs_SOURCES = tests/checkfs/checkfs.c tests/checkfs/comm.c
 checkfs_CPPFLAGS = $(AM_CPPFLAGS)
 
-makefiles_SOURCES = tests/checkfs/makefiles.c tests/checkfs/comm.c
+makefiles_SOURCES = tests/checkfs/makefiles.c
 makefiles_CPPFLAGS = $(AM_CPPFLAGS)
 
 CHECKFS_BINS = \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/fs-tests/integrity/integck.c 
new/mtd-utils-2.0.2/tests/fs-tests/integrity/integck.c
--- old/mtd-utils-2.0.1/tests/fs-tests/integrity/integck.c      2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/tests/fs-tests/integrity/integck.c      2018-02-01 
15:49:24.000000000 +0100
@@ -1164,7 +1164,7 @@
        }
        r = random_no(write_cnt);
        w = file->writes;
-       for (i = 0; w && w->next && i < r; i++)
+       for (i = 0; i < r; i++)
                w = w->next;
 
        offs = (w->offset / fsinfo.page_size) * fsinfo.page_size;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/fs-tests/utils/fstest_monitor.c 
new/mtd-utils-2.0.2/tests/fs-tests/utils/fstest_monitor.c
--- old/mtd-utils-2.0.1/tests/fs-tests/utils/fstest_monitor.c   2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/tests/fs-tests/utils/fstest_monitor.c   2017-11-15 
00:29:09.000000000 +0100
@@ -131,6 +131,7 @@
                                        break;
                                }
                                state = 1;
+                               /* fall-through */
                        case 1: /* Not quoted */
                                if (c == '\\') {
                                        if (*p)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/jittertest/JitterTest.c 
new/mtd-utils-2.0.2/tests/jittertest/JitterTest.c
--- old/mtd-utils-2.0.1/tests/jittertest/JitterTest.c   2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/tests/jittertest/JitterTest.c   2017-11-15 
00:29:09.000000000 +0100
@@ -591,12 +591,12 @@
 
 
         /* Store some historical #'s */
-        if(abs(timeDiffusec) > LastMaxDiff)
+        if(labs(timeDiffusec) > LastMaxDiff)
        {
-            LastMaxDiff = abs(timeDiffusec);
+            LastMaxDiff = labs(timeDiffusec);
             sprintf(&tmpBuf[strlen(tmpBuf)],"!");
 
-           if((GrabKProfile == TRUE) && (ProfileTriggerMSecs < 
(abs(timeDiffusec)/1000)))
+           if((GrabKProfile == TRUE) && (ProfileTriggerMSecs < 
(labs(timeDiffusec)/1000)))
              {
                  sprintf(profileFileName, "JitterTest.profilesnap-%i", 
profileFileNo);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/jittertest/plotJittervsFill.c 
new/mtd-utils-2.0.2/tests/jittertest/plotJittervsFill.c
--- old/mtd-utils-2.0.1/tests/jittertest/plotJittervsFill.c     2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/tests/jittertest/plotJittervsFill.c     2017-11-15 
00:29:09.000000000 +0100
@@ -267,7 +267,7 @@
         }
 
         /* Is the jitter value > threshold value? */
-        if(abs(jitter_ms) > JitterThreshold_ms)
+        if(abs((int)jitter_ms) > JitterThreshold_ms)
         {
             /* Found a jitter line that matches our crietrion.
                Now set flag to be on the look out for the next
@@ -276,7 +276,7 @@
 
             if(saveJitterCnt < MAX_SAVE_BUFFER)
             {
-                saveJitter[saveJitterCnt] = (int)abs(jitter_ms); /* why keep 
the (ms) jitter in float */
+                saveJitter[saveJitterCnt] = abs((int)jitter_ms); /* why keep 
the (ms) jitter in float */
                 dataLineNo[saveJitterCnt] = lineNo;
                 saveJitterCnt++;
                 lookFor_df = TRUE;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/mtd-tests/flash_readtest.c 
new/mtd-utils-2.0.2/tests/mtd-tests/flash_readtest.c
--- old/mtd-utils-2.0.1/tests/mtd-tests/flash_readtest.c        2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/mtd-tests/flash_readtest.c        2017-11-15 
00:29:09.000000000 +0100
@@ -54,7 +54,7 @@
        { NULL, 0, NULL, 0 },
 };
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fputs(
        "Usage: "PROGRAM_NAME" [OPTIONS] <device>\n\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/mtd-tests/flash_speed.c 
new/mtd-utils-2.0.2/tests/mtd-tests/flash_speed.c
--- old/mtd-utils-2.0.1/tests/mtd-tests/flash_speed.c   2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/mtd-tests/flash_speed.c   2017-11-15 
00:29:09.000000000 +0100
@@ -60,7 +60,7 @@
        { NULL, 0, NULL, 0 },
 };
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fputs(
        "Usage: "PROGRAM_NAME" [OPTIONS] <device>\n\n"
@@ -100,7 +100,6 @@
                switch (c) {
                case 'h':
                        usage(EXIT_SUCCESS);
-                       break;
                case 'b':
                        if (peb >= 0)
                                goto failmulti;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/mtd-tests/flash_stress.c 
new/mtd-utils-2.0.2/tests/mtd-tests/flash_stress.c
--- old/mtd-utils-2.0.1/tests/mtd-tests/flash_stress.c  2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/mtd-tests/flash_stress.c  2017-11-15 
00:29:09.000000000 +0100
@@ -63,7 +63,7 @@
        { NULL, 0, NULL, 0 },
 };
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fputs(
        "Usage: "PROGRAM_NAME" [OPTIONS] <device>\n\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/mtd-tests/flash_torture.c 
new/mtd-utils-2.0.2/tests/mtd-tests/flash_torture.c
--- old/mtd-utils-2.0.1/tests/mtd-tests/flash_torture.c 2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/mtd-tests/flash_torture.c 2017-11-15 
00:29:09.000000000 +0100
@@ -67,7 +67,7 @@
                flags &= ~RUN_FOREVER;
 }
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fputs(
        "Usage: "PROGRAM_NAME" [OPTIONS] <device>\n\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/mtd-tests/nandbiterrs.c 
new/mtd-utils-2.0.2/tests/mtd-tests/nandbiterrs.c
--- old/mtd-utils-2.0.1/tests/mtd-tests/nandbiterrs.c   2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/tests/mtd-tests/nandbiterrs.c   2017-11-15 
00:29:09.000000000 +0100
@@ -85,7 +85,7 @@
        { NULL, 0, NULL, 0 },
 };
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fputs(
        "Usage: "PROGRAM_NAME" [OPTIONS] <device>\n\n"
@@ -340,7 +340,6 @@
                                return 0;
                        }
                }
-               ++byte;
        }
        fputs("biterror: Failed to find a '1' bit\n", stderr);
        return -1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/mtd-tests/nandpagetest.c 
new/mtd-utils-2.0.2/tests/mtd-tests/nandpagetest.c
--- old/mtd-utils-2.0.1/tests/mtd-tests/nandpagetest.c  2017-08-24 
13:00:58.000000000 +0200
+++ new/mtd-utils-2.0.2/tests/mtd-tests/nandpagetest.c  2018-03-08 
00:30:27.000000000 +0100
@@ -58,7 +58,7 @@
        { NULL, 0, NULL, 0 },
 };
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fputs(
        "Usage: "PROGRAM_NAME" [OPTIONS] <device>\n\n"
@@ -143,7 +143,7 @@
 
        if (optind < argc)
                usage(EXIT_FAILURE);
-       if (ebcnt < 2)
+       if (ebcnt >= 0 && ebcnt < 2)
                errmsg_die("Cannot run with less than two blocks.");
        if (peb < 0)
                peb = 0;
@@ -551,8 +551,12 @@
        }
        printf("verified %u eraseblocks\n", i);
 
-       if (crosstest())
-               goto out;
+       if (ebcnt > 1) {
+               if (crosstest())
+                       goto out;
+       } else {
+               printf("skipping erasecrosstest, 2 erase blocks needed\n");
+       }
 
        if (erasecrosstest())
                goto out;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/mtd-tests/nandsubpagetest.c 
new/mtd-utils-2.0.2/tests/mtd-tests/nandsubpagetest.c
--- old/mtd-utils-2.0.1/tests/mtd-tests/nandsubpagetest.c       2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/mtd-tests/nandsubpagetest.c       2017-11-15 
00:29:09.000000000 +0100
@@ -57,7 +57,7 @@
        { NULL, 0, NULL, 0 },
 };
 
-static void usage(int status)
+static NORETURN void usage(int status)
 {
        fputs(
        "Usage: "PROGRAM_NAME" [OPTIONS] <device>\n\n"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/ubi-tests/io_update.c 
new/mtd-utils-2.0.2/tests/ubi-tests/io_update.c
--- old/mtd-utils-2.0.1/tests/ubi-tests/io_update.c     2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/tests/ubi-tests/io_update.c     2017-11-15 
00:29:09.000000000 +0100
@@ -147,7 +147,7 @@
                        rnd_len = rand() % (l + 1);
                        for (n = 0; n < rnd_len; n++)
                                buf[off + n] = (unsigned char)rand();
-                               memset(buf + off + rnd_len, 0xFF, l - rnd_len);
+                       memset(buf + off + rnd_len, 0xFF, l - rnd_len);
 
                        /*
                         * Deliberately pass len instead of l (len may be
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/unittests/Makemodule.am 
new/mtd-utils-2.0.2/tests/unittests/Makemodule.am
--- old/mtd-utils-2.0.1/tests/unittests/Makemodule.am   2016-12-14 
10:06:35.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/unittests/Makemodule.am   2018-04-16 
17:49:18.000000000 +0200
@@ -1,12 +1,12 @@
 ubilib_test_SOURCES = tests/unittests/libubi_test.c lib/libubi.c
 ubilib_test_LDADD = $(CMOCKA_LIBS)
-ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=stat 
-Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek
-ubilib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) -I include 
-DSYSFS_ROOT='"tests/unittests/sysfs_mock"'
+ubilib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl 
-Wl,--wrap=read -Wl,--wrap=lseek
+ubilib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) 
-I$(top_srcdir)/include 
-DSYSFS_ROOT='"$(top_srcdir)/tests/unittests/sysfs_mock"'
 
 mtdlib_test_SOURCES = tests/unittests/libmtd_test.c lib/libmtd.c 
lib/libmtd_legacy.c
 mtdlib_test_LDADD = $(CMOCKA_LIBS)
-mtdlib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=stat 
-Wl,--wrap=ioctl -Wl,--wrap=read -Wl,--wrap=lseek -Wl,--wrap=write
-mtdlib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) -I lib/ -I include 
-DSYSFS_ROOT='"tests/unittests/sysfs_mock"'
+mtdlib_test_LDFLAGS = -Wl,--wrap=open -Wl,--wrap=close -Wl,--wrap=ioctl 
-Wl,--wrap=read -Wl,--wrap=lseek -Wl,--wrap=write
+mtdlib_test_CPPFLAGS = -O0 --std=gnu99 $(CMOCKA_CFLAGS) -I$(top_srcdir)/lib/ 
-I$(top_srcdir)/include 
-DSYSFS_ROOT='"$(top_srcdir)/tests/unittests/sysfs_mock"'
 
 TEST_BINS = \
        ubilib_test \
@@ -20,4 +20,5 @@
 
 EXTRA_DIST += $(UNITTEST_HEADER) $(UNITTEST_EXTRA)
 
-noinst_PROGRAMS += $(TEST_BINS)
+TESTS += $(TEST_BINS)
+check_PROGRAMS += $(TEST_BINS)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/unittests/libmtd_test.c 
new/mtd-utils-2.0.2/tests/unittests/libmtd_test.c
--- old/mtd-utils-2.0.1/tests/unittests/libmtd_test.c   2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/unittests/libmtd_test.c   2018-04-16 
17:36:28.000000000 +0200
@@ -42,6 +42,7 @@
        assert_string_equal(lib->mtd_min_io_size, SYSFS_ROOT 
"/class/mtd/mtd%d/writesize");
        assert_string_equal(lib->mtd_subpage_size, SYSFS_ROOT 
"/class/mtd/mtd%d/subpagesize");
        assert_string_equal(lib->mtd_oob_size, SYSFS_ROOT 
"/class/mtd/mtd%d/oobsize");
+       assert_string_equal(lib->mtd_oobavail, SYSFS_ROOT 
"/class/mtd/mtd%d/oobavail");
        assert_string_equal(lib->mtd_region_cnt, SYSFS_ROOT 
"/class/mtd/mtd%d/numeraseregions");
        assert_string_equal(lib->mtd_flags, SYSFS_ROOT 
"/class/mtd/mtd%d/flags");
 
@@ -53,7 +54,6 @@
 {
        int ret;
        libmtd_t lib = mock_libmtd_open();
-       expect_stat(SYSFS_ROOT "/class/mtd/mtd0", 0);
        ret = mtd_dev_present(lib, 0);
        assert_int_equal(ret, 1);
        libmtd_close(lib);
@@ -70,7 +70,7 @@
        mtd.eb_cnt = 1024;
        mtd.eb_size = 128;
        seek = (loff_t)eb * mtd.eb_size;
-       expect_ioctl(MEMSETBADBLOCK, 0, &seek, sizeof(seek));
+       expect_ioctl(MEMSETBADBLOCK, 0, &seek);
        int r = mtd_mark_bad(&mtd, 4, eb);
        assert_int_equal(r, 0);
 
@@ -87,7 +87,7 @@
        mtd.eb_cnt = 1024;
        mtd.eb_size = 128;
        seek = (loff_t)eb * mtd.eb_size;
-       expect_ioctl(MEMGETBADBLOCK, 0, &seek, sizeof(seek));
+       expect_ioctl(MEMGETBADBLOCK, 0, &seek);
        int r = mtd_is_bad(&mtd, 4, eb);
        assert_int_equal(r, 0);
 
@@ -106,7 +106,7 @@
        memset(&ei, 0, sizeof(ei));
        ei.start = eb * mtd.eb_size;
        ei.length = mtd.eb_size;
-       expect_ioctl(MEMLOCK, 0, &ei, sizeof(ei));
+       expect_ioctl(MEMLOCK, 0, &ei);
        int r = mtd_lock(&mtd, 4, eb);
        assert_int_equal(r, 0);
 
@@ -125,7 +125,7 @@
        memset(&ei, 0, sizeof(ei));
        ei.start = eb * mtd.eb_size;
        ei.length = mtd.eb_size;
-       expect_ioctl(MEMUNLOCK, 0, &ei, sizeof(ei));
+       expect_ioctl(MEMUNLOCK, 0, &ei);
        int r = mtd_unlock(&mtd, 4, eb);
        assert_int_equal(r, 0);
 
@@ -144,7 +144,7 @@
        memset(&ei, 0, sizeof(ei));
        ei.start = eb * mtd.eb_size;
        ei.length = mtd.eb_size;
-       expect_ioctl(MEMISLOCKED, 0, &ei, sizeof(ei));
+       expect_ioctl(MEMISLOCKED, 0, &ei);
        int r = mtd_is_locked(&mtd, 4, eb);
        assert_int_equal(r, 0);
 
@@ -160,7 +160,7 @@
        int mock_fd = 4;
        int regidx = 0xAA;
        rr.regionindex = regidx;
-       expect_ioctl(MEMGETREGIONINFO, 0, &rr, sizeof(rr));
+       expect_ioctl(MEMGETREGIONINFO, 0, &rr);
        int r = mtd_regioninfo(mock_fd, regidx, &req);
        assert_int_equal(r, 0);
 
@@ -187,12 +187,12 @@
        ei.length = ei64.length;
        /* non offs64 first */
        lib->offs64_ioctls = OFFS64_IOCTLS_NOT_SUPPORTED;
-       expect_ioctl(MEMERASE, 0, &ei, sizeof(ei));
+       expect_ioctl(MEMERASE, 0, &ei);
        int r = mtd_erase_multi(lib, &mtd, 4, eb, blocks);
        assert_int_equal(r, 0);
 
        lib->offs64_ioctls = OFFS64_IOCTLS_SUPPORTED;
-       expect_ioctl(MEMERASE64, 0, &ei64, sizeof(ei64));
+       expect_ioctl(MEMERASE64, 0, &ei64);
        r = mtd_erase_multi(lib, &mtd, 4, eb, blocks);
        assert_int_equal(r, 0);
 
@@ -224,12 +224,12 @@
        ei.length = ei64.length;
        /* non offs64 first */
        lib->offs64_ioctls = OFFS64_IOCTLS_NOT_SUPPORTED;
-       expect_ioctl(MEMERASE, 0, &ei, sizeof(ei));
+       expect_ioctl(MEMERASE, 0, &ei);
        int r = mtd_erase(lib, &mtd, 4, eb);
        assert_int_equal(r, 0);
 
        lib->offs64_ioctls = OFFS64_IOCTLS_SUPPORTED;
-       expect_ioctl(MEMERASE64, 0, &ei64, sizeof(ei64));
+       expect_ioctl(MEMERASE64, 0, &ei64);
        r = mtd_erase(lib, &mtd, 4, eb);
        assert_int_equal(r, 0);
 
@@ -314,7 +314,7 @@
        req.usr_data = (uint64_t)(unsigned long)buf;
        req.usr_oob = (uint64_t)(unsigned long)oob_data;
        req.mode = mode;
-       expect_ioctl(MEMWRITE, 0, &req, sizeof(req));
+       expect_ioctl(MEMWRITE, 0, &req);
        int r = mtd_write(lib, &mtd, mock_fd, eb, offs, buf, len, oob_data, 
oob_len, mode);
        assert_int_equal(r, 0);
 
@@ -348,12 +348,12 @@
        oob.ptr = buf;
 
        lib->offs64_ioctls = OFFS64_IOCTLS_NOT_SUPPORTED;
-       expect_ioctl(MEMREADOOB, 0, &oob, sizeof(oob));
+       expect_ioctl(MEMREADOOB, 0, &oob);
        int r = mtd_read_oob(lib, &mtd, mock_fd, start, length, buf);
        assert_int_equal(r, 0);
 
        lib->offs64_ioctls = OFFS64_IOCTLS_SUPPORTED;
-       expect_ioctl(MEMREADOOB64, 0, &oob64, sizeof(oob64));
+       expect_ioctl(MEMREADOOB64, 0, &oob64);
        r = mtd_read_oob(lib, &mtd, mock_fd, start, length, buf);
        assert_int_equal(r, 0);
 
@@ -388,12 +388,12 @@
        oob.ptr = buf;
 
        lib->offs64_ioctls = OFFS64_IOCTLS_NOT_SUPPORTED;
-       expect_ioctl(MEMWRITEOOB, 0, &oob, sizeof(oob));
+       expect_ioctl(MEMWRITEOOB, 0, &oob);
        int r = mtd_write_oob(lib, &mtd, mock_fd, start, length, buf);
        assert_int_equal(r, 0);
 
        lib->offs64_ioctls = OFFS64_IOCTLS_SUPPORTED;
-       expect_ioctl(MEMWRITEOOB64, 0, &oob64, sizeof(oob64));
+       expect_ioctl(MEMWRITEOOB64, 0, &oob64);
        r = mtd_write_oob(lib, &mtd, mock_fd, start, length, buf);
        assert_int_equal(r, 0);
 
@@ -423,7 +423,6 @@
        struct mtd_dev_info info;
        int dev_num = 0;
        memset(&info, 0, sizeof(info));
-       expect_stat(SYSFS_ROOT "/class/mtd/mtd0", 0);
        expect_open(SYSFS_ROOT "/class/mtd/mtd0/dev", O_RDONLY, 0);
        expect_read_real(50,0);
        expect_read(1,0);
@@ -451,6 +450,9 @@
        expect_open(SYSFS_ROOT "/class/mtd/mtd0/oobsize", O_RDONLY, 0);
        expect_read_real(50,0);
        expect_close(3,1);
+       expect_open(SYSFS_ROOT "/class/mtd/mtd0/oobavail", O_RDONLY, 0);
+       expect_read_real(50,0);
+       expect_close(3,1);
        expect_open(SYSFS_ROOT "/class/mtd/mtd0/numeraseregions", O_RDONLY, 0);
        expect_read_real(50,0);
        expect_close(3,1);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/unittests/libubi_test.c 
new/mtd-utils-2.0.2/tests/unittests/libubi_test.c
--- old/mtd-utils-2.0.1/tests/unittests/libubi_test.c   2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/unittests/libubi_test.c   2018-03-08 
00:30:27.000000000 +0100
@@ -54,7 +54,7 @@
 {
        int mock_fd = 1;
        int lnum = 12;
-       expect_ioctl(UBI_IOCEBUNMAP, 0, &lnum, sizeof(lnum));
+       expect_ioctl(UBI_IOCEBUNMAP, 0, &lnum);
        int r = ubi_leb_unmap(mock_fd, lnum);
        assert_int_equal(r, 0);
 
@@ -65,7 +65,7 @@
 {
        int mock_fd = 1;
        int lnum = 1;
-       expect_ioctl(UBI_IOCEBISMAP, 0, &lnum, sizeof(lnum));
+       expect_ioctl(UBI_IOCEBISMAP, 0, &lnum);
        int r = ubi_is_mapped(mock_fd, lnum);
        assert_int_equal(r, 0);
 
@@ -77,7 +77,7 @@
        int mock_fd = 1;
        long long bytes = 0x1234;
 
-       expect_ioctl(UBI_IOCVOLUP, 0, &bytes, sizeof(bytes));
+       expect_ioctl(UBI_IOCVOLUP, 0, &bytes);
        int r = ubi_update_start(NULL, mock_fd, bytes);
        assert_int_equal(r, 0);
        (void) state;
@@ -98,7 +98,6 @@
 static void test_ubi_dev_present(void **state)
 {
        libubi_t lib = mock_libubi_open();
-       expect_stat(SYSFS_ROOT "/class/ubi/ubi0", 0);
        int r = ubi_dev_present(lib, 0);
        assert_int_equal(r, 1);
 
@@ -116,7 +115,7 @@
        req.bytes = bytes;
        req.vol_id = vol_id;
        expect_open(node, O_RDONLY, 4);
-       expect_ioctl(UBI_IOCRSVOL, 0, &req, sizeof(req));
+       expect_ioctl(UBI_IOCRSVOL, 0, &req);
        expect_close(4, 0);
        int r = ubi_rsvol(NULL, node, vol_id, bytes);
        assert_int_equal(r, 0);
@@ -131,7 +130,7 @@
        struct ubi_rnvol_req req;
        memset(&req, 0xaf, sizeof(req));
        expect_open(node, O_RDONLY, 4);
-       expect_ioctl(UBI_IOCRNVOL, 0, &req, sizeof(req));
+       expect_ioctl(UBI_IOCRNVOL, 0, &req);
        expect_close(4, 0);
        int r = ubi_rnvols(lib, node, &req);
        assert_int_equal(r, 0);
@@ -146,7 +145,7 @@
        const char *node = "/foo";
        int vol_id = 12;
        expect_open(node, O_RDONLY, 4);
-       expect_ioctl(UBI_IOCRMVOL, 0, &vol_id, sizeof(vol_id));
+       expect_ioctl(UBI_IOCRMVOL, 0, &vol_id);
        expect_close(4, 0);
        int r = ubi_rmvol(lib, node, vol_id);
        assert_int_equal(r, 0);
@@ -166,7 +165,7 @@
        req.lnum = lnum;
        req.bytes = bytes;
        req.dtype = 3;
-       expect_ioctl(UBI_IOCEBCH, 0, &req, sizeof(req));
+       expect_ioctl(UBI_IOCEBCH, 0, &req);
        int r = ubi_leb_change_start(lib, mock_fd, lnum, bytes);
        assert_int_equal(r, 0);
 
@@ -209,7 +208,7 @@
        rr.name_len = strlen(vol_name);
        strncpy(rr.name, vol_name, UBI_MAX_VOLUME_NAME + 1);
        expect_open(node, O_RDONLY, 3);
-       expect_ioctl(UBI_IOCMKVOL, 0, &rr, sizeof(rr));
+       expect_ioctl(UBI_IOCMKVOL, 0, &rr);
        expect_close(3,0);
        int r = ubi_mkvol(lib, node, &req);
        assert_int_equal(r, 0);
@@ -225,7 +224,7 @@
        libubi_t lib = mock_libubi_open();
        int ubi_dev = 0xAA;
        expect_open(node, O_RDONLY, 4);
-       expect_ioctl(UBI_IOCDET, 0, &ubi_dev, sizeof(ubi_dev));
+       expect_ioctl(UBI_IOCDET, 0, &ubi_dev);
        expect_close(4,0);
        int r = ubi_remove_dev(lib, node, ubi_dev);
        assert_int_equal(r, 0);
@@ -247,7 +246,7 @@
        rr.ubi_num = 1;
        rr.mtd_num = 1;
        expect_open(node, O_RDONLY, 4);
-       expect_ioctl(UBI_IOCATT, 0, &rr, sizeof(rr));
+       expect_ioctl(UBI_IOCATT, 0, &rr);
        expect_close(4,0);
 
        int r = ubi_attach(lib, node, &req);
@@ -266,7 +265,7 @@
        memset(&req, 0, sizeof(req));
        req.property = prop;
        req.value = val;
-       expect_ioctl(UBI_IOCSETVOLPROP, 0, &req, sizeof(req));
+       expect_ioctl(UBI_IOCSETVOLPROP, 0, &req);
        int r = ubi_set_property(mock_fd, prop, val);
        assert_int_equal(r,0);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/unittests/sysfs_mock/class/mtd/mtd0/oobavail 
new/mtd-utils-2.0.2/tests/unittests/sysfs_mock/class/mtd/mtd0/oobavail
--- old/mtd-utils-2.0.1/tests/unittests/sysfs_mock/class/mtd/mtd0/oobavail      
1970-01-01 01:00:00.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/unittests/sysfs_mock/class/mtd/mtd0/oobavail      
2018-04-16 17:36:01.000000000 +0200
@@ -0,0 +1 @@
+8
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/tests/unittests/test_lib.h 
new/mtd-utils-2.0.2/tests/unittests/test_lib.h
--- old/mtd-utils-2.0.1/tests/unittests/test_lib.h      2016-11-17 
12:46:31.000000000 +0100
+++ new/mtd-utils-2.0.2/tests/unittests/test_lib.h      2018-03-08 
00:30:27.000000000 +0100
@@ -40,31 +40,23 @@
        return retval;
 }
 
-int __wrap_ioctl(int fd, int req, ...)
+int __wrap_ioctl(int fd, unsigned long req, ...)
 {
        assert_true(fd > 0);
        check_expected(req);
        int retval = mock_type(int);
-       void *expected_arg = mock_type(void*);
-       size_t expected_len = mock_type(size_t);
+       char *expected_arg = mock_type(char*);
        if (expected_arg == NULL)
                return retval;
        va_list ap;
        va_start(ap, req);
-       void *arg = va_arg(ap, void *);
+       char *arg = va_arg(ap, char *);
        va_end(ap);
        assert_non_null(arg);
-       assert_memory_equal(expected_arg, arg, expected_len);
+       assert_memory_equal(expected_arg, arg, _IOC_SIZE(req));
        return retval;
 }
 
-int __wrap_stat(const char *path, struct stat *buf)
-{
-       check_expected(path);
-       assert_non_null(buf);
-       return mock_type(int);
-}
-
 int __wrap_read(int fd, char *buf, size_t len)
 {
        assert_true(fd > 0);
@@ -107,23 +99,16 @@
                will_return(__wrap_close, Y);\
        } while(0);
 
-#define expect_ioctl(W,X,Y,Z) do { \
-               expect_value(__wrap_ioctl, req, (int)W);\
+#define expect_ioctl(W,X,Y) do { \
+               expect_value(__wrap_ioctl, req, W);\
                will_return(__wrap_ioctl, X);\
                will_return(__wrap_ioctl, Y);\
-               will_return(__wrap_ioctl, Z);\
        } while(0);
 
 #define expect_ioctl_short(X,Y) do { \
-               expect_value(__wrap_ioctl, req, (int)X);\
+               expect_value(__wrap_ioctl, req, X);\
                will_return(__wrap_ioctl, Y);\
                will_return(__wrap_ioctl, NULL);\
-               will_return(__wrap_ioctl, 0);\
-       } while(0);
-
-#define expect_stat(X,Y) do { \
-               expect_string(__wrap_stat, path, X);\
-               will_return(__wrap_stat, Y);\
        } while(0);
 
 #define expect_write(X,Y,Z) do { \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/ubi-utils/ubiblock.c 
new/mtd-utils-2.0.2/ubi-utils/ubiblock.c
--- old/mtd-utils-2.0.1/ubi-utils/ubiblock.c    2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/ubi-utils/ubiblock.c    2017-11-15 00:29:09.000000000 
+0100
@@ -74,6 +74,7 @@
                switch (key) {
                case 'c':
                        args.create = 1;
+                       /* fall-through */
                case 'r':
                        args.node = optarg;
                        break;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/ubi-utils/ubicrc32.c 
new/mtd-utils-2.0.2/ubi-utils/ubicrc32.c
--- old/mtd-utils-2.0.1/ubi-utils/ubicrc32.c    2016-07-12 14:16:45.000000000 
+0200
+++ new/mtd-utils-2.0.2/ubi-utils/ubicrc32.c    2017-11-15 00:29:09.000000000 
+0100
@@ -89,19 +89,18 @@
        int err = 0;
        uint32_t crc = UBI_CRC32_INIT;
        char buf[BUFSIZE];
-       FILE *fp;
-
-       if (argc > 1) {
-               fp = fopen(argv[1], "r");
-               if (!fp)
-                       return sys_errmsg("cannot open \"%s\"", argv[1]);
-       } else
-               fp = stdin;
+       FILE *fp = stdin;
 
        err = parse_opt(argc, argv);
        if (err)
                return err;
 
+       if (optind < argc) {
+               fp = fopen(argv[optind], "r");
+               if (!fp)
+                       return sys_errmsg("cannot open \"%s\"", argv[1]);
+       }
+
        while (!feof(fp)) {
                size_t read;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/ubi-utils/ubiformat.c 
new/mtd-utils-2.0.2/ubi-utils/ubiformat.c
--- old/mtd-utils-2.0.1/ubi-utils/ubiformat.c   2017-07-03 22:04:47.000000000 
+0200
+++ new/mtd-utils-2.0.2/ubi-utils/ubiformat.c   2018-01-30 13:05:25.000000000 
+0100
@@ -844,7 +844,7 @@
        }
 
        if (!args.override_ec && si->empty_cnt < si->good_cnt) {
-               int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
+               int percent = (si->ok_cnt * 100) / si->good_cnt;
 
                /*
                 * Make sure the majority of eraseblocks have valid
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/ubifs-utils/mkfs.ubifs/devtable.c 
new/mtd-utils-2.0.2/ubifs-utils/mkfs.ubifs/devtable.c
--- old/mtd-utils-2.0.1/ubifs-utils/mkfs.ubifs/devtable.c       2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/ubifs-utils/mkfs.ubifs/devtable.c       2018-03-08 
00:30:27.000000000 +0100
@@ -146,16 +146,16 @@
                increment, count);
 
        len = strnlen(buf, 1024);
+       if (len == 0)
+               return err_msg("empty path");
        if (len == 1024)
                return err_msg("too long path");
 
-       if (!strcmp(buf, "/"))
+       if (buf[0] != '/')
                return err_msg("device table entries require absolute paths");
-       if (buf[1] == '\0')
-               return err_msg("root directory cannot be created");
        if (strstr(buf, "//"))
                return err_msg("'//' cannot be used in the path");
-       if (buf[len - 1] == '/')
+       if (len > 1 && buf[len - 1] == '/')
                return err_msg("do not put '/' at the end");
 
        if (strstr(buf, "/./") || strstr(buf, "/../") ||
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/ubifs-utils/mkfs.ubifs/key.h 
new/mtd-utils-2.0.2/ubifs-utils/mkfs.ubifs/key.h
--- old/mtd-utils-2.0.1/ubifs-utils/mkfs.ubifs/key.h    2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/ubifs-utils/mkfs.ubifs/key.h    2018-04-10 
20:49:11.000000000 +0200
@@ -64,8 +64,8 @@
 {
        uint32_t a = 0;
        const signed char *str = (const signed char *)s;
+       (void)len;
 
-       len = len;
        while (*str) {
                a += *str << 4;
                a += *str >> 4;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude 
config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 
--exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh 
old/mtd-utils-2.0.1/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c 
new/mtd-utils-2.0.2/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
--- old/mtd-utils-2.0.1/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c     2017-07-03 
22:04:47.000000000 +0200
+++ new/mtd-utils-2.0.2/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c     2018-04-10 
20:49:11.000000000 +0200
@@ -612,7 +612,7 @@
                                return err_msg("bad compressor name");
                        break;
                case 'X':
-#ifdef WITHOT_LZO
+#ifdef WITHOUT_LZO
                        return err_msg("built without LZO support");
 #else
                        c->favor_percent = strtol(optarg, &endp, 0);
@@ -1128,7 +1128,7 @@
 
        len = llistxattr(path_name, NULL, 0);
        if (len < 0) {
-               if (errno == ENOENT)
+               if (errno == ENOENT || errno == EOPNOTSUPP)
                        return 0;
 
                sys_err_msg("llistxattr failed on %s", path_name);
@@ -1825,18 +1825,33 @@
 {
        int err;
        mode_t mode = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
+       struct path_htbl_element *ph_elt;
+       struct name_htbl_element *nh_elt;
 
        if (root) {
                err = stat(root, &root_st);
                if (err)
                        return sys_err_msg("bad root file-system directory 
'%s'",
                                           root);
+               if (squash_owner)
+                       root_st.st_uid = root_st.st_gid = 0;
        } else {
                root_st.st_mtime = time(NULL);
                root_st.st_atime = root_st.st_ctime = root_st.st_mtime;
                root_st.st_mode = mode;
        }
 
+       /*
+        * Check for root entry and update permissions if it exists. This will
+        * also remove the entry from the device table list.
+        */
+       ph_elt = devtbl_find_path("/");
+       if (ph_elt) {
+               nh_elt = devtbl_find_name(ph_elt, "");
+               if (nh_elt && override_attributes(&root_st, ph_elt, nh_elt))
+                       return -1;
+       }
+
        head_flags = 0;
 
        err = create_inum_attr(UBIFS_ROOT_INO, root);



Reply via email to