* [PATCH] btrfs: initialize return variable
@ 2021-04-30 18:06 trix
2021-05-03 13:51 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2021-04-30 18:06 UTC (permalink / raw)
To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, Tom Rix
From: Tom Rix <trix@redhat.com>
Static analysis reports this problem
free-space-cache.c:3965:2: warning: Undefined or garbage value returned
return ret;
^~~~~~~~~~
ret is set in the node handling loop.
Treat doing nothing as a success and initialize ret to 0.
Signed-off-by: Tom Rix <trix@redhat.com>
---
fs/btrfs/free-space-cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index e54466fc101f..4806295116d8 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -3949,7 +3949,7 @@ static int cleanup_free_space_cache_v1(struct btrfs_fs_info *fs_info,
{
struct btrfs_block_group *block_group;
struct rb_node *node;
- int ret;
+ int ret = 0;
btrfs_info(fs_info, "cleaning free space cache v1");
--
2.26.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs: initialize return variable
2021-04-30 18:06 [PATCH] btrfs: initialize return variable trix
@ 2021-05-03 13:51 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2021-05-03 13:51 UTC (permalink / raw)
To: trix; +Cc: clm, josef, dsterba, linux-btrfs, linux-kernel
On Fri, Apr 30, 2021 at 11:06:55AM -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
>
> Static analysis reports this problem
> free-space-cache.c:3965:2: warning: Undefined or garbage value returned
> return ret;
> ^~~~~~~~~~
>
> ret is set in the node handling loop.
> Treat doing nothing as a success and initialize ret to 0.
Right, though it's unlikely the loop won't run at least once, having the
ret initialized is safe. Patch added to misc-next, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-03 13:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 18:06 [PATCH] btrfs: initialize return variable trix
2021-05-03 13:51 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).