* [PATCH] btrfs: fix build warning
@ 2016-02-16 8:02 Sudip Mukherjee
2016-03-22 9:39 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Sudip Mukherjee @ 2016-02-16 8:02 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: linux-kernel, linux-btrfs, Sudip Mukherjee
We were getting build warning about:
fs/btrfs/extent-tree.c:7021:34: warning: ‘used_bg’ may be used
uninitialized in this function
It is not a valid warning as used_bg is never used uninitilized since
locked is initially false so we can never be in the section where
'used_bg' is used. But gcc is not able to understand that and we can
initialize it while declaring to silence the warning.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
fs/btrfs/extent-tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e2287c7..f24e4c3 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7018,7 +7018,7 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
struct btrfs_free_cluster *cluster,
int delalloc)
{
- struct btrfs_block_group_cache *used_bg;
+ struct btrfs_block_group_cache *used_bg = NULL;
bool locked = false;
again:
spin_lock(&cluster->refill_lock);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: fix build warning
2016-02-16 8:02 [PATCH] btrfs: fix build warning Sudip Mukherjee
@ 2016-03-22 9:39 ` Geert Uytterhoeven
2016-03-22 9:59 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2016-03-22 9:39 UTC (permalink / raw)
To: Sudip Mukherjee
Cc: Chris Mason, Josef Bacik, David Sterba,
linux-kernel@vger.kernel.org, linux-btrfs
On Tue, Feb 16, 2016 at 9:02 AM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> We were getting build warning about:
> fs/btrfs/extent-tree.c:7021:34: warning: ‘used_bg’ may be used
> uninitialized in this function
>
> It is not a valid warning as used_bg is never used uninitilized since
> locked is initially false so we can never be in the section where
> 'used_bg' is used. But gcc is not able to understand that and we can
> initialize it while declaring to silence the warning.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
FWIW, I've posted an alternative patch that killed the silly locked variable
a while ago.
"[PATCH] Btrfs: Refactor btrfs_lock_cluster() to kill compiler warning"
https://lkml.org/lkml/2014/6/22/96
> ---
> fs/btrfs/extent-tree.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index e2287c7..f24e4c3 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -7018,7 +7018,7 @@ btrfs_lock_cluster(struct btrfs_block_group_cache *block_group,
> struct btrfs_free_cluster *cluster,
> int delalloc)
> {
> - struct btrfs_block_group_cache *used_bg;
> + struct btrfs_block_group_cache *used_bg = NULL;
> bool locked = false;
> again:
> spin_lock(&cluster->refill_lock);
> --
> 1.9.1
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: fix build warning
2016-03-22 9:39 ` Geert Uytterhoeven
@ 2016-03-22 9:59 ` David Sterba
0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2016-03-22 9:59 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Sudip Mukherjee, Chris Mason, Josef Bacik, David Sterba,
linux-kernel@vger.kernel.org, linux-btrfs
On Tue, Mar 22, 2016 at 10:39:59AM +0100, Geert Uytterhoeven wrote:
> On Tue, Feb 16, 2016 at 9:02 AM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > We were getting build warning about:
> > fs/btrfs/extent-tree.c:7021:34: warning: ‘used_bg’ may be used
> > uninitialized in this function
> >
> > It is not a valid warning as used_bg is never used uninitilized since
> > locked is initially false so we can never be in the section where
> > 'used_bg' is used. But gcc is not able to understand that and we can
> > initialize it while declaring to silence the warning.
> >
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>
> FWIW, I've posted an alternative patch that killed the silly locked variable
> a while ago.
> "[PATCH] Btrfs: Refactor btrfs_lock_cluster() to kill compiler warning"
> https://lkml.org/lkml/2014/6/22/96
The cleanup looks great, thanks, patch picked.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-22 10:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 8:02 [PATCH] btrfs: fix build warning Sudip Mukherjee
2016-03-22 9:39 ` Geert Uytterhoeven
2016-03-22 9:59 ` 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).