RFR(S): JDK-8073584 Native compilation warning in unpack code
Kumar Srinivasan
kumar.x.srinivasan at oracle.com
Sun Feb 22 01:38:59 UTC 2015
Hi Dmitry,
adding John on this.
unpack.cpp
What is wrong with the unary operator ? Does this emit a compiler warning ?
- sprintf(buf, ((uint)e.tag < CONSTANT_Limit)? TAG_NAME[e.tag]: "%d", e.tag);
+ if ((uint)e.tag < CONSTANT_Limit) {
+ sprintf(buf, "%s", TAG_NAME[e.tag]);
+ }
+ else {
+ sprintf(buf, "%d", e.tag);
+ }
If you are eliminating the unary operator then, the formatting should be
if (.....)
......
else
......
or
if (.....) {
....
else { <--- note, please don't introduce new formatting/conventions.
....
}
main.cpp:
+ (void) (fread(&filecrc, sizeof(filecrc), 1, u.infileptr) + 1);
UGH. What about other compilers are they ok with this ? This may very well
get suppressed for gcc, but might emit warnings on MSVC or SunStudio.
I take it you have run all the open and internal regression tests.
Thanks
Kumar
> Hi Everyone,
>
> It's my $0.02 to the warning cleanup work. Please review:
>
> http://cr.openjdk.java.net/~dsamersoff/JDK-8073584/webrev.01/
>
> Notes:
>
> I use an ugly trick: (void) (read() + 1) to get rid of ignored value
> warning because since gcc 4.6 just (void) is not enough.
>
>
> -Dmitry
>
>
More information about the core-libs-dev
mailing list