mirror of git://git.sv.gnu.org/emacs.git
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.scratch/tango-icons
parent
98d0fc989a
commit
62c2afe841
|
@ -504,7 +504,7 @@ void
|
|||
x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap,
|
||||
unsigned long *pixels, int npixels)
|
||||
{
|
||||
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
|
||||
struct x_display_info *dpyinfo = x_dpyinfo (dpy);
|
||||
|
||||
/* If display has an immutable color map, freeing colors is not
|
||||
necessary and some servers don't allow it. So don't do it. */
|
||||
|
|
10
src/xfns.c
10
src/xfns.c
|
@ -6547,10 +6547,7 @@ void
|
|||
xlw_monitor_dimensions_at_pos (Display *dpy, Screen *screen, int src_x,
|
||||
int src_y, int *x, int *y, int *width, int *height)
|
||||
{
|
||||
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
|
||||
|
||||
if (!dpyinfo)
|
||||
emacs_abort ();
|
||||
struct x_display_info *dpyinfo = x_dpyinfo (dpy);
|
||||
|
||||
block_input ();
|
||||
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)
|
|||
int
|
||||
XDisplayCells (Display *dpy, int screen_number)
|
||||
{
|
||||
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
|
||||
|
||||
if (!dpyinfo)
|
||||
emacs_abort ();
|
||||
struct x_display_info *dpyinfo = x_dpyinfo (dpy);
|
||||
|
||||
/* Not strictly correct, since the display could be using a
|
||||
non-default visual, but it satisfies the callers we need to care
|
||||
|
|
|
@ -236,7 +236,7 @@ x_menu_translate_generic_event (XEvent *event)
|
|||
XEvent copy;
|
||||
XIDeviceEvent *xev;
|
||||
|
||||
dpyinfo = x_display_info_for_display (event->xgeneric.display);
|
||||
dpyinfo = x_dpyinfo (event->xgeneric.display);
|
||||
|
||||
if (event->xgeneric.extension == dpyinfo->xi2_opcode)
|
||||
{
|
||||
|
|
62
src/xterm.c
62
src/xterm.c
|
@ -2933,7 +2933,6 @@ x_dnd_free_toplevels (bool display_alive)
|
|||
unsigned long *prev_masks UNINIT;
|
||||
specpdl_ref count;
|
||||
Display *dpy UNINIT;
|
||||
struct x_display_info *dpyinfo;
|
||||
|
||||
if (!x_dnd_toplevels)
|
||||
/* Probably called inside an IO error handler. */
|
||||
|
@ -2995,25 +2994,21 @@ x_dnd_free_toplevels (bool display_alive)
|
|||
record_unwind_protect_ptr (xfree, destroy_windows);
|
||||
record_unwind_protect_ptr (xfree, prev_masks);
|
||||
|
||||
if (display_alive)
|
||||
if (display_alive && n_windows)
|
||||
{
|
||||
dpyinfo = x_display_info_for_display (dpy);
|
||||
struct x_display_info *dpyinfo = x_dpyinfo (dpy);
|
||||
|
||||
if (n_windows)
|
||||
x_ignore_errors_for_next_request (dpyinfo, 0);
|
||||
|
||||
for (i = 0; i < n_windows; ++i)
|
||||
{
|
||||
eassume (dpyinfo);
|
||||
x_ignore_errors_for_next_request (dpyinfo, 0);
|
||||
|
||||
for (i = 0; i < n_windows; ++i)
|
||||
{
|
||||
XSelectInput (dpy, destroy_windows[i], prev_masks[i]);
|
||||
XSelectInput (dpy, destroy_windows[i], prev_masks[i]);
|
||||
#ifdef HAVE_XSHAPE
|
||||
XShapeSelectInput (dpy, destroy_windows[i], None);
|
||||
XShapeSelectInput (dpy, destroy_windows[i], None);
|
||||
#endif
|
||||
}
|
||||
|
||||
x_stop_ignoring_errors (dpyinfo);
|
||||
}
|
||||
|
||||
x_stop_ignoring_errors (dpyinfo);
|
||||
}
|
||||
|
||||
unbind_to (count, Qnil);
|
||||
|
@ -6881,7 +6876,20 @@ x_draw_horizontal_wave (struct frame *f, GC gc, int x, int y,
|
|||
#endif
|
||||
|
||||
|
||||
/* Return the struct x_display_info corresponding to DPY. */
|
||||
/* Return the struct x_display_info corresponding to DPY,
|
||||
when it is guaranteed that one will correspond. */
|
||||
|
||||
struct x_display_info *
|
||||
x_dpyinfo (Display *dpy)
|
||||
{
|
||||
for (struct x_display_info *dpyinfo = x_display_list; ;
|
||||
dpyinfo = dpyinfo->next)
|
||||
if (dpyinfo->display == dpy)
|
||||
return dpyinfo;
|
||||
}
|
||||
|
||||
/* Return the struct x_display_info corresponding to DPY,
|
||||
or a null pointer if none corresponds. */
|
||||
|
||||
struct x_display_info *
|
||||
x_display_info_for_display (Display *dpy)
|
||||
|
@ -8895,7 +8903,7 @@ x_frame_of_widget (Widget widget)
|
|||
Lisp_Object tail, frame;
|
||||
struct frame *f;
|
||||
|
||||
dpyinfo = x_display_info_for_display (XtDisplay (widget));
|
||||
dpyinfo = x_dpyinfo (XtDisplay (widget));
|
||||
|
||||
/* Find the top-level shell of the widget. Note that this function
|
||||
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
|
|||
static const XColor *
|
||||
x_color_cells (Display *dpy, int *ncells)
|
||||
{
|
||||
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
|
||||
eassume (dpyinfo);
|
||||
struct x_display_info *dpyinfo = x_dpyinfo (dpy);
|
||||
|
||||
if (dpyinfo->color_cells == NULL)
|
||||
{
|
||||
|
@ -9365,16 +9372,13 @@ x_parse_color (struct frame *f, const char *color_name,
|
|||
static bool
|
||||
x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
|
||||
{
|
||||
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
|
||||
bool rc;
|
||||
|
||||
eassume (dpyinfo);
|
||||
rc = XAllocColor (dpy, cmap, color) != 0;
|
||||
struct x_display_info *dpyinfo = x_dpyinfo (dpy);
|
||||
bool rc = XAllocColor (dpy, cmap, color) != 0;
|
||||
|
||||
if (dpyinfo->visual_info.class == DirectColor)
|
||||
return rc;
|
||||
|
||||
if (rc == 0)
|
||||
if (!rc)
|
||||
{
|
||||
/* If we got to this point, the colormap is full, so we're going
|
||||
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)
|
|||
/* If allocation succeeded, and the allocated pixel color is not
|
||||
equal to a cached pixel color recorded earlier, there was a
|
||||
change in the colormap, so clear the color cache. */
|
||||
struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
|
||||
eassume (dpyinfo);
|
||||
struct x_display_info *dpyinfo = x_dpyinfo (dpy);
|
||||
|
||||
if (dpyinfo->color_cells)
|
||||
{
|
||||
|
@ -14607,12 +14610,7 @@ x_query_pointer (Display *dpy, Window w, Window *root_return,
|
|||
int *root_y_return, int *win_x_return,
|
||||
int *win_y_return, unsigned int *mask_return)
|
||||
{
|
||||
struct x_display_info *dpyinfo;
|
||||
|
||||
dpyinfo = x_display_info_for_display (dpy);
|
||||
|
||||
if (!dpyinfo)
|
||||
emacs_abort ();
|
||||
struct x_display_info *dpyinfo = x_dpyinfo (dpy);
|
||||
|
||||
#ifdef HAVE_XINPUT2
|
||||
return x_query_pointer_1 (dpyinfo, dpyinfo->client_pointer_device,
|
||||
|
|
|
@ -993,6 +993,8 @@ extern int popup_activated_flag;
|
|||
/* This is a chain of structures for all the X displays currently in use. */
|
||||
extern struct x_display_info *x_display_list;
|
||||
|
||||
extern struct x_display_info *x_dpyinfo (Display *)
|
||||
ATTRIBUTE_RETURNS_NONNULL;
|
||||
extern struct x_display_info *x_display_info_for_display (Display *);
|
||||
extern struct frame *x_top_window_to_frame (struct x_display_info *, int);
|
||||
extern struct x_display_info *x_term_init (Lisp_Object, char *, char *);
|
||||
|
|
Loading…
Reference in New Issue