]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: fix Wmaybe-uninitialized warning in replay_one_buffer()
authorQiang Ma <maqianga@uniontech.com>
Thu, 18 Dec 2025 08:16:18 +0000 (16:16 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 20 Jan 2026 00:41:47 +0000 (01:41 +0100)
commit9c7e71c97c8cd086b148d0d3d1cd84a1deab023c
tree3d63991e19842d1440cf3ff9f96a83d61922b92a
parent437cc6057e01d98ee124496f045ede36224af326
btrfs: fix Wmaybe-uninitialized warning in replay_one_buffer()

Warning was found when compiling using loongarch64-gcc 12.3.1:

  $ make CFLAGS_tree-log.o=-Wmaybe-uninitialized

  In file included from fs/btrfs/ctree.h:21,
   from fs/btrfs/tree-log.c:12:
  fs/btrfs/accessors.h: In function 'replay_one_buffer':
  fs/btrfs/accessors.h:66:16: warning: 'inode_item' may be used uninitialized [-Wmaybe-uninitialized]
     66 |         return btrfs_get_##bits(eb, s, offsetof(type, member));         \
|                ^~~~~~~~~~
  fs/btrfs/tree-log.c:2803:42: note: 'inode_item' declared here
   2803 |                 struct btrfs_inode_item *inode_item;
|                                          ^~~~~~~~~~

Initialize the inode_item to NULL, the compiler does not seem to see the
relation between the first 'wc->log_key.type == BTRFS_INODE_ITEM_KEY'
check and the other one that also checks the replay phase.

Signed-off-by: Qiang Ma <maqianga@uniontech.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tree-log.c