RFR of 8074819: Resolve disabled warnings for libzip
Ivan Gerasimov
ivan.gerasimov at oracle.com
Fri Jun 19 18:47:11 UTC 2015
On 19.06.2015 15:11, Alan Bateman wrote:
> On 18/06/2015 21:40, Xueming Shen wrote:
>> Hi,
>>
>> Please help review the change to resolve the disabled "parentheses"
>> warnings for libzip
>>
>> issue: https://bugs.openjdk.java.net/browse/JDK-8074819
>> webrev: http://cr.openjdk.java.net/~sherman/8074819
> Looks okay to me, although I have to admit that parentheses warning is
> new to me (I had to look it up).
>
I think this warning would be avoided if ZIP_FORMAT_ERROR weren't
defined as if..else
#define ZIP_FORMAT_ERROR(message) \
if (1) { zip->msg = message; goto Catch; } else ((void)0)
Because of this, the compiler sees "if () if () {} else {}" and issues
warning, as it looks errorprone.
I believe a more common idiom is using do..while(0) instead:
#define ZIP_FORMAT_ERROR(message) \
do { zip->msg = message; goto Catch; }while (0)
Sincerely yours,
Ivan
More information about the core-libs-dev
mailing list