Skip to contentSkip to conversation

ext4: fix debug format string warning

PATCH Applied Arnd Bergmann 2 participants 2 messages Apr 9, 2021 – Apr 10, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: fix debug format string warning

From: Arnd Bergmann <[email protected]>

Using no_printk() for jbd_debug() revealed two warnings:

fs/jbd2/recovery.c: In function 'fc_do_one_pass':
fs/jbd2/recovery.c:256:30: error: format '%d' expects a matching 'int' argument [-Werror=format=]
256 | jbd_debug(3, "Processing fast commit blk with seq %d");

      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

fs/ext4/fast_commit.c: In function 'ext4_fc_replay_add_range':
fs/ext4/fast_commit.c:1732:30: error: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Werror=format=]
1732 | jbd_debug(1, "Converting from %d to %d %lld",

The first one was added incorrectly, and was also missing a few newlines in debug output, and the second one happened when the type of an argument changed.

Fixes d556435156b7 ("jbd2: avoid -Wempty-body warnings")
Fixes 6db074618969 ("ext4: use BIT() macro for BH_** state bits")
Fixes 5b849b5f96b4 ("jbd2: fast commit recovery path")
---
 fs/ext4/fast_commit.c | 2 +-
 fs/jbd2/recovery.c    | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/ext4/fast_commit.c +1 -1
index 6c4f19b0a556..feec2f3f13e9 100644
@@ -1729,7 +1729,7 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
 		}
 
 		/* Range is mapped and needs a state change */
-		jbd_debug(1, "Converting from %d to %d %lld",
+		jbd_debug(1, "Converting from %ld to %d %lld",
 				map.m_flags & EXT4_MAP_UNWRITTEN,
 			ext4_ext_is_unwritten(ex), map.m_pblk);
 		ret = ext4_ext_replay_update_ex(inode, cur, map.m_len,
fs/jbd2/recovery.c +3 -3
index 69f18fe20923..60601c5779f1 100644
@@ -245,15 +245,15 @@ static int fc_do_one_pass(journal_t *journal,
 		return 0;
 
 	while (next_fc_block <= journal->j_fc_last) {
-		jbd_debug(3, "Fast commit replay: next block %ld",
+		jbd_debug(3, "Fast commit replay: next block %ld\n",
 			  next_fc_block);
 		err = jread(&bh, journal, next_fc_block);
 		if (err) {
-			jbd_debug(3, "Fast commit replay: read error");
+			jbd_debug(3, "Fast commit replay: read error\n");
 			break;
 		}
 
-		jbd_debug(3, "Processing fast commit blk with seq %d");
+		jbd_debug(3, "Processing fast commit blk with seq\n");
 		err = journal->j_fc_replay_callback(journal, bh, pass,
 					next_fc_block - journal->j_fc_first,
 					expected_commit_id);
Signature · 1 line
2.29.2
maintainer Applied
#1 lore raw
Quoted 16 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Using no_printk() for jbd_debug() revealed two warnings:

fs/jbd2/recovery.c: In function 'fc_do_one_pass':
fs/jbd2/recovery.c:256:30: error: format '%d' expects a matching 'int' argument [-Werror=format=]
256 | jbd_debug(3, "Processing fast commit blk with seq %d");

      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

fs/ext4/fast_commit.c: In function 'ext4_fc_replay_add_range':
fs/ext4/fast_commit.c:1732:30: error: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Werror=format=]
1732 | jbd_debug(1, "Converting from %d to %d %lld",

The first one was added incorrectly, and was also missing a few newlines in debug output, and the second one happened when the type of an argument changed.

Quoted 5 lines
Fixes d556435156b7 ("jbd2: avoid -Wempty-body warnings")
Fixes 6db074618969 ("ext4: use BIT() macro for BH_** state bits")
Fixes 5b849b5f96b4 ("jbd2: fast commit recovery path")

Thanks, applied, with one change.

Quoted 5 lines
fs/jbd2/recovery.c +0 -0
index 69f18fe20923..60601c5779f1 100644

fs/jbd2/recovery.c static int fc_do_one_pass(journal_t *journal, · line 256

Quoted 10 lines
fs/jbd2/recovery.c +2 -2
@@ -245,15 +245,15 @@ static int fc_do_one_pass(journal_t *journal,
....
 
 		if (err) {
-			jbd_debug(3, "Fast commit replay: read error");
+			jbd_debug(3, "Fast commit replay: read error\n");
 			break;
 		}
 
-		jbd_debug(3, "Processing fast commit blk with seq %d");
+		jbd_debug(3, "Processing fast commit blk with seq\n");

This debug statement isn't adding any real value, so I just removed it.

- Ted