diff mbox series

[2/7] btrfs-progs: check_mounted_where: pack varibles type by size

Message ID 20d70d9b1ab791c796c73bfc84c23abe956af52c.1686202417.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: cleanup and preparatory around device scan | expand

Commit Message

Anand Jain June 8, 2023, 6 a.m. UTC
Pack variables by their type; it may save some space. Also, fixes a line
indentation.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/open-utils.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Qu Wenruo June 8, 2023, 6:11 a.m. UTC | #1
On 2023/6/8 14:00, Anand Jain wrote:
> Pack variables by their type; it may save some space. Also, fixes a line
> indentation.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   common/open-utils.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/common/open-utils.c b/common/open-utils.c
> index 01d747d8ac43..1e18fa905b51 100644
> --- a/common/open-utils.c
> +++ b/common/open-utils.c
> @@ -55,16 +55,16 @@ static int blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices,
>   int check_mounted_where(int fd, const char *file, char *where, int size,
>   			struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags)
>   {
> -	int ret;
> -	u64 total_devs = 1;
> -	bool is_btrfs;
>   	struct btrfs_fs_devices *fs_devices_mnt = NULL;
> -	FILE *f;
>   	struct mntent *mnt;
> +	u64 total_devs = 1;
> +	FILE *f;
> +	int ret;
> +	bool is_btrfs;
>
>   	/* scan the initial device */
> -	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt,
> -		    &total_devs, BTRFS_SUPER_INFO_OFFSET, sbflags);
> +	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt, &total_devs,
> +				    BTRFS_SUPER_INFO_OFFSET, sbflags);
>   	is_btrfs = (ret >= 0);
>
>   	/* scan other devices */
David Sterba June 8, 2023, 12:38 p.m. UTC | #2
On Thu, Jun 08, 2023 at 02:00:59PM +0800, Anand Jain wrote:
> Pack variables by their type; it may save some space.

AFAIK compiler does not stick to the order defined in the sources on
stack and is free to reorder variables or completely optimize them out
so I don't see point in doing such changes.

> Also, fixes a line
> indentation.

And we don't want whitespace-only patches unless it's something that
really annoys us. Argument formatting is mixed and as long as it's
readable it should not be changed. Acceptable styles are one or two tabs
or align under the openeing ( .
Anand Jain June 11, 2023, 10:21 a.m. UTC | #3
On 08/06/2023 20:38, David Sterba wrote:
> On Thu, Jun 08, 2023 at 02:00:59PM +0800, Anand Jain wrote:
>> Pack variables by their type; it may save some space.
> 
> AFAIK compiler does not stick to the order defined in the sources on
> stack and is free to reorder variables or completely optimize them out
> so I don't see point in doing such changes.
> 

  Oh. I don't see any point in packing them.

>> Also, fixes a line
>> indentation.
> 
> And we don't want whitespace-only patches unless it's something that
> really annoys us. Argument formatting is mixed and as long as it's
> readable it should not be changed. Acceptable styles are one or two tabs
> or align under the openeing ( .


  Got it.

  I will drop this patch in the next reroll.

Thanks.
diff mbox series

Patch

diff --git a/common/open-utils.c b/common/open-utils.c
index 01d747d8ac43..1e18fa905b51 100644
--- a/common/open-utils.c
+++ b/common/open-utils.c
@@ -55,16 +55,16 @@  static int blk_file_in_dev_list(struct btrfs_fs_devices* fs_devices,
 int check_mounted_where(int fd, const char *file, char *where, int size,
 			struct btrfs_fs_devices **fs_dev_ret, unsigned sbflags)
 {
-	int ret;
-	u64 total_devs = 1;
-	bool is_btrfs;
 	struct btrfs_fs_devices *fs_devices_mnt = NULL;
-	FILE *f;
 	struct mntent *mnt;
+	u64 total_devs = 1;
+	FILE *f;
+	int ret;
+	bool is_btrfs;
 
 	/* scan the initial device */
-	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt,
-		    &total_devs, BTRFS_SUPER_INFO_OFFSET, sbflags);
+	ret = btrfs_scan_one_device(fd, file, &fs_devices_mnt, &total_devs,
+				    BTRFS_SUPER_INFO_OFFSET, sbflags);
 	is_btrfs = (ret >= 0);
 
 	/* scan other devices */