]> www.infradead.org Git - mtd-utils.git/commitdiff
mkfs.jffs2: fix casting of __off64_t
authorAndy Shevchenko <ext-andriy.shevchenko@nokia.com>
Wed, 20 Apr 2011 09:35:08 +0000 (12:35 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 21 Apr 2011 12:43:26 +0000 (15:43 +0300)
The casting of __off64_t to unsigned long potentially wrong for values higher
than ULONG_MAX.  Let's fix that by using PRIu64 classifier.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
mkfs.jffs2.c

index 7bb9ad155bf362d76720c92744bfa79ee99fb46b..7abaf5040111797cdf95ade8f1b94b3acc176ddd 100644 (file)
@@ -72,8 +72,9 @@
 #endif
 #include <byteswap.h>
 #include <crc32.h>
-#include "rbtree.h"
+#include <inttypes.h>
 
+#include "rbtree.h"
 #include "common.h"
 
 /* Do not use the weird XPG version of basename */
@@ -1232,8 +1233,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
                } else switch (e->sb.st_mode & S_IFMT) {
                        case S_IFDIR:
                                if (verbose) {
-                                       printf("\td %04o %9lu             %5d:%-3d %s\n",
-                                                       e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
+                                       printf("\td %04o %9" PRIu64 "             %5d:%-3d %s\n",
+                                                       e->sb.st_mode & ~S_IFMT, e->sb.st_size,
                                                        (int) (e->sb.st_uid), (int) (e->sb.st_gid),
                                                        e->name);
                                }
@@ -1242,8 +1243,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
                                break;
                        case S_IFSOCK:
                                if (verbose) {
-                                       printf("\ts %04o %9lu             %5d:%-3d %s\n",
-                                                       e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
+                                       printf("\ts %04o %9" PRIu64 "             %5d:%-3d %s\n",
+                                                       e->sb.st_mode & ~S_IFMT, e->sb.st_size,
                                                        (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
                                }
                                write_pipe(e);
@@ -1251,8 +1252,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
                                break;
                        case S_IFIFO:
                                if (verbose) {
-                                       printf("\tp %04o %9lu             %5d:%-3d %s\n",
-                                                       e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
+                                       printf("\tp %04o %9" PRIu64 "             %5d:%-3d %s\n",
+                                                       e->sb.st_mode & ~S_IFMT, e->sb.st_size,
                                                        (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
                                }
                                write_pipe(e);
@@ -1280,8 +1281,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
                                break;
                        case S_IFLNK:
                                if (verbose) {
-                                       printf("\tl %04o %9lu             %5d:%-3d %s -> %s\n",
-                                                       e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
+                                       printf("\tl %04o %9" PRIu64 "             %5d:%-3d %s -> %s\n",
+                                                       e->sb.st_mode & ~S_IFMT, e->sb.st_size,
                                                        (int) e->sb.st_uid, (int) e->sb.st_gid, e->name,
                                                        e->link);
                                }
@@ -1292,9 +1293,9 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
                                wrote = write_regular_file(e);
                                write_xattr_entry(e);
                                if (verbose) {
-                                       printf("\tf %04o %9lu (%9u) %5d:%-3d %s\n",
-                                                       e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
-                                                       wrote, (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
+                                       printf("\tf %04o %9" PRIu64 " (%9u) %5d:%-3d %s\n",
+                                                       e->sb.st_mode & ~S_IFMT, e->sb.st_size, wrote,
+                                                       (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
                                }
                                break;
                        default: