mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qiang Ma <maqianga@uniontech.com>
To: clm@fb.com, dsterba@suse.com
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Qiang Ma <maqianga@uniontech.com>
Subject: [PATCH] btrfs: Fix -Wmaybe-uninitialized warning
Date: Thu, 18 Dec 2025 16:16:18 +0800	[thread overview]
Message-ID: <20251218081618.2038279-1-maqianga@uniontech.com> (raw)

Fix a -Wmaybe-uninitialized warning by initializing
the variable to NULL.

$ 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;
      |                                          ^~~~~~~~~~

Warning was found when compiling using loongarch64-gcc 12.3.1.

Signed-off-by: Qiang Ma <maqianga@uniontech.com>
---
 fs/btrfs/tree-log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 31edc93a383e..0d6faaaa70f1 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2798,7 +2798,7 @@ static int replay_one_buffer(struct extent_buffer *eb,
 
 	nritems = btrfs_header_nritems(eb);
 	for (wc->log_slot = 0; wc->log_slot < nritems; wc->log_slot++) {
-		struct btrfs_inode_item *inode_item;
+		struct btrfs_inode_item *inode_item = NULL;
 
 		btrfs_item_key_to_cpu(eb, &wc->log_key, wc->log_slot);
 
-- 
2.20.1


             reply	other threads:[~2025-12-18  8:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  8:16 Qiang Ma [this message]
2025-12-18 20:37 ` David Sterba
2025-12-19  3:11   ` Qiang Ma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251218081618.2038279-1-maqianga@uniontech.com \
    --to=maqianga@uniontech.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®