United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6879689 Fix warning about ignored return value when compiling with -O2
JDK-6879689 : Fix warning about ignored return value when compiling with -O2

Details
Type:
Bug
Submit Date:
2009-09-08
Status:
Closed
Updated Date:
2012-10-08
Project Name:
JDK
Resolved Date:
2010-04-07
Component:
hotspot
OS:
generic
Sub-Component:
runtime
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
OpenJDK6 (b19)

Related Reports

Sub Tasks

Description
/mnt/builder/icedtea7/openjdk-ecj/hotspot/src/share/vm/adlc/archDesc.cpp:1034:
error: ignoring return value of 'size_t fwrite(const void*, size_t,
size_t, FILE*)', declared with attribute warn_unused_result

The fwrite library call is marked as requiring a warning if the return value is ignored. More recent gcc's can disable this via -Wno-unused-result but in general this warning will be issued and as we build with -Werror the warning becomes an error. So we need to avoid the warning.

                                    

Comments
SUGGESTED FIX

http://cr.openjdk.java.net/~andrew/werror/webrev.02/
                                     
2009-09-08
EVALUATION

See description.

We can use the return value in an assert that checks for success of the fwrite call.

We also switch the "size" and "nitems" parameters to fwrite to give a more meaningful size comparison.
                                     
2009-09-08
EVALUATION

http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/5fdbe2cdf565
                                     
2009-09-25
PUBLIC COMMENTS

See
http://hg.openjdk.java.net/jdk6/jdk6/hotspot/rev/6ee696377676
                                     
2010-04-07



Hardware and Software, Engineered to Work Together