linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] Btrfs: silence a compiler warning
@ 2012-02-22  7:30 Dan Carpenter
  2012-02-22 16:29 ` David Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2012-02-22  7:30 UTC (permalink / raw)
  To: Chris Mason; +Cc: linux-btrfs, kernel-janitors

Gcc warns that "ret" can be used uninitialized.  It can't actually be
used uninitialized because btrfs_num_copies() always returns 1 or more.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 064b29b..c053e90 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -643,7 +643,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
 static int btrfsic_process_superblock(struct btrfsic_state *state,
 				      struct btrfs_fs_devices *fs_devices)
 {
-	int ret;
+	int ret = 0;
 	struct btrfs_super_block *selected_super;
 	struct list_head *dev_head = &fs_devices->devices;
 	struct btrfs_device *device;

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

* Re: [patch] Btrfs: silence a compiler warning
  2012-02-22  7:30 [patch] Btrfs: silence a compiler warning Dan Carpenter
@ 2012-02-22 16:29 ` David Brown
  2012-02-22 16:37   ` Dan Carpenter
  2012-02-22 19:41   ` [patch v2] " Dan Carpenter
  0 siblings, 2 replies; 4+ messages in thread
From: David Brown @ 2012-02-22 16:29 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Chris Mason, linux-btrfs, kernel-janitors

On Wed, Feb 22, 2012 at 10:30:55AM +0300, Dan Carpenter wrote:
>Gcc warns that "ret" can be used uninitialized.  It can't actually be
>used uninitialized because btrfs_num_copies() always returns 1 or more.
>
>Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
>diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
>index 064b29b..c053e90 100644
>--- a/fs/btrfs/check-integrity.c
>+++ b/fs/btrfs/check-integrity.c
>@@ -643,7 +643,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
> static int btrfsic_process_superblock(struct btrfsic_state *state,
> 				      struct btrfs_fs_devices *fs_devices)
> {
>-	int ret;
>+	int ret = 0;

Does

	int uninitialized_var(ret);

work?  The assignment to zero actually generates additional
(unnecessary) code.

David

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

* Re: [patch] Btrfs: silence a compiler warning
  2012-02-22 16:29 ` David Brown
@ 2012-02-22 16:37   ` Dan Carpenter
  2012-02-22 19:41   ` [patch v2] " Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-02-22 16:37 UTC (permalink / raw)
  To: David Brown; +Cc: Chris Mason, linux-btrfs, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 978 bytes --]

On Wed, Feb 22, 2012 at 08:29:26AM -0800, David Brown wrote:
> On Wed, Feb 22, 2012 at 10:30:55AM +0300, Dan Carpenter wrote:
> >Gcc warns that "ret" can be used uninitialized.  It can't actually be
> >used uninitialized because btrfs_num_copies() always returns 1 or more.
> >
> >Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> >diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> >index 064b29b..c053e90 100644
> >--- a/fs/btrfs/check-integrity.c
> >+++ b/fs/btrfs/check-integrity.c
> >@@ -643,7 +643,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
> >static int btrfsic_process_superblock(struct btrfsic_state *state,
> >				      struct btrfs_fs_devices *fs_devices)
> >{
> >-	int ret;
> >+	int ret = 0;
> 
> Does
> 
> 	int uninitialized_var(ret);
> 
> work?  The assignment to zero actually generates additional
> (unnecessary) code.

Sure.  I can resend it.

regards,
dan carpenter


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [patch v2] Btrfs: silence a compiler warning
  2012-02-22 16:29 ` David Brown
  2012-02-22 16:37   ` Dan Carpenter
@ 2012-02-22 19:41   ` Dan Carpenter
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2012-02-22 19:41 UTC (permalink / raw)
  To: David Brown; +Cc: Chris Mason, linux-btrfs, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 814 bytes --]

Gcc warns that "ret" can be used uninitialized.  It can't actually be
used uninitialized because btrfs_num_copies() always returns 1 or more.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: use the uninitialized_var() macro instead of initializing to 0.

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 064b29b..3bb3853 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -643,7 +643,7 @@ static struct btrfsic_dev_state *btrfsic_dev_state_hashtable_lookup(
 static int btrfsic_process_superblock(struct btrfsic_state *state,
 				      struct btrfs_fs_devices *fs_devices)
 {
-	int ret;
+	int uninitialized_var(ret);
 	struct btrfs_super_block *selected_super;
 	struct list_head *dev_head = &fs_devices->devices;
 	struct btrfs_device *device;

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-02-22 19:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-22  7:30 [patch] Btrfs: silence a compiler warning Dan Carpenter
2012-02-22 16:29 ` David Brown
2012-02-22 16:37   ` Dan Carpenter
2012-02-22 19:41   ` [patch v2] " Dan Carpenter

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).