btrfs-progs: Fix -Wimplicit-fallthrough warning
Although most fallthrough cases are pretty obvious, we still need to teach hint the compiler that it's an explicit fallthrough. The annotation is not standardized and sometimes comments are used, the attribute is getting more widespread so we're going to use it too. Unknown attributes are ignored by old compilers. Also reformat the code to use common indentation. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
32b86071cf
commit
436677aab0
30
utils.c
30
utils.c
|
@ -1134,15 +1134,25 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_size, unsigned unit_mod
|
||||||
num_divs = 0;
|
num_divs = 0;
|
||||||
last_size = size;
|
last_size = size;
|
||||||
switch (unit_mode & UNITS_MODE_MASK) {
|
switch (unit_mode & UNITS_MODE_MASK) {
|
||||||
case UNITS_TBYTES: base *= mult; num_divs++;
|
case UNITS_TBYTES:
|
||||||
case UNITS_GBYTES: base *= mult; num_divs++;
|
base *= mult;
|
||||||
case UNITS_MBYTES: base *= mult; num_divs++;
|
num_divs++;
|
||||||
case UNITS_KBYTES: num_divs++;
|
__attribute__ ((fallthrough));
|
||||||
break;
|
case UNITS_GBYTES:
|
||||||
|
base *= mult;
|
||||||
|
num_divs++;
|
||||||
|
__attribute__ ((fallthrough));
|
||||||
|
case UNITS_MBYTES:
|
||||||
|
base *= mult;
|
||||||
|
num_divs++;
|
||||||
|
__attribute__ ((fallthrough));
|
||||||
|
case UNITS_KBYTES:
|
||||||
|
num_divs++;
|
||||||
|
break;
|
||||||
case UNITS_BYTES:
|
case UNITS_BYTES:
|
||||||
base = 1;
|
base = 1;
|
||||||
num_divs = 0;
|
num_divs = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (negative) {
|
if (negative) {
|
||||||
s64 ssize = (s64)size;
|
s64 ssize = (s64)size;
|
||||||
|
@ -1907,13 +1917,17 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
|
||||||
default:
|
default:
|
||||||
case 4:
|
case 4:
|
||||||
allowed |= BTRFS_BLOCK_GROUP_RAID10;
|
allowed |= BTRFS_BLOCK_GROUP_RAID10;
|
||||||
|
__attribute__ ((fallthrough));
|
||||||
case 3:
|
case 3:
|
||||||
allowed |= BTRFS_BLOCK_GROUP_RAID6;
|
allowed |= BTRFS_BLOCK_GROUP_RAID6;
|
||||||
|
__attribute__ ((fallthrough));
|
||||||
case 2:
|
case 2:
|
||||||
allowed |= BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
|
allowed |= BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
|
||||||
BTRFS_BLOCK_GROUP_RAID5;
|
BTRFS_BLOCK_GROUP_RAID5;
|
||||||
|
__attribute__ ((fallthrough));
|
||||||
case 1:
|
case 1:
|
||||||
allowed |= BTRFS_BLOCK_GROUP_DUP;
|
allowed |= BTRFS_BLOCK_GROUP_DUP;
|
||||||
|
__attribute__ ((fallthrough));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_cnt > 1 && profile & BTRFS_BLOCK_GROUP_DUP) {
|
if (dev_cnt > 1 && profile & BTRFS_BLOCK_GROUP_DUP) {
|
||||||
|
|
Loading…
Reference in New Issue