aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2024-04-30 01:20:12 -0700
committerPaul Eggert2024-04-30 01:26:23 -0700
commit62c2afe84107de96b850c1da7a2b80bcab6e588a (patch)
tree8accd81d83b5be6e97d89fe9d1dca6f2257f56c9 /src
parent98d0fc989a00dda19412ec5cd3ebe9fb4f276521 (diff)
downloademacs-62c2afe84107de96b850c1da7a2b80bcab6e588a.tar.gz
emacs-62c2afe84107de96b850c1da7a2b80bcab6e588a.zip
Pacify GCC 14 -Wnull-dereference
* src/xterm.c (x_dpyinfo): New function, which acts like x_display_info_for_display except it always returns nonnull. This simplifies callers and pacifies GCC 14. All callers changed.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c2
-rw-r--r--src/xfns.c10
-rw-r--r--src/xmenu.c2
-rw-r--r--src/xterm.c62
-rw-r--r--src/xterm.h2
5 files changed, 36 insertions, 42 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 56d067ade5b..d5079491258 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -504,7 +504,7 @@ void
504x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap, 504x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap,
505 unsigned long *pixels, int npixels) 505 unsigned long *pixels, int npixels)
506{ 506{
507 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 507 struct x_display_info *dpyinfo = x_dpyinfo (dpy);
508 508
509 /* If display has an immutable color map, freeing colors is not 509 /* If display has an immutable color map, freeing colors is not
510 necessary and some servers don't allow it. So don't do it. */ 510 necessary and some servers don't allow it. So don't do it. */
diff --git a/src/xfns.c b/src/xfns.c
index 67db461a379..c48fa24b6be 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -6547,10 +6547,7 @@ void
6547xlw_monitor_dimensions_at_pos (Display *dpy, Screen *screen, int src_x, 6547xlw_monitor_dimensions_at_pos (Display *dpy, Screen *screen, int src_x,
6548 int src_y, int *x, int *y, int *width, int *height) 6548 int src_y, int *x, int *y, int *width, int *height)
6549{ 6549{
6550 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 6550 struct x_display_info *dpyinfo = x_dpyinfo (dpy);
6551
6552 if (!dpyinfo)
6553 emacs_abort ();
6554 6551
6555 block_input (); 6552 block_input ();
6556 xlw_monitor_dimensions_at_pos_1 (dpyinfo, screen, src_x, src_y, 6553 xlw_monitor_dimensions_at_pos_1 (dpyinfo, screen, src_x, src_y,
@@ -10214,10 +10211,7 @@ XkbFreeNames (XkbDescPtr xkb, unsigned int which, Bool free_map)
10214int 10211int
10215XDisplayCells (Display *dpy, int screen_number) 10212XDisplayCells (Display *dpy, int screen_number)
10216{ 10213{
10217 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 10214 struct x_display_info *dpyinfo = x_dpyinfo (dpy);
10218
10219 if (!dpyinfo)
10220 emacs_abort ();
10221 10215
10222 /* Not strictly correct, since the display could be using a 10216 /* Not strictly correct, since the display could be using a
10223 non-default visual, but it satisfies the callers we need to care 10217 non-default visual, but it satisfies the callers we need to care
diff --git a/src/xmenu.c b/src/xmenu.c
index ef1eeb5925f..8682e67dad4 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -236,7 +236,7 @@ x_menu_translate_generic_event (XEvent *event)
236 XEvent copy; 236 XEvent copy;
237 XIDeviceEvent *xev; 237 XIDeviceEvent *xev;
238 238
239 dpyinfo = x_display_info_for_display (event->xgeneric.display); 239 dpyinfo = x_dpyinfo (event->xgeneric.display);
240 240
241 if (event->xgeneric.extension == dpyinfo->xi2_opcode) 241 if (event->xgeneric.extension == dpyinfo->xi2_opcode)
242 { 242 {
diff --git a/src/xterm.c b/src/xterm.c
index 93d347a77ef..c6cc4a9cae6 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2933,7 +2933,6 @@ x_dnd_free_toplevels (bool display_alive)
2933 unsigned long *prev_masks UNINIT; 2933 unsigned long *prev_masks UNINIT;
2934 specpdl_ref count; 2934 specpdl_ref count;
2935 Display *dpy UNINIT; 2935 Display *dpy UNINIT;
2936 struct x_display_info *dpyinfo;
2937 2936
2938 if (!x_dnd_toplevels) 2937 if (!x_dnd_toplevels)
2939 /* Probably called inside an IO error handler. */ 2938 /* Probably called inside an IO error handler. */
@@ -2995,25 +2994,21 @@ x_dnd_free_toplevels (bool display_alive)
2995 record_unwind_protect_ptr (xfree, destroy_windows); 2994 record_unwind_protect_ptr (xfree, destroy_windows);
2996 record_unwind_protect_ptr (xfree, prev_masks); 2995 record_unwind_protect_ptr (xfree, prev_masks);
2997 2996
2998 if (display_alive) 2997 if (display_alive && n_windows)
2999 { 2998 {
3000 dpyinfo = x_display_info_for_display (dpy); 2999 struct x_display_info *dpyinfo = x_dpyinfo (dpy);
3001 3000
3002 if (n_windows) 3001 x_ignore_errors_for_next_request (dpyinfo, 0);
3003 {
3004 eassume (dpyinfo);
3005 x_ignore_errors_for_next_request (dpyinfo, 0);
3006 3002
3007 for (i = 0; i < n_windows; ++i) 3003 for (i = 0; i < n_windows; ++i)
3008 { 3004 {
3009 XSelectInput (dpy, destroy_windows[i], prev_masks[i]); 3005 XSelectInput (dpy, destroy_windows[i], prev_masks[i]);
3010#ifdef HAVE_XSHAPE 3006#ifdef HAVE_XSHAPE
3011 XShapeSelectInput (dpy, destroy_windows[i], None); 3007 XShapeSelectInput (dpy, destroy_windows[i], None);
3012#endif 3008#endif
3013 }
3014
3015 x_stop_ignoring_errors (dpyinfo);
3016 } 3009 }
3010
3011 x_stop_ignoring_errors (dpyinfo);
3017 } 3012 }
3018 3013
3019 unbind_to (count, Qnil); 3014 unbind_to (count, Qnil);
@@ -6881,7 +6876,20 @@ x_draw_horizontal_wave (struct frame *f, GC gc, int x, int y,
6881#endif 6876#endif
6882 6877
6883 6878
6884/* Return the struct x_display_info corresponding to DPY. */ 6879/* Return the struct x_display_info corresponding to DPY,
6880 when it is guaranteed that one will correspond. */
6881
6882struct x_display_info *
6883x_dpyinfo (Display *dpy)
6884{
6885 for (struct x_display_info *dpyinfo = x_display_list; ;
6886 dpyinfo = dpyinfo->next)
6887 if (dpyinfo->display == dpy)
6888 return dpyinfo;
6889}
6890
6891/* Return the struct x_display_info corresponding to DPY,
6892 or a null pointer if none corresponds. */
6885 6893
6886struct x_display_info * 6894struct x_display_info *
6887x_display_info_for_display (Display *dpy) 6895x_display_info_for_display (Display *dpy)
@@ -8895,7 +8903,7 @@ x_frame_of_widget (Widget widget)
8895 Lisp_Object tail, frame; 8903 Lisp_Object tail, frame;
8896 struct frame *f; 8904 struct frame *f;
8897 8905
8898 dpyinfo = x_display_info_for_display (XtDisplay (widget)); 8906 dpyinfo = x_dpyinfo (XtDisplay (widget));
8899 8907
8900 /* Find the top-level shell of the widget. Note that this function 8908 /* Find the top-level shell of the widget. Note that this function
8901 can be called when the widget is not yet realized, so XtWindow 8909 can be called when the widget is not yet realized, so XtWindow
@@ -9089,8 +9097,7 @@ cvt_pixel_dtor (XtAppContext app, XrmValuePtr to, XtPointer closure, XrmValuePtr
9089static const XColor * 9097static const XColor *
9090x_color_cells (Display *dpy, int *ncells) 9098x_color_cells (Display *dpy, int *ncells)
9091{ 9099{
9092 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 9100 struct x_display_info *dpyinfo = x_dpyinfo (dpy);
9093 eassume (dpyinfo);
9094 9101
9095 if (dpyinfo->color_cells == NULL) 9102 if (dpyinfo->color_cells == NULL)
9096 { 9103 {
@@ -9365,16 +9372,13 @@ x_parse_color (struct frame *f, const char *color_name,
9365static bool 9372static bool
9366x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color) 9373x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
9367{ 9374{
9368 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 9375 struct x_display_info *dpyinfo = x_dpyinfo (dpy);
9369 bool rc; 9376 bool rc = XAllocColor (dpy, cmap, color) != 0;
9370
9371 eassume (dpyinfo);
9372 rc = XAllocColor (dpy, cmap, color) != 0;
9373 9377
9374 if (dpyinfo->visual_info.class == DirectColor) 9378 if (dpyinfo->visual_info.class == DirectColor)
9375 return rc; 9379 return rc;
9376 9380
9377 if (rc == 0) 9381 if (!rc)
9378 { 9382 {
9379 /* If we got to this point, the colormap is full, so we're going 9383 /* If we got to this point, the colormap is full, so we're going
9380 to try and get the next closest color. The algorithm used is 9384 to try and get the next closest color. The algorithm used is
@@ -9477,8 +9481,7 @@ x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
9477 /* If allocation succeeded, and the allocated pixel color is not 9481 /* If allocation succeeded, and the allocated pixel color is not
9478 equal to a cached pixel color recorded earlier, there was a 9482 equal to a cached pixel color recorded earlier, there was a
9479 change in the colormap, so clear the color cache. */ 9483 change in the colormap, so clear the color cache. */
9480 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); 9484 struct x_display_info *dpyinfo = x_dpyinfo (dpy);
9481 eassume (dpyinfo);
9482 9485
9483 if (dpyinfo->color_cells) 9486 if (dpyinfo->color_cells)
9484 { 9487 {
@@ -14607,12 +14610,7 @@ x_query_pointer (Display *dpy, Window w, Window *root_return,
14607 int *root_y_return, int *win_x_return, 14610 int *root_y_return, int *win_x_return,
14608 int *win_y_return, unsigned int *mask_return) 14611 int *win_y_return, unsigned int *mask_return)
14609{ 14612{
14610 struct x_display_info *dpyinfo; 14613 struct x_display_info *dpyinfo = x_dpyinfo (dpy);
14611
14612 dpyinfo = x_display_info_for_display (dpy);
14613
14614 if (!dpyinfo)
14615 emacs_abort ();
14616 14614
14617#ifdef HAVE_XINPUT2 14615#ifdef HAVE_XINPUT2
14618 return x_query_pointer_1 (dpyinfo, dpyinfo->client_pointer_device, 14616 return x_query_pointer_1 (dpyinfo, dpyinfo->client_pointer_device,
diff --git a/src/xterm.h b/src/xterm.h
index 2c00b1e7bec..437ef281b0c 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -993,6 +993,8 @@ extern int popup_activated_flag;
993/* This is a chain of structures for all the X displays currently in use. */ 993/* This is a chain of structures for all the X displays currently in use. */
994extern struct x_display_info *x_display_list; 994extern struct x_display_info *x_display_list;
995 995
996extern struct x_display_info *x_dpyinfo (Display *)
997 ATTRIBUTE_RETURNS_NONNULL;
996extern struct x_display_info *x_display_info_for_display (Display *); 998extern struct x_display_info *x_display_info_for_display (Display *);
997extern struct frame *x_top_window_to_frame (struct x_display_info *, int); 999extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
998extern struct x_display_info *x_term_init (Lisp_Object, char *, char *); 1000extern struct x_display_info *x_term_init (Lisp_Object, char *, char *);