RFR: 8317696: Fix compilation with clang-16

Daniel Jeliński djelinski at openjdk.org
Mon Oct 9 14:43:10 UTC 2023


On Sat, 7 Oct 2023 16:24:29 GMT, Jan Kratochvil <jkratochvil at openjdk.org> wrote:

> `--with-toolchain-type=clang` fails the compilation for me with `clang-16.0.6-3.fc38.x86_64`
> 
> While the warnings can be disabled I find better to just fix them. The GTK prototypes in JDK reported by clang are either missing or wrong. 
> 
> 
> src/java.base/unix/native/libnet/DefaultProxySelector.c:378:41: error: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
>     proxies = (*g_proxy_resolver_lookup)(resolver, uri, NULL, &error);
>                                         ^
> src/java.base/unix/native/libnet/DefaultProxySelector.c:397:63: error: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
>                                 (*g_network_address_parse_uri)(proxies[i], 0,
>                                                               ^
> src/java.base/unix/native/libnet/DefaultProxySelector.c:402:70: error: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
>                             phost = (*g_network_address_get_hostname)(conn);
>                                                                      ^
> src/java.base/unix/native/libnet/DefaultProxySelector.c:403:66: error: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
>                             pport = (*g_network_address_get_port)(conn);
>                                                                  ^
> src/java.base/unix/native/libnet/DefaultProxySelector.c:445:22: error: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
>         (*g_strfreev)(proxies);
>                      ^
> src/java.base/unix/native/libnet/DefaultProxySelector.c:448:25: error: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Werror,-Wdeprecated-non-prototype]
>         (*g_clear_error)(&error);
>                         ^
> Compiling X11Renderer.c (for libawt_headless.so)
> In file included from src/java.desktop/unix/native/common/java2d/x11/X11PMBlitLoops.c:29:
> In file included from src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h:29:
> src/java.desktop/unix/native/common/aw...

Changes requested by djelinski (Reviewer).

src/java.base/unix/native/libnet/DefaultProxySelector.c line 96:

> 94: typedef GProxyResolver* g_proxy_resolver_get_default_func(void);
> 95: typedef char** g_proxy_resolver_lookup_func(GProxyResolver* resolver, char* uri, void *null, GError **error_p);
> 96: typedef GSocketConnectable* g_network_address_parse_uri_func(char* proxy, int zero, GError **error_p);

Suggestion:

typedef GSocketConnectable* g_network_address_parse_uri_func(char* proxy, unsigned short default_port, GError **error_p);

https://developer-old.gnome.org/gio/stable/GNetworkAddress.html#g-network-address-parse-uri

src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c line 218:

> 216: static GtkWidget* (*fp_gtk_menu_bar_new)();
> 217: static GtkWidget* (*fp_gtk_menu_item_new)();
> 218: static GtkWidget* (*fp_gtk_notebook_new)(void);

This change is inconsistent with the surrounding style; I'd keep the original declaration, and only remove the NULL in function calls.

-------------

PR Review: https://git.openjdk.org/jdk/pull/16092#pullrequestreview-1664342423
PR Review Comment: https://git.openjdk.org/jdk/pull/16092#discussion_r1350242526
PR Review Comment: https://git.openjdk.org/jdk/pull/16092#discussion_r1350396505


More information about the net-dev mailing list