Skip to content

Commit 01215d3

Browse files
zhangyi089tytso
authored andcommitted
jbd2: fix compile warning when using JBUFFER_TRACE
The jh pointer may be used uninitialized in the two cases below and the compiler complain about it when enabling JBUFFER_TRACE macro, fix them. In file included from fs/jbd2/transaction.c:19:0: fs/jbd2/transaction.c: In function ‘jbd2_journal_get_undo_access’: ./include/linux/jbd2.h:1637:38: warning: ‘jh’ is used uninitialized in this function [-Wuninitialized] #define JBUFFER_TRACE(jh, info) do { printk("%s: %d\n", __func__, jh->b_jcount);} while (0) ^ fs/jbd2/transaction.c:1219:23: note: ‘jh’ was declared here struct journal_head *jh; ^ In file included from fs/jbd2/transaction.c:19:0: fs/jbd2/transaction.c: In function ‘jbd2_journal_dirty_metadata’: ./include/linux/jbd2.h:1637:38: warning: ‘jh’ may be used uninitialized in this function [-Wmaybe-uninitialized] #define JBUFFER_TRACE(jh, info) do { printk("%s: %d\n", __func__, jh->b_jcount);} while (0) ^ fs/jbd2/transaction.c:1332:23: note: ‘jh’ was declared here struct journal_head *jh; ^ Signed-off-by: zhangyi (F) <yi.zhang@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org Reviewed-by: Jan Kara <jack@suse.cz>
1 parent 7159a98 commit 01215d3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/jbd2/transaction.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,11 +1252,12 @@ int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh)
12521252
struct journal_head *jh;
12531253
char *committed_data = NULL;
12541254

1255-
JBUFFER_TRACE(jh, "entry");
12561255
if (jbd2_write_access_granted(handle, bh, true))
12571256
return 0;
12581257

12591258
jh = jbd2_journal_add_journal_head(bh);
1259+
JBUFFER_TRACE(jh, "entry");
1260+
12601261
/*
12611262
* Do this first --- it can drop the journal lock, so we want to
12621263
* make sure that obtaining the committed_data is done
@@ -1367,15 +1368,17 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
13671368

13681369
if (is_handle_aborted(handle))
13691370
return -EROFS;
1370-
if (!buffer_jbd(bh)) {
1371-
ret = -EUCLEAN;
1372-
goto out;
1373-
}
1371+
if (!buffer_jbd(bh))
1372+
return -EUCLEAN;
1373+
13741374
/*
13751375
* We don't grab jh reference here since the buffer must be part
13761376
* of the running transaction.
13771377
*/
13781378
jh = bh2jh(bh);
1379+
jbd_debug(5, "journal_head %p\n", jh);
1380+
JBUFFER_TRACE(jh, "entry");
1381+
13791382
/*
13801383
* This and the following assertions are unreliable since we may see jh
13811384
* in inconsistent state unless we grab bh_state lock. But this is
@@ -1409,9 +1412,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
14091412
}
14101413

14111414
journal = transaction->t_journal;
1412-
jbd_debug(5, "journal_head %p\n", jh);
1413-
JBUFFER_TRACE(jh, "entry");
1414-
14151415
jbd_lock_bh_state(bh);
14161416

14171417
if (jh->b_modified == 0) {

0 commit comments

Comments
 (0)