diff mbox

[1/3] btrfs-progs: check: remove unused found_key variable in walk_down_tree()

Message ID 20160825052101.25864-1-wangxg.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Xiaoguang Wang Aug. 25, 2016, 5:20 a.m. UTC
Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
---
 cmds-check.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

David Sterba Aug. 29, 2016, 4:22 p.m. UTC | #1
On Thu, Aug 25, 2016 at 01:20:59PM +0800, Wang Xiaoguang wrote:
> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
> ---
>  cmds-check.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/cmds-check.c b/cmds-check.c
> index 0ddfd24..1cd0421 100644
> --- a/cmds-check.c
> +++ b/cmds-check.c
> @@ -3737,7 +3737,6 @@ static int check_fs_root(struct btrfs_root *root,
>  		path.slots[level] = 0;
>  	} else {
>  		struct btrfs_key key;
> -		struct btrfs_disk_key found_key;
>  
>  		btrfs_disk_key_to_cpu(&key, &root_item->drop_progress);
>  		level = root_item->drop_level;
> @@ -3745,10 +3744,6 @@ static int check_fs_root(struct btrfs_root *root,
>  		wret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
>  		if (wret < 0)
>  			goto skip_walking;
> -		btrfs_node_key(path.nodes[level], &found_key,
> -				path.slots[level]);
> -		WARN_ON(memcmp(&found_key, &root_item->drop_progress,
> -					sizeof(found_key)));

It's not unused, the WARN_ON is an if in disguise, ane memcmp does the
check, am I missing something here?
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba Sept. 9, 2016, 3:36 p.m. UTC | #2
On Mon, Aug 29, 2016 at 06:22:17PM +0200, David Sterba wrote:
> On Thu, Aug 25, 2016 at 01:20:59PM +0800, Wang Xiaoguang wrote:
> > Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
> > ---
> >  cmds-check.c | 5 -----
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/cmds-check.c b/cmds-check.c
> > index 0ddfd24..1cd0421 100644
> > --- a/cmds-check.c
> > +++ b/cmds-check.c
> > @@ -3737,7 +3737,6 @@ static int check_fs_root(struct btrfs_root *root,
> >  		path.slots[level] = 0;
> >  	} else {
> >  		struct btrfs_key key;
> > -		struct btrfs_disk_key found_key;
> >  
> >  		btrfs_disk_key_to_cpu(&key, &root_item->drop_progress);
> >  		level = root_item->drop_level;
> > @@ -3745,10 +3744,6 @@ static int check_fs_root(struct btrfs_root *root,
> >  		wret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
> >  		if (wret < 0)
> >  			goto skip_walking;
> > -		btrfs_node_key(path.nodes[level], &found_key,
> > -				path.slots[level]);
> > -		WARN_ON(memcmp(&found_key, &root_item->drop_progress,
> > -					sizeof(found_key)));
> 
> It's not unused, the WARN_ON is an if in disguise, ane memcmp does the
> check, am I missing something here?

So, the warning should stay, please replace it with an if and a message,
unless there are other reasons to drop the check completely.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Xiaoguang Wang Sept. 12, 2016, 7:01 a.m. UTC | #3
Hi,

On 08/30/2016 12:22 AM, David Sterba wrote:
> On Thu, Aug 25, 2016 at 01:20:59PM +0800, Wang Xiaoguang wrote:
>> Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
>> ---
>>   cmds-check.c | 5 -----
>>   1 file changed, 5 deletions(-)
>>
>> diff --git a/cmds-check.c b/cmds-check.c
>> index 0ddfd24..1cd0421 100644
>> --- a/cmds-check.c
>> +++ b/cmds-check.c
>> @@ -3737,7 +3737,6 @@ static int check_fs_root(struct btrfs_root *root,
>>   		path.slots[level] = 0;
>>   	} else {
>>   		struct btrfs_key key;
>> -		struct btrfs_disk_key found_key;
>>   
>>   		btrfs_disk_key_to_cpu(&key, &root_item->drop_progress);
>>   		level = root_item->drop_level;
>> @@ -3745,10 +3744,6 @@ static int check_fs_root(struct btrfs_root *root,
>>   		wret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
>>   		if (wret < 0)
>>   			goto skip_walking;
>> -		btrfs_node_key(path.nodes[level], &found_key,
>> -				path.slots[level]);
>> -		WARN_ON(memcmp(&found_key, &root_item->drop_progress,
>> -					sizeof(found_key)));
> It's not unused, the WARN_ON is an if in disguise, ane memcmp does the
> check, am I missing something here?
No, you're right.
I mistakenly took the memcmp() as memcpy(), sorry.

Regards,
Xiaoguang Wang
>



--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/cmds-check.c b/cmds-check.c
index 0ddfd24..1cd0421 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -3737,7 +3737,6 @@  static int check_fs_root(struct btrfs_root *root,
 		path.slots[level] = 0;
 	} else {
 		struct btrfs_key key;
-		struct btrfs_disk_key found_key;
 
 		btrfs_disk_key_to_cpu(&key, &root_item->drop_progress);
 		level = root_item->drop_level;
@@ -3745,10 +3744,6 @@  static int check_fs_root(struct btrfs_root *root,
 		wret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
 		if (wret < 0)
 			goto skip_walking;
-		btrfs_node_key(path.nodes[level], &found_key,
-				path.slots[level]);
-		WARN_ON(memcmp(&found_key, &root_item->drop_progress,
-					sizeof(found_key)));
 	}
 
 	while (1) {