Patchwork [PATCHv1,1/5] mkfs.jffs2: fix casting of printf argument

login
register
mail settings
Submitter Shevchenko Andriy (EXT-Teleca/Helsinki)
Date April 13, 2011, 1:20 p.m.
Message ID <ec50e9f8ced473683c8c8e981607737dfb015c3b.1302700658.git.ext-andriy.shevchenko@nokia.com>
Download mbox | patch
Permalink /patch/91007/
State Accepted
Commit f96aa3ccf0fbb0e659e475d9ce9536b913067657
Headers show

Comments

Shevchenko Andriy (EXT-Teleca/Helsinki) - April 13, 2011, 1:20 p.m.
The compiler warns us about cast mismatch for %9lu specifier.  In original code
the argument has __off64_t type. Here is a simple type casting fix.

Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
---
 mkfs.jffs2.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
Artem Bityutskiy - April 14, 2011, 12:24 p.m.
On Wed, 2011-04-13 at 16:20 +0300, Andy Shevchenko wrote:
> The compiler warns us about cast mismatch for %9lu specifier.  In original code
> the argument has __off64_t type. Here is a simple type casting fix.
> 
> Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>

If it is off64_t then you should better change the printf() placeholder
to %ull and cast the argument to (unsigned long long)
Shevchenko Andriy (EXT-Teleca/Helsinki) - April 14, 2011, 1:21 p.m.
On Thu, 2011-04-14 at 15:24 +0300, Artem Bityutskiy wrote:
> On Wed, 2011-04-13 at 16:20 +0300, Andy Shevchenko wrote:
> > The compiler warns us about cast mismatch for %9lu specifier.  In original code
> > the argument has __off64_t type. Here is a simple type casting fix.
> > 
> > Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com>
> 
> If it is off64_t then you should better change the printf() placeholder
> to %ull and cast the argument to (unsigned long long)
> 
I was waiting for such correction because I don't know the limits of the
argument, thanks.

Patch

diff --git a/mkfs.jffs2.c b/mkfs.jffs2.c
index 3aab533..7bb9ad1 100644
--- a/mkfs.jffs2.c
+++ b/mkfs.jffs2.c
@@ -1233,7 +1233,7 @@  static void recursive_populate_directory(struct filesystem_entry *dir)
 			case S_IFDIR:
 				if (verbose) {
 					printf("\td %04o %9lu             %5d:%-3d %s\n",
-							e->sb.st_mode & ~S_IFMT, e->sb.st_size,
+							e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
 							(int) (e->sb.st_uid), (int) (e->sb.st_gid),
 							e->name);
 				}
@@ -1243,7 +1243,7 @@  static void recursive_populate_directory(struct filesystem_entry *dir)
 			case S_IFSOCK:
 				if (verbose) {
 					printf("\ts %04o %9lu             %5d:%-3d %s\n",
-							e->sb.st_mode & ~S_IFMT, e->sb.st_size,
+							e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
 							(int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
 				}
 				write_pipe(e);
@@ -1252,7 +1252,7 @@  static void recursive_populate_directory(struct filesystem_entry *dir)
 			case S_IFIFO:
 				if (verbose) {
 					printf("\tp %04o %9lu             %5d:%-3d %s\n",
-							e->sb.st_mode & ~S_IFMT, e->sb.st_size,
+							e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
 							(int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
 				}
 				write_pipe(e);
@@ -1281,7 +1281,7 @@  static void recursive_populate_directory(struct filesystem_entry *dir)
 			case S_IFLNK:
 				if (verbose) {
 					printf("\tl %04o %9lu             %5d:%-3d %s -> %s\n",
-							e->sb.st_mode & ~S_IFMT, e->sb.st_size,
+							e->sb.st_mode & ~S_IFMT, (unsigned long) e->sb.st_size,
 							(int) e->sb.st_uid, (int) e->sb.st_gid, e->name,
 							e->link);
 				}
@@ -1293,8 +1293,8 @@  static void recursive_populate_directory(struct filesystem_entry *dir)
 				write_xattr_entry(e);
 				if (verbose) {
 					printf("\tf %04o %9lu (%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);
+							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);
 				}
 				break;
 			default: