Linux NILFS development
 help / color / mirror / Atom feed
From: trix-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
To: konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	nathan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org
Cc: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	llvm-cunTk1MwBs/YUNznpcFYbw@public.gmane.org,
	Tom Rix <trix-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH] nilfs2: move initialization of nr_dirty to decl
Date: Thu, 17 Mar 2022 10:50:43 -0700	[thread overview]
Message-ID: <20220317175043.1972081-1-trix@redhat.com> (raw)

From: Tom Rix <trix-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On clang build there is this error
inode.c:227:13: error: variable 'nr_dirty' is
  used uninitialized whenever 'if' condition is false
        } else if (ret) {
                   ^~~

In nilfs_dirty_folio(), if the call to
filemap_dirty_folio() fails and there
are no buffers, nr_dirty will be uninitialized.
Move the initialization out of the buffer
block and to the decl.

Signed-off-by: Tom Rix <trix-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/nilfs2/inode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index c1219c0678a57..01e58b65c9384 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -204,7 +204,7 @@ static bool nilfs_dirty_folio(struct address_space *mapping,
 {
 	struct inode *inode = mapping->host;
 	struct buffer_head *head;
-	unsigned int nr_dirty;
+	unsigned int nr_dirty = 0;
 	bool ret = filemap_dirty_folio(mapping, folio);
 
 	/*
@@ -214,8 +214,6 @@ static bool nilfs_dirty_folio(struct address_space *mapping,
 	head = folio_buffers(folio);
 	if (head) {
 		struct buffer_head *bh = head;
-
-		nr_dirty = 0;
 		do {
 			/* Do not mark hole blocks dirty */
 			if (buffer_dirty(bh) || !buffer_mapped(bh))
-- 
2.26.3


             reply	other threads:[~2022-03-17 17:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17 17:50 trix-H+wXaHxf7aLQT0dZR+AlfA [this message]
     [not found] ` <20220317175043.1972081-1-trix-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2022-03-17 18:12   ` [PATCH] nilfs2: move initialization of nr_dirty to decl Nathan Chancellor

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=20220317175043.1972081-1-trix@redhat.com \
    --to=trix-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=llvm-cunTk1MwBs/YUNznpcFYbw@public.gmane.org \
    --cc=nathan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.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