diff mbox series

[1/2] btrfs-progs: add BTRFS_DEV_ITEMS_OBJECTID in comment in print-tree

Message ID 20190828095619.9923-1-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series [1/2] btrfs-progs: add BTRFS_DEV_ITEMS_OBJECTID in comment in print-tree | expand

Commit Message

Anand Jain Aug. 28, 2019, 9:56 a.m. UTC
So when searching for BTRFS_DEV_ITEMS_OBJECTID it hits. Albeit it is
defined same as BTRFS_ROOT_TREE_OBJECTID.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 print-tree.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Nikolay Borisov Aug. 28, 2019, 1:01 p.m. UTC | #1
On 28.08.19 г. 12:56 ч., Anand Jain wrote:
> So when searching for BTRFS_DEV_ITEMS_OBJECTID it hits. Albeit it is
> defined same as BTRFS_ROOT_TREE_OBJECTID.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  print-tree.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/print-tree.c b/print-tree.c
> index b31e515f8989..5832f3089e3d 100644
> --- a/print-tree.c
> +++ b/print-tree.c
> @@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)
>  	}
>  
>  	switch (objectid) {
> +	/* BTRFS_DEV_ITEMS_OBJECTID */

That comment looks really cryptic to someone just looking at the code.
Adding case BTRFS_DEV_ITEMS_OBJECTID: is better.

>  	case BTRFS_ROOT_TREE_OBJECTID:
>  		if (type == BTRFS_DEV_ITEM_KEY)
>  			fprintf(stream, "DEV_ITEMS");
>
David Sterba Aug. 28, 2019, 1:24 p.m. UTC | #2
On Wed, Aug 28, 2019 at 04:01:04PM +0300, Nikolay Borisov wrote:
> 
> 
> On 28.08.19 г. 12:56 ч., Anand Jain wrote:
> > So when searching for BTRFS_DEV_ITEMS_OBJECTID it hits. Albeit it is
> > defined same as BTRFS_ROOT_TREE_OBJECTID.
> > 
> > Signed-off-by: Anand Jain <anand.jain@oracle.com>
> > ---
> >  print-tree.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/print-tree.c b/print-tree.c
> > index b31e515f8989..5832f3089e3d 100644
> > --- a/print-tree.c
> > +++ b/print-tree.c
> > @@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)
> >  	}
> >  
> >  	switch (objectid) {
> > +	/* BTRFS_DEV_ITEMS_OBJECTID */
> 
> That comment looks really cryptic to someone just looking at the code.
> Adding case BTRFS_DEV_ITEMS_OBJECTID: is better.

> >  	case BTRFS_ROOT_TREE_OBJECTID:

Both constants have the same value so they can't be in one switch, but
yeah the comment should be a bit more verbose, just the constant name is
bringing more questions than answers.
Anand Jain Aug. 28, 2019, 1:48 p.m. UTC | #3
> On 28 Aug 2019, at 9:01 PM, Nikolay Borisov <nborisov@suse.com> wrote:
> 
> 
> 
> On 28.08.19 г. 12:56 ч., Anand Jain wrote:
>> So when searching for BTRFS_DEV_ITEMS_OBJECTID it hits. Albeit it is
>> defined same as BTRFS_ROOT_TREE_OBJECTID.
>> 
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> print-tree.c | 1 +
>> 1 file changed, 1 insertion(+)
>> 
>> diff --git a/print-tree.c b/print-tree.c
>> index b31e515f8989..5832f3089e3d 100644
>> --- a/print-tree.c
>> +++ b/print-tree.c
>> @@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)
>> 	}
>> 
>> 	switch (objectid) {
>> +	/* BTRFS_DEV_ITEMS_OBJECTID */
> 
> That comment looks really cryptic to someone just looking at the code.
> Adding case BTRFS_DEV_ITEMS_OBJECTID: is better.
> 

Both of them defined with the same value (we find which object by type).
So only one of it can be in the case.

#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
::
#define BTRFS_ROOT_TREE_OBJECTID 1ULL

Thanks, Anand


>> 	case BTRFS_ROOT_TREE_OBJECTID:
>> 		if (type == BTRFS_DEV_ITEM_KEY)
>> 			fprintf(stream, "DEV_ITEMS");
>>
Anand Jain Aug. 28, 2019, 1:49 p.m. UTC | #4
> On 28 Aug 2019, at 9:24 PM, David Sterba <dsterba@suse.cz> wrote:
> 
> On Wed, Aug 28, 2019 at 04:01:04PM +0300, Nikolay Borisov wrote:
>> 
>> 
>> On 28.08.19 г. 12:56 ч., Anand Jain wrote:
>>> So when searching for BTRFS_DEV_ITEMS_OBJECTID it hits. Albeit it is
>>> defined same as BTRFS_ROOT_TREE_OBJECTID.
>>> 
>>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>>> ---
>>> print-tree.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>> 
>>> diff --git a/print-tree.c b/print-tree.c
>>> index b31e515f8989..5832f3089e3d 100644
>>> --- a/print-tree.c
>>> +++ b/print-tree.c
>>> @@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)
>>> 	}
>>> 
>>> 	switch (objectid) {
>>> +	/* BTRFS_DEV_ITEMS_OBJECTID */
>> 
>> That comment looks really cryptic to someone just looking at the code.
>> Adding case BTRFS_DEV_ITEMS_OBJECTID: is better.
> 
>>> 	case BTRFS_ROOT_TREE_OBJECTID:
> 
> Both constants have the same value so they can't be in one switch, but
> yeah the comment should be a bit more verbose, just the constant name is
> bringing more questions than answers.

 Oh. Hmm. Let me try.

Thanks, Anand
David Sterba Aug. 29, 2019, 4:06 p.m. UTC | #5
On Wed, Aug 28, 2019 at 05:56:18PM +0800, Anand Jain wrote:
> So when searching for BTRFS_DEV_ITEMS_OBJECTID it hits. Albeit it is
> defined same as BTRFS_ROOT_TREE_OBJECTID.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

1-2 applied, thanks.
diff mbox series

Patch

diff --git a/print-tree.c b/print-tree.c
index b31e515f8989..5832f3089e3d 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -704,6 +704,7 @@  void print_objectid(FILE *stream, u64 objectid, u8 type)
 	}
 
 	switch (objectid) {
+	/* BTRFS_DEV_ITEMS_OBJECTID */
 	case BTRFS_ROOT_TREE_OBJECTID:
 		if (type == BTRFS_DEV_ITEM_KEY)
 			fprintf(stream, "DEV_ITEMS");