nilfs2: move initialization of nr_dirty to decl
PATCH 1/1 nilfs2: move initialization of nr_dirty to decl
From: Tom Rix <[email protected]>
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.
--- fs/nilfs2/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/nilfs2/inode.c +1 -3
@@ -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))
Signature · 1 line
2.26.3
Hi Tom,
Quoted 8 lines · On Thu, Mar 17, 2022 at 10:50:43AM -0700…
From: Tom Rix <[email protected]>
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) { ^~~
Quoted 7 lines
In
nilfs_dirty_folio(), if the call tofilemap_dirty_folio()fails and there are no buffers,nr_dirtywill be uninitialized. Move the initialization out of the buffer block and to the decl.Signed-off-by Tom Rix <[email protected]>
This has been fixed in next-20220317:
https://git.kernel.org/next/linux-next/c/af7afdc7bbbe60cb6ce51a86b022d647e1a72717
Cheers,
Nathan
Quoted 29 lines
--- fs/nilfs2/inode.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fs/nilfs2/inode.c +1
-3@@ -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))Signature · 1 line
2.26.3