mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	btrfs: sysfs: refactor output formatting in btrfs_read_policy_show()
Refactor the logic in btrfs_read_policy_show() for easier extension with more balancing methods. Streamline the space and bracket handling around the active policy without altering the functional output. This is in preparation to add more methods. Signed-off-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
		
							parent
							
								
									a5019b7070
								
							
						
					
					
						commit
						83be7f8b9c
					
				
					 1 changed files with 10 additions and 8 deletions
				
			
		| 
						 | 
					@ -1316,14 +1316,16 @@ static ssize_t btrfs_read_policy_show(struct kobject *kobj,
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < BTRFS_NR_READ_POLICY; i++) {
 | 
						for (i = 0; i < BTRFS_NR_READ_POLICY; i++) {
 | 
				
			||||||
		if (policy == i)
 | 
							if (ret != 0)
 | 
				
			||||||
			ret += sysfs_emit_at(buf, ret, "%s[%s]",
 | 
								ret += sysfs_emit_at(buf, ret, " ");
 | 
				
			||||||
					 (ret == 0 ? "" : " "),
 | 
					
 | 
				
			||||||
					 btrfs_read_policy_name[i]);
 | 
							if (i == policy)
 | 
				
			||||||
		else
 | 
								ret += sysfs_emit_at(buf, ret, "[");
 | 
				
			||||||
			ret += sysfs_emit_at(buf, ret, "%s%s",
 | 
					
 | 
				
			||||||
					 (ret == 0 ? "" : " "),
 | 
							ret += sysfs_emit_at(buf, ret, "%s", btrfs_read_policy_name[i]);
 | 
				
			||||||
					 btrfs_read_policy_name[i]);
 | 
					
 | 
				
			||||||
 | 
							if (i == policy)
 | 
				
			||||||
 | 
								ret += sysfs_emit_at(buf, ret, "]");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret += sysfs_emit_at(buf, ret, "\n");
 | 
						ret += sysfs_emit_at(buf, ret, "\n");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue