From 250a5e8bdde09c7e7d67bc006c469964de7474bb Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 25 Jun 2022 13:00:28 -0500 Subject: [PATCH] Pacify Oracle Studio re xterm.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/xterm.c (xErrorHandler, xIOErrorHandler): New typedefs. (xm_get_drag_window_1, x_connection_closed): Use them instead of void *, since the C standard frowns on converting function pointers to and from void *. This pacifies Oracle Studio diagnostics like “warning: assignment type mismatch: pointer to void "=" pointer to function(pointer to struct _XDisplay {})\ returning int”. (x_detect_pending_selection_requests, x_had_errors_p): Do not rely on implicit conversion of a pointer to a bool return value; use !! instead. This pacifies Oracle Studio’s “warning: improper pointer/integer combination: op "="”. (xim_open_dpy) [HAVE_X11R6 && !HAVE_X11R6_XIM]: Do not use xim_destroy_callback; configure.ac says “inoue@ainet.or.jp says Solaris has a bug related to X11R6-style ## XIM support” and Oracle Studio complains “warning: assignment type mismatch: pointer to function(pointer to struct _XIC {}, pointer to char, pointer\ to char) returning void "=" pointer to function(pointer to struct _XIM {}, pointer to char, pointer to char) returning void”. --- src/xterm.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 7d5794bdd7a..cd9645af074 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -719,6 +719,12 @@ along with GNU Emacs. If not, see . */ #include #endif +/* Although X11/Xlib.h commonly defines the types XErrorHandler and + XIOErrorHandler, they are not in the Xlib spec so for portability + define and use names with a leading lower-case 'x' instead. */ +typedef int (*xErrorHandler) (Display *, XErrorEvent *); +typedef int (*xIOErrorHandler) (Display *); + #if defined USE_XCB && defined USE_CAIRO_XCB #define USE_CAIRO_XCB_SURFACE #endif @@ -1830,7 +1836,9 @@ xm_get_drag_window_1 (struct x_display_info *dpyinfo) Window drag_window; XSetWindowAttributes attrs; Display *temp_display; - void *old_handler, *old_io_handler; + xErrorHandler old_handler; + xIOErrorHandler old_io_handler; + /* These are volatile because GCC mistakenly warns about them being clobbered by longjmp. */ volatile bool error, created; @@ -1893,9 +1901,7 @@ xm_get_drag_window_1 (struct x_display_info *dpyinfo) XGrabServer (temp_display); XSetCloseDownMode (temp_display, RetainPermanent); - /* We can't use XErrorHandler since it's not in the Xlib - specification, and Emacs tries to be portable. */ - old_handler = (void *) XSetErrorHandler (xm_drag_window_error_handler); + old_handler = XSetErrorHandler (xm_drag_window_error_handler); _MOTIF_DRAG_WINDOW = XInternAtom (temp_display, "_MOTIF_DRAG_WINDOW", False); @@ -11202,7 +11208,7 @@ x_push_selection_request (struct selection_input_event *se) bool x_detect_pending_selection_requests (void) { - return pending_selection_requests; + return !!pending_selection_requests; } static void @@ -23024,7 +23030,7 @@ x_had_errors_p (Display *dpy) > x_error_message->first_request)) XSync (dpy, False); - return x_error_message->string; + return !!x_error_message->string; } /* Forget about any errors we have had, since we did x_catch_errors on @@ -23084,7 +23090,7 @@ x_connection_closed (Display *dpy, const char *error_message, bool ioerror) struct x_display_info *dpyinfo; Lisp_Object frame, tail; specpdl_ref idx = SPECPDL_INDEX (); - void *io_error_handler; + xIOErrorHandler io_error_handler; xm_drop_start_message dmsg; struct frame *f; @@ -23479,14 +23485,14 @@ xim_open_dpy (struct x_display_info *dpyinfo, char *resource_name) if (xim) { -#ifdef HAVE_X11R6 +#ifdef HAVE_X11R6_XIM XIMCallback destroy; #endif /* Get supported styles and XIM values. */ XGetIMValues (xim, XNQueryInputStyle, &dpyinfo->xim_styles, NULL); -#ifdef HAVE_X11R6 +#ifdef HAVE_X11R6_XIM destroy.callback = xim_destroy_callback; destroy.client_data = (XPointer)dpyinfo; XSetIMValues (xim, XNDestroyCallback, &destroy, NULL); -- 2.39.5