Re: [PATCH 5/9] btrfs-progs: Fix Wimplicit-fallthrough warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2018/11/16 下午4:04, Nikolay Borisov wrote:
> 
> 
> On 16.11.18 г. 9:54 ч., Qu Wenruo wrote:
>> Although most fallthrough case is pretty obvious, we still need to teach
>> the dumb compiler that it's an explicit fallthrough.
>>
>> Also reformat the code to use common indent.
>>
>> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
> 
> Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx>
> 
> Is this attribute dependent on a particular compiler version? Does
> gcc4.4 for example support it?

IIRC unsupported attribute should just be ignored by the compiler, so it
shouldn't cause any problem.

However I'm not 100% perfect sure, as my distribution doesn't provide
older gcc.

Thanks,
Qu

> 
>> ---
>>  utils.c | 30 ++++++++++++++++++++++--------
>>  1 file changed, 22 insertions(+), 8 deletions(-)
>>
>> diff --git a/utils.c b/utils.c
>> index a310300829eb..b274f46fdd9d 100644
>> --- a/utils.c
>> +++ b/utils.c
>> @@ -1134,15 +1134,25 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_size, unsigned unit_mod
>>  	num_divs = 0;
>>  	last_size = size;
>>  	switch (unit_mode & UNITS_MODE_MASK) {
>> -	case UNITS_TBYTES: base *= mult; num_divs++;
>> -	case UNITS_GBYTES: base *= mult; num_divs++;
>> -	case UNITS_MBYTES: base *= mult; num_divs++;
>> -	case UNITS_KBYTES: num_divs++;
>> -			   break;
>> +	case UNITS_TBYTES:
>> +		base *= mult;
>> +		num_divs++;
>> +		__attribute__ ((fallthrough));
>> +	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:
>> -			   base = 1;
>> -			   num_divs = 0;
>> -			   break;
>> +		base = 1;
>> +		num_divs = 0;
>> +		break;
>>  	default:
>>  		if (negative) {
>>  			s64 ssize = (s64)size;
>> @@ -1907,13 +1917,17 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,
>>  	default:
>>  	case 4:
>>  		allowed |= BTRFS_BLOCK_GROUP_RAID10;
>> +		__attribute__ ((fallthrough));
>>  	case 3:
>>  		allowed |= BTRFS_BLOCK_GROUP_RAID6;
>> +		__attribute__ ((fallthrough));
>>  	case 2:
>>  		allowed |= BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
>>  			BTRFS_BLOCK_GROUP_RAID5;
>> +		__attribute__ ((fallthrough));
>>  	case 1:
>>  		allowed |= BTRFS_BLOCK_GROUP_DUP;
>> +		__attribute__ ((fallthrough));
>>  	}
>>  
>>  	if (dev_cnt > 1 && profile & BTRFS_BLOCK_GROUP_DUP) {
>>



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux