linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix Wmaybe-uninitialized warning
@ 2019-09-03  3:30 Austin Kim
  2019-09-10 16:39 ` Austin Kim
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Austin Kim @ 2019-09-03  3:30 UTC (permalink / raw)
  To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, austindh.kim

gcc throws warning message as below:

‘clone_src_i_size’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
 #define IS_ALIGNED(x, a)  (((x) & ((typeof(x))(a) - 1)) == 0)
                       ^
fs/btrfs/send.c:5088:6: note: ‘clone_src_i_size’ was declared here
 u64 clone_src_i_size;
   ^
The clone_src_i_size is only used as call-by-reference
in a call to get_inode_info().

Silence the warning by initializing clone_src_i_size to 0.

Signed-off-by: Austin Kim <austindh.kim@gmail.com>
---
 fs/btrfs/send.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index f856d6c..197536b 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -5085,7 +5085,7 @@ static int clone_range(struct send_ctx *sctx,
 	struct btrfs_path *path;
 	struct btrfs_key key;
 	int ret;
-	u64 clone_src_i_size;
+	u64 clone_src_i_size = 0;
 
 	/*
 	 * Prevent cloning from a zero offset with a length matching the sector
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: fix Wmaybe-uninitialized warning
  2019-09-03  3:30 [PATCH] btrfs: fix Wmaybe-uninitialized warning Austin Kim
@ 2019-09-10 16:39 ` Austin Kim
  2019-09-17 10:12 ` David Sterba
  2019-10-07 15:03 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Austin Kim @ 2019-09-10 16:39 UTC (permalink / raw)
  To: clm, Josef Bacik, dsterba; +Cc: linux-btrfs, linux-kernel

Hello, maintainers.

If you are available, please review this patch and share the feedback.

Thanks,
Austin Kim

2019년 9월 3일 (화) 오후 12:30, Austin Kim <austindh.kim@gmail.com>님이 작성:
>
> gcc throws warning message as below:
>
> ‘clone_src_i_size’ may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>  #define IS_ALIGNED(x, a)  (((x) & ((typeof(x))(a) - 1)) == 0)
>                        ^
> fs/btrfs/send.c:5088:6: note: ‘clone_src_i_size’ was declared here
>  u64 clone_src_i_size;
>    ^
> The clone_src_i_size is only used as call-by-reference
> in a call to get_inode_info().
>
> Silence the warning by initializing clone_src_i_size to 0.
>
> Signed-off-by: Austin Kim <austindh.kim@gmail.com>
> ---
>  fs/btrfs/send.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index f856d6c..197536b 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -5085,7 +5085,7 @@ static int clone_range(struct send_ctx *sctx,
>         struct btrfs_path *path;
>         struct btrfs_key key;
>         int ret;
> -       u64 clone_src_i_size;
> +       u64 clone_src_i_size = 0;
>
>         /*
>          * Prevent cloning from a zero offset with a length matching the sector
> --
> 2.6.2
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: fix Wmaybe-uninitialized warning
  2019-09-03  3:30 [PATCH] btrfs: fix Wmaybe-uninitialized warning Austin Kim
  2019-09-10 16:39 ` Austin Kim
@ 2019-09-17 10:12 ` David Sterba
  2019-10-07 15:03 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2019-09-17 10:12 UTC (permalink / raw)
  To: Austin Kim; +Cc: clm, josef, dsterba, linux-btrfs, linux-kernel

On Tue, Sep 03, 2019 at 12:30:19PM +0900, Austin Kim wrote:
> gcc throws warning message as below:

What version of gcc reports that? 9.2.1 does not.

> ‘clone_src_i_size’ may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>  #define IS_ALIGNED(x, a)  (((x) & ((typeof(x))(a) - 1)) == 0)
>                        ^
> fs/btrfs/send.c:5088:6: note: ‘clone_src_i_size’ was declared here
>  u64 clone_src_i_size;
>    ^
> The clone_src_i_size is only used as call-by-reference
> in a call to get_inode_info().

The reference is passed to a static function, so the compiler has enough
information to determine if it's unused. By inspection I don't see a
problem with the uninitalized variable: if __get_inode_info succeeds,
there's a valid value, in error case it's not used at all.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: fix Wmaybe-uninitialized warning
  2019-09-03  3:30 [PATCH] btrfs: fix Wmaybe-uninitialized warning Austin Kim
  2019-09-10 16:39 ` Austin Kim
  2019-09-17 10:12 ` David Sterba
@ 2019-10-07 15:03 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2019-10-07 15:03 UTC (permalink / raw)
  To: Austin Kim; +Cc: clm, josef, dsterba, linux-btrfs, linux-kernel

On Tue, Sep 03, 2019 at 12:30:19PM +0900, Austin Kim wrote:
> gcc throws warning message as below:
> 
> ‘clone_src_i_size’ may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>  #define IS_ALIGNED(x, a)  (((x) & ((typeof(x))(a) - 1)) == 0)
>                        ^
> fs/btrfs/send.c:5088:6: note: ‘clone_src_i_size’ was declared here
>  u64 clone_src_i_size;
>    ^
> The clone_src_i_size is only used as call-by-reference
> in a call to get_inode_info().
> 
> Silence the warning by initializing clone_src_i_size to 0.
> 
> Signed-off-by: Austin Kim <austindh.kim@gmail.com>

A few more people have repoted this warning, so I'm gonig to apply the
patch to avoid further reports. Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-07 15:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03  3:30 [PATCH] btrfs: fix Wmaybe-uninitialized warning Austin Kim
2019-09-10 16:39 ` Austin Kim
2019-09-17 10:12 ` David Sterba
2019-10-07 15:03 ` 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).