RFR: JDK-8354316 : clang/linux build fails with -Wunused-result warning at XToolkit.c:695:9 [v2]
Harshitha Onkar
honkar at openjdk.org
Wed May 14 21:28:37 UTC 2025
> The following line results in unused-result warning on linux/clang.
>
>
> /java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c:695:9: error: ignoring return value of function
> declared with 'warn_unused_result' attribute [-Werror,-Wunused-result]
> 695 | write ( AWT_WRITEPIPE, &wakeUp_char, 1 );
>
>
> There are two ways to handle it
>
> 1) Make changes to XToolkit.c such that the warning is no longer thrown. But throwing an error based on the result of `write ( AWT_WRITEPIPE, &wakeUp_char, 1 );` will result in unexpected behavioral changes and the best way to handle it is to have an empty if block with an appropriate comment.
>
>
> There was a discussion about the same line long ago and the reason the result of `write()` was not handled and it was left unchanged was not to introduce behavioral change - https://mail.openjdk.org/pipermail/awt-dev/2016-July/011626.html
>
>
> 2) Add unused-result to disabled warning section for clang similar to gcc - https://github.com/openjdk/jdk/blob/d1543429ff29ca0d761b8473b3fb8621abcd226d/make/modules/java.desktop/lib/AwtLibraries.gmk#L281. The 1st approach was picked over the 2nd since the usual recommendation is not to add to disabled warning section unless there is no other option.
>
> NOTE: the fix has been tested on linux/gcc , it does need to be tested on linux/clang.
Harshitha Onkar has updated the pull request incrementally with one additional commit since the last revision:
DTRACE added
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/25217/files
- new: https://git.openjdk.org/jdk/pull/25217/files/f1172662..91f3d409
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=25217&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=25217&range=00-01
Stats: 4 lines in 1 file changed: 0 ins; 3 del; 1 mod
Patch: https://git.openjdk.org/jdk/pull/25217.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25217/head:pull/25217
PR: https://git.openjdk.org/jdk/pull/25217
More information about the client-libs-dev
mailing list