diff --git a/mkfs/common.c b/mkfs/common.c index c830783023..3ceb263bdf 100644 --- a/mkfs/common.c +++ b/mkfs/common.c @@ -1067,7 +1067,7 @@ static int check_overwrite(const char *device) * 1: something is wrong, an error is printed * 0: all is fine */ -int test_dev_for_mkfs(const char *file, int force_overwrite) +bool test_dev_for_mkfs(const char *file, int force_overwrite) { int ret, fd; struct stat st; @@ -1076,15 +1076,15 @@ int test_dev_for_mkfs(const char *file, int force_overwrite) if (ret < 0) { errno = -ret; error("checking status of %s: %m", file); - return 1; + return true; } if (ret == 1) { error("%s is a swap device", file); - return 1; + return true; } ret = test_status_for_mkfs(file, force_overwrite); if (ret) - return 1; + return true; /* * Check if the device is busy. Open it in read-only mode to avoid triggering * udev events. @@ -1092,26 +1092,26 @@ int test_dev_for_mkfs(const char *file, int force_overwrite) fd = open(file, O_RDONLY | O_EXCL); if (fd < 0) { error("unable to open %s: %m", file); - return 1; + return true; } if (fstat(fd, &st)) { error("unable to stat %s: %m", file); close(fd); - return 1; + return true; } if (!S_ISBLK(st.st_mode)) { error("%s is not a block device", file); close(fd); - return 1; + return true; } close(fd); - return 0; + return false; } /* * check if the file (device) is formatted or mounted */ -int test_status_for_mkfs(const char *file, bool force_overwrite) +bool test_status_for_mkfs(const char *file, bool force_overwrite) { int ret; @@ -1119,21 +1119,21 @@ int test_status_for_mkfs(const char *file, bool force_overwrite) if (check_overwrite(file)) { error("use the -f option to force overwrite of %s", file); - return 1; + return true; } } ret = check_mounted(file); if (ret < 0) { errno = -ret; error("cannot check mount status of %s: %m", file); - return 1; + return true; } if (ret == 1) { error("%s is mounted", file); - return 1; + return true; } - return 0; + return false; } int is_vol_small(const char *file) diff --git a/mkfs/common.h b/mkfs/common.h index 2a356301f8..308026d946 100644 --- a/mkfs/common.h +++ b/mkfs/common.h @@ -106,7 +106,7 @@ int test_minimum_size(const char *file, u64 min_dev_size); int is_vol_small(const char *file); int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile, u64 dev_cnt, int mixed, int ssd); -int test_status_for_mkfs(const char *file, bool force_overwrite); -int test_dev_for_mkfs(const char *file, int force_overwrite); +bool test_status_for_mkfs(const char *file, bool force_overwrite); +bool test_dev_for_mkfs(const char *file, int force_overwrite); #endif diff --git a/mkfs/main.c b/mkfs/main.c index 972ed1112e..1c5d668e1e 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -507,10 +507,10 @@ static void list_all_devices(struct btrfs_root *root) printf("\n"); } -static int is_temp_block_group(struct extent_buffer *node, - struct btrfs_block_group_item *bgi, - u64 data_profile, u64 meta_profile, - u64 sys_profile) +static bool is_temp_block_group(struct extent_buffer *node, + struct btrfs_block_group_item *bgi, + u64 data_profile, u64 meta_profile, + u64 sys_profile) { u64 flag = btrfs_block_group_flags(node, bgi); u64 flag_type = flag & BTRFS_BLOCK_GROUP_TYPE_MASK; @@ -537,26 +537,26 @@ static int is_temp_block_group(struct extent_buffer *node, * So only use condition 1) and 2) to judge them. */ if (used != 0) - return 0; + return false; switch (flag_type) { case BTRFS_BLOCK_GROUP_DATA: case BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_METADATA: data_profile &= BTRFS_BLOCK_GROUP_PROFILE_MASK; if (flag_profile != data_profile) - return 1; + return true; break; case BTRFS_BLOCK_GROUP_METADATA: meta_profile &= BTRFS_BLOCK_GROUP_PROFILE_MASK; if (flag_profile != meta_profile) - return 1; + return true; break; case BTRFS_BLOCK_GROUP_SYSTEM: sys_profile &= BTRFS_BLOCK_GROUP_PROFILE_MASK; if (flag_profile != sys_profile) - return 1; + return true; break; } - return 0; + return false; } /* Note: if current is a block group, it will skip it anyway */