Re: [PATCH v2 04/13] btrfs-progs: Fix Wempty-body warning

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

 




On 2018/12/14 上午2:59, David Sterba wrote:
> On Wed, Dec 05, 2018 at 02:40:09PM +0800, Qu Wenruo wrote:
>> messages.h:49:24: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
>>     PRINT_TRACE_ON_ERROR;    \
>>
>> Just extra braces would solve the problem.
>>
>> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
>> Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx>
>> ---
>>  messages.h | 15 ++++++++++-----
>>  1 file changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/messages.h b/messages.h
>> index ec7d93381a36..16f650d19a4b 100644
>> --- a/messages.h
>> +++ b/messages.h
>> @@ -45,13 +45,16 @@
>>  
>>  #define error_on(cond, fmt, ...)					\
>>  	do {								\
>> -		if ((cond))						\
>> +		if ((cond)) {						\
>>  			PRINT_TRACE_ON_ERROR;				\
> 
> I think the definition of PRINT_TRACE_ON_ERROR should be fixed to always
> emit a statement, a "do { } while (0)" in the other case.

Looks much better than my braces solution.

> Otherwise it's
> "don't forget to enclose in { } if used", the proposed change looks
> lightly safer to me. I'll update the patch, no need to resend, please
> let me know if it's ok for you.
> 

I'm completely OK with such better solution.

Thanks,
Qu

Attachment: signature.asc
Description: OpenPGP digital signature


[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