diff mbox

[4/7] btrfs-progs: Use list_for_each_entry in write_dev_all_supers

Message ID 1512463189-24724-5-git-send-email-nborisov@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nikolay Borisov Dec. 5, 2017, 8:39 a.m. UTC
No need to use extra variable and 2 macros when we can succintly use 1.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 disk-io.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Qu Wenruo Dec. 5, 2017, 9:14 a.m. UTC | #1
On 2017年12月05日 16:39, Nikolay Borisov wrote:
> No need to use extra variable and 2 macros when we can succintly use 1.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Straightforward cleanup.

Although I found several other places with the same problem.

It would be better to address them all in one patch.
(3 in volumes.c 1 in utils.c and 1 in cmds-filesystem.c)

Thanks,
Qu
> ---
>  disk-io.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/disk-io.c b/disk-io.c
> index f5edc4796619..3d8785d5bb37 100644
> --- a/disk-io.c
> +++ b/disk-io.c
> @@ -1556,7 +1556,6 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info,
>  
>  int write_all_supers(struct btrfs_fs_info *fs_info)
>  {
> -	struct list_head *cur;
>  	struct list_head *head = &fs_info->fs_devices->devices;
>  	struct btrfs_device *dev;
>  	struct btrfs_super_block *sb;
> @@ -1566,8 +1565,7 @@ int write_all_supers(struct btrfs_fs_info *fs_info)
>  
>  	sb = fs_info->super_copy;
>  	dev_item = &sb->dev_item;
> -	list_for_each(cur, head) {
> -		dev = list_entry(cur, struct btrfs_device, dev_list);
> +	list_for_each_entry(dev, head, dev_list) {
>  		if (!dev->writeable)
>  			continue;
>  
>
Nikolay Borisov Dec. 5, 2017, 9:16 a.m. UTC | #2
On  5.12.2017 11:14, Qu Wenruo wrote:
> 
> 
> On 2017年12月05日 16:39, Nikolay Borisov wrote:
>> No need to use extra variable and 2 macros when we can succintly use 1.
>>
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> 
> Straightforward cleanup.
> 
> Although I found several other places with the same problem.
> 
> It would be better to address them all in one patch.
> (3 in volumes.c 1 in utils.c and 1 in cmds-filesystem.c)

I will fold them then and resend this patch.

> 
> Thanks,
> Qu
>> ---
>>  disk-io.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/disk-io.c b/disk-io.c
>> index f5edc4796619..3d8785d5bb37 100644
>> --- a/disk-io.c
>> +++ b/disk-io.c
>> @@ -1556,7 +1556,6 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info,
>>  
>>  int write_all_supers(struct btrfs_fs_info *fs_info)
>>  {
>> -	struct list_head *cur;
>>  	struct list_head *head = &fs_info->fs_devices->devices;
>>  	struct btrfs_device *dev;
>>  	struct btrfs_super_block *sb;
>> @@ -1566,8 +1565,7 @@ int write_all_supers(struct btrfs_fs_info *fs_info)
>>  
>>  	sb = fs_info->super_copy;
>>  	dev_item = &sb->dev_item;
>> -	list_for_each(cur, head) {
>> -		dev = list_entry(cur, struct btrfs_device, dev_list);
>> +	list_for_each_entry(dev, head, dev_list) {
>>  		if (!dev->writeable)
>>  			continue;
>>  
>>
> 
--
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/disk-io.c b/disk-io.c
index f5edc4796619..3d8785d5bb37 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1556,7 +1556,6 @@  static int write_dev_supers(struct btrfs_fs_info *fs_info,
 
 int write_all_supers(struct btrfs_fs_info *fs_info)
 {
-	struct list_head *cur;
 	struct list_head *head = &fs_info->fs_devices->devices;
 	struct btrfs_device *dev;
 	struct btrfs_super_block *sb;
@@ -1566,8 +1565,7 @@  int write_all_supers(struct btrfs_fs_info *fs_info)
 
 	sb = fs_info->super_copy;
 	dev_item = &sb->dev_item;
-	list_for_each(cur, head) {
-		dev = list_entry(cur, struct btrfs_device, dev_list);
+	list_for_each_entry(dev, head, dev_list) {
 		if (!dev->writeable)
 			continue;