Omit useless casts found by GCC 16

GCC 16’s -Wuseless-cast warning can be useful.
Fix the useless casts it identifies, and also fix false positives
by using compound literals, which are safer anyway than casts.
* src/composite.c (composition_adjust_point)
(Ffind_composition_internal):
* lwlib/xlwmenu.c (xlwMenuResources, xlwMenuClassRec)
(resource_widget_value, XlwMenuDestroy, Select):
* src/alloc.c (process_mark_stack):
* src/data.c (Faref):
* src/emacs-module.c (module_extract_big_integer):
* src/fileio.c (Finsert_file_contents):
* src/frame.h (FRAME_MESSAGE_BUF_SIZE):
* src/gtkutil.c (xg_tool_item_stale_p, update_frame_tool_bar):
* src/image.c (pbm_load, png_load_body, jpeg_load_body)
(tiff_load, gif_load):
* src/pdumper.c (ptrdiff_t_to_dump_off, dump_queue_dequeue)
(field_relpos, dump_field_emacs_ptr)
(dump_object_start_pseudovector, pdumper_remember_scalar_impl)
(pdumper_load, syms_of_pdumper):
* src/regex-emacs.c (BUF_PUSH, BUF_PUSH_2, POINTER_TO_OFFSET):
* src/xdisp.c (remember_mouse_glyph, pint2str):
* src/xterm.c (cvt_string_to_pixel, handle_one_xevent):
Omit useless casts.  Perhaps they were formerly needed,
but they should not be needed now.
* src/alloc.c (Fmemory_info):
* src/category.c (Fdefine_category, Fmodify_category_entry):
* src/data.c (Fash):
* src/dispextern.h (GLYPH_CODE_P):
* src/emacs.c (load_seccomp):
* src/fns.c (Flocale_info, maybe_resize_hash_table):
* src/indent.c (check_display_width):
* src/json.c (symset_size):
* src/lisp.h (XUNTAG, BOOL_VECTOR_LENGTH_MAX, obarray_size)
(hash_table_index_size):
* src/lread.c (make_obarray, grow_obarray, Fobarray_clear):
* src/menu.c (digest_single_submenu, x_popup_menu_1):
* src/term.c (init_tty):
* src/widget.c (update_wm_hints):
* src/xdisp.c (truncate_echo_area):
* src/xfns.c (x_set_border_pixel):
* src/xfont.c (xfont_match, xfont_open):
* src/xmenu.c (set_frame_menubar):
* test/src/emacs-module-resources/mod-test.c (emacs_module_init):
Use compound literal instead of a cast that is useless in
some platforms but not others.
* src/dispextern.h, src/haikugui.h, src/w32gui.h:
(WINDOW_HANDLE_UINTPTR): New macro.
* src/frame.c (gui_report_frame_params):
* src/xterm.c (x_try_cr_xlib_drawable):
Use it.
* src/lisp.h (XUNTAG): And tag with UINTPTR_MAX to pacify
gcc warning about a constant out of range.
(hash_idx_t): Make it int_least32_t, as it need not be exactly 32 bits.
(PRIdHASH_IDX): New macro.
* src/pdumper.c (dump_queue_dequeue): Use it.
* src/profiler.c (setup_cpu_timer): Make a local EMACS_INT
rather than int, to avoid need for casting later.
* src/syntax.c (uninitialized_interval):
Use 1u rather than 1 so the cast is always useful.
A compound literal wouldn’t do here, as this macro
needs to be an integer constant expression.
* src/xfns.c (XICCallback, XICProc): Remove macros.
(Xxic_preedit_start_callback): Use a cleaner way to specify it,
avoiding the need for type macros, and for a cast
if HAVE_XICCALLBACK_CALLBACK.
* src/xterm.c (handle_one_xevent): 2nd arg is now XEvent *
on all platforms, as there is no need to diverge, and
diverging meant we needed lots of unnecessary casts.
This commit is contained in:
Paul Eggert 2026-05-26 17:51:44 -07:00
parent ca5e9976b1
commit 5d8bb14d3b
33 changed files with 150 additions and 149 deletions

View file

@ -118,7 +118,7 @@ xlwMenuResources[] =
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
offset(menu.foreground), XtRString, "XtDefaultForeground"}, offset(menu.foreground), XtRString, "XtDefaultForeground"},
{XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel), {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel),
offset(menu.disabled_foreground), XtRString, (XtPointer)NULL}, offset(menu.disabled_foreground), XtRString, NULL},
{XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel), {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
offset(menu.button_foreground), XtRString, "XtDefaultForeground"}, offset(menu.button_foreground), XtRString, "XtDefaultForeground"},
{XtNhighlightForeground, XtCHighlightForeground, XtRPixel, sizeof(Pixel), {XtNhighlightForeground, XtCHighlightForeground, XtRPixel, sizeof(Pixel),
@ -147,17 +147,17 @@ xlwMenuResources[] =
offset (menu.bottom_shadow_pixmap), XtRImmediate, (XtPointer)None}, offset (menu.bottom_shadow_pixmap), XtRImmediate, (XtPointer)None},
{XtNopen, XtCCallback, XtRCallback, sizeof(XtPointer), {XtNopen, XtCCallback, XtRCallback, sizeof(XtPointer),
offset(menu.open), XtRCallback, (XtPointer)NULL}, offset(menu.open), XtRCallback, NULL},
{XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer), {XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer),
offset(menu.select), XtRCallback, (XtPointer)NULL}, offset(menu.select), XtRCallback, NULL},
{XtNhighlightCallback, XtCCallback, XtRCallback, sizeof(XtPointer), {XtNhighlightCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
offset(menu.highlight), XtRCallback, (XtPointer)NULL}, offset(menu.highlight), XtRCallback, NULL},
{XtNenterCallback, XtCCallback, XtRCallback, sizeof(XtPointer), {XtNenterCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
offset(menu.enter), XtRCallback, (XtPointer)NULL}, offset(menu.enter), XtRCallback, NULL},
{XtNleaveCallback, XtCCallback, XtRCallback, sizeof(XtPointer), {XtNleaveCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
offset(menu.leave), XtRCallback, (XtPointer)NULL}, offset(menu.leave), XtRCallback, NULL},
{XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer), {XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer),
offset(menu.contents), XtRImmediate, (XtPointer)NULL}, offset(menu.contents), XtRImmediate, NULL},
{XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
offset(menu.cursor_shape), XtRString, (XtPointer)"right_ptr"}, offset(menu.cursor_shape), XtRString, (XtPointer)"right_ptr"},
{XtNhorizontal, XtCHorizontal, XtRInt, sizeof(int), {XtNhorizontal, XtCHorizontal, XtRInt, sizeof(int),
@ -208,7 +208,7 @@ xlwMenuActionsList [] =
XlwMenuClassRec xlwMenuClassRec = XlwMenuClassRec xlwMenuClassRec =
{ {
{ /* CoreClass fields initialization */ { /* CoreClass fields initialization */
(WidgetClass) SuperClass, /* superclass */ SuperClass, /* superclass */
"XlwMenu", /* class_name */ "XlwMenu", /* class_name */
sizeof(XlwMenuRec), /* size */ sizeof(XlwMenuRec), /* size */
XlwMenuClassInitialize, /* class_initialize */ XlwMenuClassInitialize, /* class_initialize */
@ -430,7 +430,7 @@ resource_widget_value (XlwMenuWidget mw, widget_value *val)
resourced_name = val->name; resourced_name = val->name;
if (!val->value) if (!val->value)
{ {
complete_name = (char *) XtMalloc (strlen (resourced_name) + 1); complete_name = XtMalloc (strlen (resourced_name) + 1);
strcpy (complete_name, resourced_name); strcpy (complete_name, resourced_name);
} }
else else
@ -2259,7 +2259,7 @@ XlwMenuDestroy (Widget w)
XlwMenuWidget mw = (XlwMenuWidget) w; XlwMenuWidget mw = (XlwMenuWidget) w;
if (pointer_grabbed) if (pointer_grabbed)
ungrab_all ((Widget)w, CurrentTime); ungrab_all (w, CurrentTime);
pointer_grabbed = 0; pointer_grabbed = 0;
keyboard_grabbed = 0; keyboard_grabbed = 0;
@ -2773,7 +2773,7 @@ Select (Widget w, XEvent *ev, String *params, Cardinal *num_params)
after the initial down-click that brought the menu up, after the initial down-click that brought the menu up,
do nothing. */ do nothing. */
if ((selected_item == 0 if ((selected_item == 0
|| ((widget_value *) selected_item)->call_data == 0) || selected_item->call_data == 0)
&& !next_release_must_exit && !next_release_must_exit
&& (ev->xbutton.time - menu_post_event.xbutton.time && (ev->xbutton.time - menu_post_event.xbutton.time
< XtGetMultiClickTime (XtDisplay (w)))) < XtGetMultiClickTime (XtDisplay (w))))

View file

@ -6609,7 +6609,7 @@ process_mark_stack (ptrdiff_t base_sp)
case PVEC_CHAR_TABLE: case PVEC_CHAR_TABLE:
case PVEC_SUB_CHAR_TABLE: case PVEC_SUB_CHAR_TABLE:
mark_char_table (ptr, (enum pvec_type) pvectype); mark_char_table (ptr, pvectype);
break; break;
case PVEC_BOOL_VECTOR: case PVEC_BOOL_VECTOR:
@ -7177,28 +7177,28 @@ respective remote host. */)
#else #else
units = 1; units = 1;
#endif #endif
return list4i ((uintmax_t) si.totalram * units / 1024, return list4i ((uintmax_t) {si.totalram} * units / 1024,
(uintmax_t) si.freeram * units / 1024, (uintmax_t) {si.freeram} * units / 1024,
(uintmax_t) si.totalswap * units / 1024, (uintmax_t) {si.totalswap} * units / 1024,
(uintmax_t) si.freeswap * units / 1024); (uintmax_t) {si.freeswap} * units / 1024);
#elif defined WINDOWSNT #elif defined WINDOWSNT
unsigned long long totalram, freeram, totalswap, freeswap; unsigned long long totalram, freeram, totalswap, freeswap;
if (w32_memory_info (&totalram, &freeram, &totalswap, &freeswap) == 0) if (w32_memory_info (&totalram, &freeram, &totalswap, &freeswap) == 0)
return list4i ((uintmax_t) totalram / 1024, return list4i ((uintmax_t) {totalram} / 1024,
(uintmax_t) freeram / 1024, (uintmax_t) {freeram} / 1024,
(uintmax_t) totalswap / 1024, (uintmax_t) {totalswap} / 1024,
(uintmax_t) freeswap / 1024); (uintmax_t) {freeswap} / 1024);
else else
return Qnil; return Qnil;
#elif defined MSDOS #elif defined MSDOS
unsigned long totalram, freeram, totalswap, freeswap; unsigned long totalram, freeram, totalswap, freeswap;
if (dos_memory_info (&totalram, &freeram, &totalswap, &freeswap) == 0) if (dos_memory_info (&totalram, &freeram, &totalswap, &freeswap) == 0)
return list4i ((uintmax_t) totalram / 1024, return list4i ((uintmax_t) {totalram} / 1024,
(uintmax_t) freeram / 1024, (uintmax_t) {freeram} / 1024,
(uintmax_t) totalswap / 1024, (uintmax_t) {totalswap} / 1024,
(uintmax_t) freeswap / 1024); (uintmax_t) {freeswap} / 1024);
else else
return Qnil; return Qnil;
#else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT, not MSDOS */ #else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT, not MSDOS */

View file

@ -117,7 +117,7 @@ the current buffer's category table. */)
table = check_category_table (table); table = check_category_table (table);
if (!NILP (CATEGORY_DOCSTRING (table, XFIXNAT (category)))) if (!NILP (CATEGORY_DOCSTRING (table, XFIXNAT (category))))
error ("Category `%c' is already defined", (int) XFIXNAT (category)); error ("Category `%c' is already defined", (int) {XFIXNAT (category)});
SET_CATEGORY_DOCSTRING (table, XFIXNAT (category), docstring); SET_CATEGORY_DOCSTRING (table, XFIXNAT (category), docstring);
return Qnil; return Qnil;
@ -347,7 +347,7 @@ then delete CATEGORY from the category set instead of adding it. */)
table = check_category_table (table); table = check_category_table (table);
if (NILP (CATEGORY_DOCSTRING (table, XFIXNAT (category)))) if (NILP (CATEGORY_DOCSTRING (table, XFIXNAT (category))))
error ("Undefined category: %c", (int) XFIXNAT (category)); error ("Undefined category: %c", (int) {XFIXNAT (category)});
set_value = NILP (reset); set_value = NILP (reset);

View file

@ -1873,8 +1873,7 @@ composition_adjust_point (ptrdiff_t last_pt, ptrdiff_t new_pt)
return new_pt; return new_pt;
/* Next check the automatic composition. */ /* Next check the automatic composition. */
if (! find_automatic_composition (new_pt, (ptrdiff_t) -1, (ptrdiff_t) -1, if (! find_automatic_composition (new_pt, -1, -1, &beg, &end, &val, Qnil)
&beg, &end, &val, Qnil)
|| beg == new_pt) || beg == new_pt)
return new_pt; return new_pt;
for (i = 0; i < LGSTRING_GLYPH_LEN (val); i++) for (i = 0; i < LGSTRING_GLYPH_LEN (val); i++)
@ -2074,7 +2073,7 @@ See `find-composition' for more details. */)
&& !NILP (BVAR (current_buffer, enable_multibyte_characters))) && !NILP (BVAR (current_buffer, enable_multibyte_characters)))
|| (!NILP (string) && STRING_MULTIBYTE (string))) || (!NILP (string) && STRING_MULTIBYTE (string)))
&& ! inhibit_auto_composition () && ! inhibit_auto_composition ()
&& find_automatic_composition (from, to, (ptrdiff_t) -1, && find_automatic_composition (from, to, -1,
&start, &end, &gstring, string)) &start, &end, &gstring, string))
return list3 (make_fixnum (start), make_fixnum (end), gstring); return list3 (make_fixnum (start), make_fixnum (end), gstring);
return Qnil; return Qnil;
@ -2083,7 +2082,7 @@ See `find-composition' for more details. */)
{ {
ptrdiff_t s, e; ptrdiff_t s, e;
if (find_automatic_composition (from, to, (ptrdiff_t) -1, if (find_automatic_composition (from, to, -1,
&s, &e, &gstring, string) &s, &e, &gstring, string)
&& (e <= fixed_pos ? e > end : s < start)) && (e <= fixed_pos ? e > end : s < start))
return list3 (make_fixnum (s), make_fixnum (e), gstring); return list3 (make_fixnum (s), make_fixnum (e), gstring);

View file

@ -2583,7 +2583,7 @@ or a byte-code object. IDX starts at 0. */)
if (idxval < 0 || idxval >= SCHARS (array)) if (idxval < 0 || idxval >= SCHARS (array))
args_out_of_range (array, idx); args_out_of_range (array, idx);
if (! STRING_MULTIBYTE (array)) if (! STRING_MULTIBYTE (array))
return make_fixnum ((unsigned char) SREF (array, idxval)); return make_fixnum (SREF (array, idxval));
idxval_byte = string_char_to_byte (array, idxval); idxval_byte = string_char_to_byte (array, idxval);
c = STRING_CHAR (SDATA (array) + idxval_byte); c = STRING_CHAR (SDATA (array) + idxval_byte);
@ -3587,7 +3587,7 @@ discarding bits. */)
if (c == 0) if (c == 0)
return value; return value;
if ((EMACS_INT) -1 >> 1 == -1 && FIXNUMP (value)) if ((EMACS_INT) {-1} >> 1 == -1 && FIXNUMP (value))
{ {
EMACS_INT shift = -c; EMACS_INT shift = -c;
EMACS_INT result EMACS_INT result

View file

@ -185,6 +185,14 @@ typedef void *Emacs_Cursor;
#ifdef HAVE_WINDOW_SYSTEM #ifdef HAVE_WINDOW_SYSTEM
/* Convert a window handle to uintptr_t. This default uses a compound literal,
which is good for platforms where handles are integers, as it checks
types better than a cast would. Platforms where handles are pointers
should override the default with a more-powerful cast. */
# ifndef WINDOW_HANDLE_UINTPTR
# define WINDOW_HANDLE_UINTPTR(h) ((uintptr_t) {(h)})
# endif
/* ``box'' structure similar to that found in the X sample server, /* ``box'' structure similar to that found in the X sample server,
meaning that X2 and Y2 are not actually the end of the box, but one meaning that X2 and Y2 are not actually the end of the box, but one
pixel past the end of the box, which makes checking for overlaps pixel past the end of the box, which makes checking for overlaps
@ -2045,7 +2053,7 @@ GLYPH_CODE_P (Lisp_Object gc)
: (RANGED_FIXNUMP : (RANGED_FIXNUMP
(0, gc, (0, gc,
(MAX_FACE_ID < EMACS_INT_MAX >> CHARACTERBITS (MAX_FACE_ID < EMACS_INT_MAX >> CHARACTERBITS
? ((EMACS_INT) MAX_FACE_ID << CHARACTERBITS) | MAX_CHAR ? ((EMACS_INT) {MAX_FACE_ID} << CHARACTERBITS) | MAX_CHAR
: EMACS_INT_MAX)))); : EMACS_INT_MAX))));
} }

View file

@ -1120,7 +1120,7 @@ module_extract_big_integer (emacs_env *env, emacs_value arg, int *sign,
u = -(EMACS_UINT) x; u = -(EMACS_UINT) x;
static_assert (required * bits < PTRDIFF_MAX); static_assert (required * bits < PTRDIFF_MAX);
for (ptrdiff_t i = 0; i < required; ++i) for (ptrdiff_t i = 0; i < required; ++i)
magnitude[i] = (emacs_limb_t) (u >> (i * bits)); magnitude[i] = u >> (i * bits);
MODULE_INTERNAL_CLEANUP (); MODULE_INTERNAL_CLEANUP ();
return true; return true;
} }

View file

@ -1232,7 +1232,7 @@ load_seccomp (const char *file)
|| stat.st_size % sizeof *program.filter != 0) || stat.st_size % sizeof *program.filter != 0)
{ {
fprintf (stderr, "seccomp filter %s has invalid size %ld\n", fprintf (stderr, "seccomp filter %s has invalid size %ld\n",
file, (long) stat.st_size); file, (long) {stat.st_size});
goto out; goto out;
} }
if (ckd_add (&program.len, stat.st_size / sizeof *program.filter, 0)) if (ckd_add (&program.len, stat.st_size / sizeof *program.filter, 0))

View file

@ -4396,7 +4396,7 @@ by calling `format-decode', which see. */)
Ferase_buffer (); Ferase_buffer ();
bset_enable_multibyte_characters (buf, Qnil); bset_enable_multibyte_characters (buf, Qnil);
insert_1_both ((char *) read_buf, nread, nread, 0, 0, 0); insert_1_both (read_buf, nread, nread, 0, 0, 0);
TEMP_SET_PT_BOTH (BEG, BEG_BYTE); TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
coding_system = calln (Vset_auto_coding_function, coding_system = calln (Vset_auto_coding_function,
filename, make_fixnum (nread)); filename, make_fixnum (nread));

View file

@ -3959,14 +3959,14 @@ The data read from the system are decoded using `locale-coding-system'. */)
# endif # endif
# ifdef HAVE_LANGINFO__NL_PAPER_WIDTH # ifdef HAVE_LANGINFO__NL_PAPER_WIDTH
if (EQ (item, Qpaper)) if (EQ (item, Qpaper))
/* We have to cast twice here: first to a correctly-sized integer, /* We have to convert twice here: first to a correctly-sized integer,
then to int, because that's what nl_langinfo is documented to then to int, because that's what nl_langinfo is documented to
return for _NO_PAPER_{WIDTH,HEIGHT}. The first cast doesn't return for _NO_PAPER_{WIDTH,HEIGHT}. The cast doesn't
suffice because it could overflow an Emacs fixnum. This can suffice because it could overflow an Emacs fixnum. This can
happen when running under ASan, which fills allocated but happen when running under ASan, which fills allocated but
uninitialized memory with 0xBE bytes. */ uninitialized memory with 0xBE bytes. */
return list2i ((int) (intptr_t) nl_langinfo (_NL_PAPER_WIDTH), return list2i ((int) {(intptr_t) nl_langinfo (_NL_PAPER_WIDTH)},
(int) (intptr_t) nl_langinfo (_NL_PAPER_HEIGHT)); (int) {(intptr_t) nl_langinfo (_NL_PAPER_HEIGHT)});
# endif # endif
#endif /* HAVE_LANGINFO_CODESET*/ #endif /* HAVE_LANGINFO_CODESET*/
return Qnil; return Qnil;
@ -4987,7 +4987,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
ptrdiff_t old_index_size = hash_table_index_size (h); ptrdiff_t old_index_size = hash_table_index_size (h);
ptrdiff_t index_bits = compute_hash_index_bits (new_size); ptrdiff_t index_bits = compute_hash_index_bits (new_size);
ptrdiff_t index_size = (ptrdiff_t)1 << index_bits; ptrdiff_t index_size = (ptrdiff_t) {1} << index_bits;
hash_idx_t *index = hash_table_alloc_bytes (index_size * sizeof *index); hash_idx_t *index = hash_table_alloc_bytes (index_size * sizeof *index);
for (ptrdiff_t i = 0; i < index_size; i++) for (ptrdiff_t i = 0; i < index_size; i++)
index[i] = -1; index[i] = -1;

View file

@ -5458,7 +5458,7 @@ gui_report_frame_params (struct frame *f, Lisp_Object *alistptr)
E.g., on MS-Windows it returns a value whose type is HANDLE, E.g., on MS-Windows it returns a value whose type is HANDLE,
which is actually a pointer. Explicit casting avoids compiler which is actually a pointer. Explicit casting avoids compiler
warnings. */ warnings. */
w = (uintptr_t) FRAME_NATIVE_WINDOW (f); w = WINDOW_HANDLE_UINTPTR (FRAME_NATIVE_WINDOW (f));
store_in_alist (alistptr, Qwindow_id, store_in_alist (alistptr, Qwindow_id,
make_formatted_string ("%"PRIuMAX, w)); make_formatted_string ("%"PRIuMAX, w));
#ifdef HAVE_X_WINDOWS #ifdef HAVE_X_WINDOWS
@ -5466,7 +5466,7 @@ gui_report_frame_params (struct frame *f, Lisp_Object *alistptr)
/* Tooltip frame may not have this widget. */ /* Tooltip frame may not have this widget. */
if (FRAME_X_OUTPUT (f)->widget) if (FRAME_X_OUTPUT (f)->widget)
#endif #endif
w = (uintptr_t) FRAME_OUTER_WINDOW (f); w = WINDOW_HANDLE_UINTPTR (FRAME_OUTER_WINDOW (f));
store_in_alist (alistptr, Qouter_window_id, store_in_alist (alistptr, Qouter_window_id,
make_formatted_string ("%"PRIuMAX, w)); make_formatted_string ("%"PRIuMAX, w));
#endif #endif
@ -5480,7 +5480,8 @@ gui_report_frame_params (struct frame *f, Lisp_Object *alistptr)
if (FRAME_OUTPUT_DATA (f)->parent_desc == FRAME_DISPLAY_INFO (f)->root_window) if (FRAME_OUTPUT_DATA (f)->parent_desc == FRAME_DISPLAY_INFO (f)->root_window)
tem = Qnil; tem = Qnil;
else else
tem = make_fixed_natnum ((uintptr_t) FRAME_OUTPUT_DATA (f)->parent_desc); tem = make_fixed_natnum (WINDOW_HANDLE_UINTPTR
(FRAME_OUTPUT_DATA (f)->parent_desc));
store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil)); store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil));
store_in_alist (alistptr, Qparent_id, tem); store_in_alist (alistptr, Qparent_id, tem);
store_in_alist (alistptr, Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f)); store_in_alist (alistptr, Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f));

View file

@ -1382,7 +1382,7 @@ FRAME_PARENT_FRAME (struct frame *f)
width of the frame by 4 because multi-byte form may require at most width of the frame by 4 because multi-byte form may require at most
4-byte for a character. */ 4-byte for a character. */
#define FRAME_MESSAGE_BUF_SIZE(f) (((int) FRAME_COLS (f)) * 4) #define FRAME_MESSAGE_BUF_SIZE(f) (4 * FRAME_COLS (f))
#define CHECK_FRAME(x) \ #define CHECK_FRAME(x) \
CHECK_TYPE (FRAMEP (x), Qframep, x) CHECK_TYPE (FRAMEP (x), Qframep, x)

View file

@ -5738,8 +5738,7 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char *stock_name,
gpointer gold_img = g_object_get_data (G_OBJECT (wimage), gpointer gold_img = g_object_get_data (G_OBJECT (wimage),
XG_TOOL_BAR_IMAGE_DATA); XG_TOOL_BAR_IMAGE_DATA);
#ifdef USE_CAIRO #ifdef USE_CAIRO
void *old_img = (void *) gold_img; if (gold_img != img->cr_data)
if (old_img != img->cr_data)
return 1; return 1;
#else #else
Pixmap old_img = (Pixmap) gold_img; Pixmap old_img = (Pixmap) gold_img;
@ -6106,7 +6105,7 @@ update_frame_tool_bar (struct frame *f)
w = xg_get_image_for_pixmap (f, img, x->widget, NULL); w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA,
#ifdef USE_CAIRO #ifdef USE_CAIRO
(gpointer)img->cr_data img->cr_data
#else #else
(gpointer)img->pixmap (gpointer)img->pixmap
#endif #endif

View file

@ -36,6 +36,8 @@ struct haiku_rect
typedef void *haiku; typedef void *haiku;
#define WINDOW_HANDLE_UINTPTR(h) ((uintptr_t) (h))
typedef haiku Emacs_Pixmap; typedef haiku Emacs_Pixmap;
typedef haiku Emacs_Window; typedef haiku Emacs_Window;
typedef haiku Emacs_Cursor; typedef haiku Emacs_Cursor;

View file

@ -7840,8 +7840,7 @@ pbm_load (struct frame *f, struct image *img)
/* Maybe fill in the background field while we have ximg handy. */ /* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL))) if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
/* Casting avoids a GCC warning. */ IMAGE_BACKGROUND (img, f, ximg);
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */ /* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0); image_put_x_image (f, img, ximg, 0);
@ -8586,9 +8585,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
img->width = width; img->width = width;
img->height = height; img->height = height;
/* Maybe fill in the background field while we have ximg handy. /* Maybe fill in the background field while we have ximg handy. */
Casting avoids a GCC warning. */ IMAGE_BACKGROUND (img, f, ximg);
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */ /* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0); image_put_x_image (f, img, ximg, 0);
@ -8597,8 +8595,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
if (mask_img) if (mask_img)
{ {
/* Fill in the background_transparent field while we have the /* Fill in the background_transparent field while we have the
mask handy. Casting avoids a GCC warning. */ mask handy. */
image_background_transparent (img, f, (Emacs_Pix_Context)mask_img); image_background_transparent (img, f, mask_img);
image_put_x_image (f, img, mask_img, 1); image_put_x_image (f, img, mask_img, 1);
} }
@ -9165,8 +9163,7 @@ jpeg_load_body (struct frame *f, struct image *img,
/* Maybe fill in the background field while we have ximg handy. */ /* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL))) if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
/* Casting avoids a GCC warning. */ IMAGE_BACKGROUND (img, f, ximg);
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */ /* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0); image_put_x_image (f, img, ximg, 0);
@ -9606,8 +9603,7 @@ tiff_load (struct frame *f, struct image *img)
/* Maybe fill in the background field while we have ximg handy. */ /* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL))) if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
/* Casting avoids a GCC warning on W32. */ IMAGE_BACKGROUND (img, f, ximg);
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */ /* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0); image_put_x_image (f, img, ximg, 0);
@ -10329,8 +10325,7 @@ gif_load (struct frame *f, struct image *img)
/* Maybe fill in the background field while we have ximg handy. */ /* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL))) if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
/* Casting avoids a GCC warning. */ IMAGE_BACKGROUND (img, f, ximg);
IMAGE_BACKGROUND (img, f, (Emacs_Pix_Context)ximg);
/* Put ximg into the image. */ /* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0); image_put_x_image (f, img, ximg, 0);

View file

@ -500,7 +500,7 @@ check_display_width (Lisp_Object window,
Lisp_Object prop; Lisp_Object prop;
EMACS_INT align_to_max = EMACS_INT align_to_max =
(col < MOST_POSITIVE_FIXNUM - INT_MAX (col < MOST_POSITIVE_FIXNUM - INT_MAX
? (EMACS_INT) INT_MAX + col ? (EMACS_INT) {INT_MAX} + col
: MOST_POSITIVE_FIXNUM); : MOST_POSITIVE_FIXNUM);
plist = XCDR (val); plist = XCDR (val);

View file

@ -134,7 +134,7 @@ struct symset_tbl
static inline ptrdiff_t static inline ptrdiff_t
symset_size (int bits) symset_size (int bits)
{ {
return (ptrdiff_t) 1 << bits; return (ptrdiff_t) {1} << bits;
} }
static struct symset_tbl * static struct symset_tbl *

View file

@ -747,10 +747,11 @@ INLINE void
/* Extract A's pointer value, assuming A's Lisp type is TYPE and the /* Extract A's pointer value, assuming A's Lisp type is TYPE and the
extracted pointer's type is CTYPE *. When !USE_LSB_TAG this simply extracted pointer's type is CTYPE *. When !USE_LSB_TAG this simply
extracts A's low-order bits, as (uintptr_t) LISP_WORD_TAG (type) is extracts A's low-order bits, as LISP_WORD_TAG (type) & UINTPTR_MAX is
always zero then. */ always zero then. */
#define XUNTAG(a, type, ctype) \ #define XUNTAG(a, type, ctype) \
((ctype *) ((uintptr_t) XLP (a) - (uintptr_t) LISP_WORD_TAG (type))) ((ctype *) ((uintptr_t) XLP (a) \
- (uintptr_t) {LISP_WORD_TAG (type) & UINTPTR_MAX}))
/* A forwarding pointer to a value. It uses a generic pointer to /* A forwarding pointer to a value. It uses a generic pointer to
avoid alignment bugs that could occur if it used a pointer to a avoid alignment bugs that could occur if it used a pointer to a
@ -1841,10 +1842,10 @@ enum
#define BOOL_VECTOR_LENGTH_MAX \ #define BOOL_VECTOR_LENGTH_MAX \
min (MOST_POSITIVE_FIXNUM, \ min (MOST_POSITIVE_FIXNUM, \
((INT_MULTIPLY_OVERFLOW (min (PTRDIFF_MAX, SIZE_MAX) - bool_header_size,\ ((INT_MULTIPLY_OVERFLOW (min (PTRDIFF_MAX, SIZE_MAX) - bool_header_size,\
(EMACS_INT) BOOL_VECTOR_BITS_PER_CHAR) \ (EMACS_INT) {BOOL_VECTOR_BITS_PER_CHAR}) \
? EMACS_INT_MAX \ ? EMACS_INT_MAX \
: ((min (PTRDIFF_MAX, SIZE_MAX) - bool_header_size) \ : ((min (PTRDIFF_MAX, SIZE_MAX) - bool_header_size) \
* (EMACS_INT) BOOL_VECTOR_BITS_PER_CHAR)) \ * (EMACS_INT) {BOOL_VECTOR_BITS_PER_CHAR})) \
- (BITS_PER_BITS_WORD - 1))) - (BITS_PER_BITS_WORD - 1)))
/* The number of data words and bytes in a bool vector with SIZE bits. */ /* The number of data words and bytes in a bool vector with SIZE bits. */
@ -2437,7 +2438,7 @@ make_lisp_obarray (struct Lisp_Obarray *o)
INLINE ptrdiff_t INLINE ptrdiff_t
obarray_size (const struct Lisp_Obarray *o) obarray_size (const struct Lisp_Obarray *o)
{ {
return (ptrdiff_t)1 << o->size_bits; return (ptrdiff_t) {1} << o->size_bits;
} }
Lisp_Object check_obarray_slow (Lisp_Object); Lisp_Object check_obarray_slow (Lisp_Object);
@ -2557,7 +2558,8 @@ typedef enum hash_table_weakness_t {
/* The type of a hash table index, both for table indices and index /* The type of a hash table index, both for table indices and index
(hash) indices. It's signed and a subtype of ptrdiff_t. */ (hash) indices. It's signed and a subtype of ptrdiff_t. */
typedef int32_t hash_idx_t; typedef int_least32_t hash_idx_t;
#define PRIdHASH_IDX PRIdLEAST32
struct Lisp_Hash_Table struct Lisp_Hash_Table
{ {
@ -2715,7 +2717,7 @@ HASH_TABLE_SIZE (const struct Lisp_Hash_Table *h)
INLINE ptrdiff_t INLINE ptrdiff_t
hash_table_index_size (const struct Lisp_Hash_Table *h) hash_table_index_size (const struct Lisp_Hash_Table *h)
{ {
return (ptrdiff_t)1 << h->index_bits; return (ptrdiff_t) {1} << h->index_bits;
} }
/* Hash value for KEY in hash table H. */ /* Hash value for KEY in hash table H. */

View file

@ -5029,7 +5029,7 @@ make_obarray (unsigned bits)
struct Lisp_Obarray *o = allocate_obarray (); struct Lisp_Obarray *o = allocate_obarray ();
o->count = 0; o->count = 0;
o->size_bits = bits; o->size_bits = bits;
ptrdiff_t size = (ptrdiff_t)1 << bits; ptrdiff_t size = (ptrdiff_t) {1} << bits;
o->buckets = hash_table_alloc_bytes (size * sizeof *o->buckets); o->buckets = hash_table_alloc_bytes (size * sizeof *o->buckets);
for (ptrdiff_t i = 0; i < size; i++) for (ptrdiff_t i = 0; i < size; i++)
o->buckets[i] = make_fixnum (0); o->buckets[i] = make_fixnum (0);
@ -5053,7 +5053,7 @@ grow_obarray (struct Lisp_Obarray *o)
int new_bits = o->size_bits + 1; int new_bits = o->size_bits + 1;
if (new_bits > obarray_max_bits) if (new_bits > obarray_max_bits)
error ("Obarray too big"); error ("Obarray too big");
ptrdiff_t new_size = (ptrdiff_t)1 << new_bits; ptrdiff_t new_size = (ptrdiff_t) {1} << new_bits;
o->buckets = hash_table_alloc_bytes (new_size * sizeof *o->buckets); o->buckets = hash_table_alloc_bytes (new_size * sizeof *o->buckets);
for (ptrdiff_t i = 0; i < new_size; i++) for (ptrdiff_t i = 0; i < new_size; i++)
o->buckets[i] = make_fixnum (0); o->buckets[i] = make_fixnum (0);
@ -5123,7 +5123,7 @@ DEFUN ("obarray-clear", Fobarray_clear, Sobarray_clear, 1, 1, 0,
/* This function does not bother setting the status of its contained symbols /* This function does not bother setting the status of its contained symbols
to uninterned. It doesn't matter very much. */ to uninterned. It doesn't matter very much. */
int new_bits = obarray_default_bits; int new_bits = obarray_default_bits;
int new_size = (ptrdiff_t)1 << new_bits; int new_size = (ptrdiff_t) {1} << new_bits;
Lisp_Object *new_buckets Lisp_Object *new_buckets
= hash_table_alloc_bytes (new_size * sizeof *new_buckets); = hash_table_alloc_bytes (new_size * sizeof *new_buckets);
for (ptrdiff_t i = 0; i < new_size; i++) for (ptrdiff_t i = 0; i < new_size; i++)

View file

@ -803,9 +803,9 @@ digest_single_submenu (int start, int end, bool top_level_items)
wv->lname = item_name; wv->lname = item_name;
if (!NILP (descrip)) if (!NILP (descrip))
wv->lkey = descrip; wv->lkey = descrip;
/* The intptr_t cast avoids a warning. There's no problem /* The intptr_t avoids a warning. There's no problem
as long as pointers have enough bits to hold small integers. */ as long as pointers have enough bits to hold small integers. */
wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0); wv->call_data = (!NILP (def) ? (void *) (intptr_t) {i} : 0);
if (NILP (type)) if (NILP (type))
wv->button_type = BUTTON_TYPE_NONE; wv->button_type = BUTTON_TYPE_NONE;
@ -1272,12 +1272,12 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
xpos += check_integer_range (x, xpos += check_integer_range (x,
(xpos < INT_MIN - MOST_NEGATIVE_FIXNUM (xpos < INT_MIN - MOST_NEGATIVE_FIXNUM
? (EMACS_INT) INT_MIN - xpos ? (EMACS_INT) {INT_MIN} - xpos
: MOST_NEGATIVE_FIXNUM), : MOST_NEGATIVE_FIXNUM),
INT_MAX - xpos); INT_MAX - xpos);
ypos += check_integer_range (y, ypos += check_integer_range (y,
(ypos < INT_MIN - MOST_NEGATIVE_FIXNUM (ypos < INT_MIN - MOST_NEGATIVE_FIXNUM
? (EMACS_INT) INT_MIN - ypos ? (EMACS_INT) {INT_MIN} - ypos
: MOST_NEGATIVE_FIXNUM), : MOST_NEGATIVE_FIXNUM),
INT_MAX - ypos); INT_MAX - ypos);

View file

@ -159,7 +159,7 @@ ptrdiff_t_to_dump_off (ptrdiff_t value)
{ {
eassert (DUMP_OFF_MIN <= value); eassert (DUMP_OFF_MIN <= value);
eassert (value <= DUMP_OFF_MAX); eassert (value <= DUMP_OFF_MAX);
return (dump_off) value; return value;
} }
/* Worst-case allocation granularity on any system that might load /* Worst-case allocation granularity on any system that might load
@ -1234,13 +1234,14 @@ dump_queue_dequeue (struct dump_queue *dump_queue, dump_off basis)
dump_trace dump_trace
(("dump_queue_dequeue basis=%"PRIdDUMP_OFF" fancy=%"PRIdPTR (("dump_queue_dequeue basis=%"PRIdDUMP_OFF" fancy=%"PRIdPTR
" zero=%"PRIdPTR" normal=%"PRIdPTR" strong=%"PRIdPTR" hash=%td\n"), " zero=%"PRIdPTR" normal=%"PRIdPTR" strong=%"PRIdPTR
" hash=%"PRIdHASH_IDX"\n"),
basis, basis,
dump_tailq_length (&dump_queue->fancy_weight_objects), dump_tailq_length (&dump_queue->fancy_weight_objects),
dump_tailq_length (&dump_queue->zero_weight_objects), dump_tailq_length (&dump_queue->zero_weight_objects),
dump_tailq_length (&dump_queue->one_weight_normal_objects), dump_tailq_length (&dump_queue->one_weight_normal_objects),
dump_tailq_length (&dump_queue->one_weight_strong_objects), dump_tailq_length (&dump_queue->one_weight_strong_objects),
(ptrdiff_t) XHASH_TABLE (dump_queue->link_weights)->count); XHASH_TABLE (dump_queue->link_weights)->count);
#define nr_candidates 3 #define nr_candidates 3
struct candidate struct candidate
@ -1773,7 +1774,7 @@ field_relpos (const void *in_start, const void *in_field)
ever violated, make sure the two pointers indeed point into the ever violated, make sure the two pointers indeed point into the
same object, and if so, enlarge the value of PDUMPER_MAX_OBJECT_SIZE. */ same object, and if so, enlarge the value of PDUMPER_MAX_OBJECT_SIZE. */
eassert (relpos < PDUMPER_MAX_OBJECT_SIZE); eassert (relpos < PDUMPER_MAX_OBJECT_SIZE);
return (dump_off) relpos; return relpos;
} }
static void static void
@ -1967,7 +1968,7 @@ dump_field_emacs_ptr (struct dump_context *ctx,
intptr_t rel_emacs_ptr = 0; intptr_t rel_emacs_ptr = 0;
if (abs_emacs_ptr) if (abs_emacs_ptr)
{ {
rel_emacs_ptr = emacs_offset ((void *)abs_emacs_ptr); rel_emacs_ptr = emacs_offset (abs_emacs_ptr);
dump_reloc_dump_to_emacs_ptr_raw (ctx, ctx->obj_offset + relpos); dump_reloc_dump_to_emacs_ptr_raw (ctx, ctx->obj_offset + relpos);
} }
cpyptr ((char *) out + relpos, &rel_emacs_ptr); cpyptr ((char *) out + relpos, &rel_emacs_ptr);
@ -1980,7 +1981,7 @@ dump_object_start_pseudovector (struct dump_context *ctx,
{ {
eassert (in_hdr->size & PSEUDOVECTOR_FLAG); eassert (in_hdr->size & PSEUDOVECTOR_FLAG);
ptrdiff_t vec_size = vectorlike_nbytes (in_hdr); ptrdiff_t vec_size = vectorlike_nbytes (in_hdr);
dump_object_start (ctx, out_hdr, (dump_off) vec_size); dump_object_start (ctx, out_hdr, vec_size);
*out_hdr = *in_hdr; *out_hdr = *in_hdr;
} }
@ -4416,7 +4417,7 @@ pdumper_remember_scalar_impl (void *mem, ptrdiff_t nbytes)
{ {
eassert (0 <= nbytes && nbytes <= INT_MAX); eassert (0 <= nbytes && nbytes <= INT_MAX);
if (nbytes > 0) if (nbytes > 0)
pdumper_remember_user_data_1 (mem, (int) nbytes); pdumper_remember_user_data_1 (mem, nbytes);
} }
void void
@ -5655,7 +5656,7 @@ pdumper_load (const char *dump_filename, char *argv0)
err = PDUMPER_LOAD_BAD_FILE_TYPE; err = PDUMPER_LOAD_BAD_FILE_TYPE;
if (stat.st_size > INTPTR_MAX) if (stat.st_size > INTPTR_MAX)
goto out; goto out;
dump_size = (intptr_t) stat.st_size; dump_size = stat.st_size;
err = PDUMPER_LOAD_BAD_FILE_TYPE; err = PDUMPER_LOAD_BAD_FILE_TYPE;
if (dump_size < sizeof (*header)) if (dump_size < sizeof (*header))
@ -5910,7 +5911,6 @@ syms_of_pdumper (void)
doc: /* The fingerprint of this Emacs binary. doc: /* The fingerprint of this Emacs binary.
It is a string that is supposed to be unique to each build of It is a string that is supposed to be unique to each build of
Emacs. */); Emacs. */);
Vpdumper_fingerprint = make_unibyte_string ((char *) hexbuf, Vpdumper_fingerprint = make_unibyte_string (hexbuf, sizeof hexbuf);
sizeof hexbuf);
#endif /* HAVE_PDUMPER */ #endif /* HAVE_PDUMPER */
} }

View file

@ -392,12 +392,11 @@ deliver_profiler_signal (int signal)
static int static int
setup_cpu_timer (Lisp_Object sampling_interval) setup_cpu_timer (Lisp_Object sampling_interval)
{ {
int billion = 1000000000; EMACS_INT billion = 1000000000;
if (! RANGED_FIXNUMP (1, sampling_interval, if (! RANGED_FIXNUMP (1, sampling_interval,
(TYPE_MAXIMUM (time_t) < EMACS_INT_MAX / billion (TYPE_MAXIMUM (time_t) < EMACS_INT_MAX / billion
? ((EMACS_INT) TYPE_MAXIMUM (time_t) * billion ? TYPE_MAXIMUM (time_t) * billion + (billion - 1)
+ (billion - 1))
: EMACS_INT_MAX))) : EMACS_INT_MAX)))
return -1; return -1;

View file

@ -175,7 +175,7 @@ ptrdiff_t emacs_re_safe_alloca = MAX_ALLOCA;
(destination = SAFE_ALLOCA (nsize), \ (destination = SAFE_ALLOCA (nsize), \
memcpy (destination, source, osize)) memcpy (destination, source, osize))
/* True if 'size1' is non-NULL and PTR is pointing anywhere inside /* True if 'size1' is nonzero and PTR is pointing anywhere inside
'string1' or just past its end. This works if PTR is NULL, which is 'string1' or just past its end. This works if PTR is NULL, which is
a good thing. */ a good thing. */
#define FIRST_STRING_P(ptr) \ #define FIRST_STRING_P(ptr) \
@ -1210,7 +1210,7 @@ static bool analyze_first (struct re_pattern_buffer *bufp,
#define BUF_PUSH(c) \ #define BUF_PUSH(c) \
do { \ do { \
GET_BUFFER_SPACE (1); \ GET_BUFFER_SPACE (1); \
*b++ = (unsigned char) (c); \ *b++ = (c); \
} while (false) } while (false)
@ -1218,8 +1218,8 @@ static bool analyze_first (struct re_pattern_buffer *bufp,
#define BUF_PUSH_2(c1, c2) \ #define BUF_PUSH_2(c1, c2) \
do { \ do { \
GET_BUFFER_SPACE (2); \ GET_BUFFER_SPACE (2); \
*b++ = (unsigned char) (c1); \ *b++ = (c1); \
*b++ = (unsigned char) (c2); \ *b++ = (c2); \
} while (false) } while (false)
@ -3637,7 +3637,7 @@ static bool bcmp_translate (re_char *, re_char *, ptrdiff_t,
#define POINTER_TO_OFFSET(ptr) \ #define POINTER_TO_OFFSET(ptr) \
(FIRST_STRING_P (ptr) \ (FIRST_STRING_P (ptr) \
? (ptr) - string1 \ ? (ptr) - string1 \
: (ptr) - string2 + (ptrdiff_t) size1) : (ptr) - string2 + size1)
/* Call before fetching a character with *d. This switches over to /* Call before fetching a character with *d. This switches over to
string2 if necessary. string2 if necessary.

View file

@ -236,7 +236,7 @@ SYNTAX_MATCH (int c)
} }
/* A "dummy" value we never dereference, distinct from NULL. */ /* A "dummy" value we never dereference, distinct from NULL. */
#define uninitialized_interval ((INTERVAL) (intptr_t) 1) #define uninitialized_interval ((INTERVAL) (intptr_t) 1u)
/* This should be called with FROM at the start of forward /* This should be called with FROM at the start of forward
search, or after the last position of the backward search. It search, or after the last position of the backward search. It

View file

@ -4585,7 +4585,7 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
tty->TS_exit_attribute_mode = tgetstr ("me", address); tty->TS_exit_attribute_mode = tgetstr ("me", address);
#ifdef TERMINFO #ifdef TERMINFO
tty->TS_enter_strike_through_mode = tigetstr ("smxx"); tty->TS_enter_strike_through_mode = tigetstr ("smxx");
if (tty->TS_enter_strike_through_mode == (char *) (intptr_t) -1) if (tty->TS_enter_strike_through_mode == (char *) (intptr_t) {-1})
tty->TS_enter_strike_through_mode = NULL; tty->TS_enter_strike_through_mode = NULL;
#else #else
/* FIXME: Is calling tgetstr here for non-terminfo case correct, /* FIXME: Is calling tgetstr here for non-terminfo case correct,
@ -4621,8 +4621,8 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
const char *bg; const char *bg;
/* Our own non-standard support for 24-bit colors. */ /* Our own non-standard support for 24-bit colors. */
if ((fg = tigetstr ("setf24")) && (bg = tigetstr ("setb24")) if ((fg = tigetstr ("setf24")) && (bg = tigetstr ("setb24"))
&& fg != (char *) (intptr_t) -1 && fg != (char *) (intptr_t) {-1}
&& bg != (char *) (intptr_t) -1) && bg != (char *) (intptr_t) {-1})
{ {
tty->TS_set_foreground = fg; tty->TS_set_foreground = fg;
tty->TS_set_background = bg; tty->TS_set_background = bg;
@ -4630,8 +4630,8 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
} }
/* Other non-standard support for 24-bit colors. */ /* Other non-standard support for 24-bit colors. */
else if ((fg = tigetstr ("setrgbf")) && (bg = tigetstr ("setrgbb")) else if ((fg = tigetstr ("setrgbf")) && (bg = tigetstr ("setrgbb"))
&& fg != (char *) (intptr_t) -1 && fg != (char *) (intptr_t) {-1}
&& bg != (char *) (intptr_t) -1) && bg != (char *) (intptr_t) {-1})
{ {
tty->TS_set_foreground = fg; tty->TS_set_foreground = fg;
tty->TS_set_background = bg; tty->TS_set_background = bg;
@ -4692,7 +4692,7 @@ use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\
common default escape sequence and is not recommended. */ common default escape sequence and is not recommended. */
#ifdef TERMINFO #ifdef TERMINFO
tty->TF_set_underline_style = tigetstr ("Smulx"); tty->TF_set_underline_style = tigetstr ("Smulx");
if (tty->TF_set_underline_style == (char *) (intptr_t) -1) if (tty->TF_set_underline_style == (char *) (intptr_t) {-1})
tty->TF_set_underline_style = NULL; tty->TF_set_underline_style = NULL;
#else #else
tty->TF_set_underline_style = tgetstr ("Smulx", address); tty->TF_set_underline_style = tgetstr ("Smulx", address);

View file

@ -33,6 +33,8 @@ typedef HWND Window;
typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */ typedef HDC Display; /* HDC so it doesn't conflict with xpm lib. */
typedef HCURSOR Emacs_Cursor; typedef HCURSOR Emacs_Cursor;
#define WINDOW_HANDLE_UINTPTR(h) ((uintptr_t) (h))
/* Windows equivalent of XImage. */ /* Windows equivalent of XImage. */
typedef struct _XImage typedef struct _XImage
{ {

View file

@ -299,12 +299,12 @@ update_wm_hints (WMShellWidget wmshell, EmacsFrame ew)
+ (rounded_height - (char_height * ch))); + (rounded_height - (char_height * ch)));
XtVaSetValues ((Widget) wmshell, XtVaSetValues ((Widget) wmshell,
XtNbaseWidth, (XtArgVal) base_width, XtNbaseWidth, (XtArgVal) {base_width},
XtNbaseHeight, (XtArgVal) base_height, XtNbaseHeight, (XtArgVal) {base_height},
XtNwidthInc, (XtArgVal) (frame_resize_pixelwise ? 1 : cw), XtNwidthInc, (XtArgVal) {frame_resize_pixelwise ? 1 : cw},
XtNheightInc, (XtArgVal) (frame_resize_pixelwise ? 1 : ch), XtNheightInc, (XtArgVal) {frame_resize_pixelwise ? 1 : ch},
XtNminWidth, (XtArgVal) base_width, XtNminWidth, (XtArgVal) {base_width},
XtNminHeight, (XtArgVal) base_height, XtNminHeight, (XtArgVal) {base_height},
NULL); NULL);
/* Return if size hints really changed. If they did not, then Xt /* Return if size hints really changed. If they did not, then Xt

View file

@ -2848,7 +2848,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
text_glyph: text_glyph:
gr = 0; gy = 0; gr = 0; gy = 0;
for (; r <= end_row && r->enabled_p; ++r) for (; r <= end_row && r->enabled_p; ++r)
if (r->y + (int) r->height > y) if (r->y + r->height > y)
{ {
gr = r; gy = r->y; gr = r; gy = r->y;
break; break;
@ -2948,7 +2948,7 @@ remember_mouse_glyph (struct frame *f, int gx, int gy, NativeRectangle *rect)
row_glyph: row_glyph:
gr = 0, gy = 0; gr = 0, gy = 0;
for (; r <= end_row && r->enabled_p; ++r) for (; r <= end_row && r->enabled_p; ++r)
if (r->y + (int) r->height > y) if (r->y + r->height > y)
{ {
gr = r; gy = r->y; gr = r; gy = r->y;
break; break;
@ -13509,7 +13509,7 @@ truncate_echo_area (ptrdiff_t nchars)
initialized yet, just toss it. */ initialized yet, just toss it. */
if (sf->glyphs_initialized_p) if (sf->glyphs_initialized_p)
with_echo_area_buffer (0, 0, truncate_message_1, with_echo_area_buffer (0, 0, truncate_message_1,
(void *) (intptr_t) nchars, Qnil); (void *) (intptr_t) {nchars}, Qnil);
} }
} }
@ -29092,7 +29092,7 @@ pint2str (register char *buf, register int width, register ptrdiff_t d)
} }
} }
for (width -= (int) (p - buf); width > 0; --width) for (width -= p - buf; width > 0; --width)
*p++ = ' '; *p++ = ' ';
*p-- = '\0'; *p-- = '\0';
while (p > buf) while (p > buf)

View file

@ -1559,7 +1559,7 @@ x_set_border_pixel (struct frame *f, unsigned long pix)
{ {
block_input (); block_input ();
XtVaSetValues (f->output_data.x->widget, XtNborderColor, XtVaSetValues (f->output_data.x->widget, XtNborderColor,
(Pixel) pix, NULL); (Pixel) {pix}, NULL);
unblock_input (); unblock_input ();
if (FRAME_VISIBLE_P (f)) if (FRAME_VISIBLE_P (f))
@ -2736,11 +2736,6 @@ static int xic_preedit_start_callback (XIC, XPointer, XPointer);
static void xic_string_conversion_callback (XIC, XPointer, static void xic_string_conversion_callback (XIC, XPointer,
XIMStringConversionCallbackStruct *); XIMStringConversionCallbackStruct *);
#ifndef HAVE_XICCALLBACK_CALLBACK
#define XICCallback XIMCallback
#define XICProc XIMProc
#endif
static XIMCallback Xxic_preedit_draw_callback = static XIMCallback Xxic_preedit_draw_callback =
{ {
NULL, NULL,
@ -2759,11 +2754,19 @@ static XIMCallback Xxic_preedit_done_callback =
(XIMProc) xic_preedit_done_callback, (XIMProc) xic_preedit_done_callback,
}; };
#ifdef HAVE_XICCALLBACK_CALLBACK
static XICCallback Xxic_preedit_start_callback = static XICCallback Xxic_preedit_start_callback =
{ {
NULL, NULL,
(XICProc) xic_preedit_start_callback, xic_preedit_start_callback,
}; };
#else
static XIMCallback Xxic_preedit_start_callback =
{
NULL,
(XIMProc) xic_preedit_start_callback,
};
#endif
static XIMCallback Xxic_string_conversion_callback = static XIMCallback Xxic_string_conversion_callback =
{ {

View file

@ -565,7 +565,7 @@ xfont_match (struct frame *f, Lisp_Object spec)
{ {
if (XGetFontProperty (xfont, XA_FONT, &value)) if (XGetFontProperty (xfont, XA_FONT, &value))
{ {
char *s = XGetAtomName (display, (Atom) value); char *s = XGetAtomName (display, (Atom) {value});
/* If DXPC (a Differential X Protocol Compressor) /* If DXPC (a Differential X Protocol Compressor)
Ver.3.7 is running, XGetAtomName will return null Ver.3.7 is running, XGetAtomName will return null
@ -733,7 +733,7 @@ xfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
char *p0, *p; char *p0, *p;
int dashes = 0; int dashes = 0;
p0 = p = XGetAtomName (FRAME_X_DISPLAY (f), (Atom) value); p0 = p = XGetAtomName (FRAME_X_DISPLAY (f), (Atom) {value});
/* Count the number of dashes in the "full name". /* Count the number of dashes in the "full name".
If it is too few, this isn't really the font's full name, If it is too few, this isn't really the font's full name,
so don't use it. so don't use it.

View file

@ -1131,7 +1131,7 @@ set_frame_menubar (struct frame *f, bool deep_p)
menu item is really supposed to be empty. */ menu item is really supposed to be empty. */
/* The intptr_t cast avoids a warning. /* The intptr_t cast avoids a warning.
This value just has to be different from small integers. */ This value just has to be different from small integers. */
wv->call_data = (void *) (intptr_t) (-1); wv->call_data = (void *) (intptr_t) {-1};
if (prev_wv) if (prev_wv)
prev_wv->next = wv; prev_wv->next = wv;

View file

@ -1182,15 +1182,9 @@ static bool x_handle_net_wm_state (struct frame *, const XPropertyEvent *);
static void x_check_fullscreen (struct frame *); static void x_check_fullscreen (struct frame *);
static void x_check_expected_move (struct frame *, int, int); static void x_check_expected_move (struct frame *, int, int);
static void x_sync_with_move (struct frame *, int, int, bool); static void x_sync_with_move (struct frame *, int, int, bool);
#ifndef HAVE_XINPUT2
static int handle_one_xevent (struct x_display_info *,
const XEvent *, int *,
struct input_event *);
#else
static int handle_one_xevent (struct x_display_info *, static int handle_one_xevent (struct x_display_info *,
XEvent *, int *, XEvent *, int *,
struct input_event *); struct input_event *);
#endif
#if ! (defined USE_X_TOOLKIT || defined USE_MOTIF) && defined USE_GTK #if ! (defined USE_X_TOOLKIT || defined USE_MOTIF) && defined USE_GTK
static int x_dispatch_event (XEvent *, Display *); static int x_dispatch_event (XEvent *, Display *);
#endif #endif
@ -6187,7 +6181,9 @@ x_try_cr_xlib_drawable (struct frame *f, GC gc)
cairo_destroy (buf); cairo_destroy (buf);
cairo_set_user_data (cr, &saved_drawable_key, cairo_set_user_data (cr, &saved_drawable_key,
(void *) (uintptr_t) FRAME_X_RAW_DRAWABLE (f), NULL); ((void *)
WINDOW_HANDLE_UINTPTR (FRAME_X_RAW_DRAWABLE (f))),
NULL);
FRAME_X_RAW_DRAWABLE (f) = pixmap; FRAME_X_RAW_DRAWABLE (f) = pixmap;
cairo_surface_flush (xlib_surface); cairo_surface_flush (xlib_surface);
@ -9010,7 +9006,7 @@ cvt_string_to_pixel (Display *dpy, XrmValue *args, Cardinal *nargs,
screen = *(Screen **) args[0].addr; screen = *(Screen **) args[0].addr;
cmap = *(Colormap *) args[1].addr; cmap = *(Colormap *) args[1].addr;
color_name = (String) from->addr; color_name = from->addr;
if (strcmp (color_name, XtDefaultBackground) == 0) if (strcmp (color_name, XtDefaultBackground) == 0)
{ {
@ -18868,11 +18864,7 @@ x_find_selection_owner (struct x_display_info *dpyinfo, Atom selection)
static int static int
handle_one_xevent (struct x_display_info *dpyinfo, handle_one_xevent (struct x_display_info *dpyinfo,
#ifndef HAVE_XINPUT2
const XEvent *event,
#else
XEvent *event, XEvent *event,
#endif
int *finish, struct input_event *hold_quit) int *finish, struct input_event *hold_quit)
{ {
union buffered_input_event inev; union buffered_input_event inev;
@ -19363,7 +19355,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (f) if (f)
{ {
_XEditResCheckMessages (f->output_data.x->widget, _XEditResCheckMessages (f->output_data.x->widget,
NULL, (XEvent *) event, NULL); NULL, event, NULL);
goto done; goto done;
} }
@ -19437,7 +19429,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
== dpyinfo->Xatom_net_wm_frame_drawn) == dpyinfo->Xatom_net_wm_frame_drawn)
{ {
if (any) if (any)
x_sync_handle_frame_drawn (dpyinfo, (XEvent *) event, any); x_sync_handle_frame_drawn (dpyinfo, event, any);
goto done; goto done;
} }
@ -19460,8 +19452,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
dx = 0; dx = 0;
dy = 0; dy = 0;
rc = x_coords_from_dnd_message (dpyinfo, (XEvent *) event, rc = x_coords_from_dnd_message (dpyinfo, event, &dx, &dy);
&dx, &dy);
if (x_handle_dnd_message (f, &event->xclient, dpyinfo, &inev.ie, if (x_handle_dnd_message (f, &event->xclient, dpyinfo, &inev.ie,
rc, dx, dy)) rc, dx, dy))
@ -19938,12 +19929,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
expose_frame (f, event->xexpose.x, event->xexpose.y, expose_frame (f, event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height); event->xexpose.width, event->xexpose.height);
#ifndef USE_TOOLKIT_SCROLL_BARS #ifndef USE_TOOLKIT_SCROLL_BARS
x_scroll_bar_handle_exposure (f, (XEvent *) event); x_scroll_bar_handle_exposure (f, event);
#endif #endif
} }
#ifndef USE_TOOLKIT_SCROLL_BARS #ifndef USE_TOOLKIT_SCROLL_BARS
else else
x_scroll_bar_handle_exposure (f, (XEvent *) event); x_scroll_bar_handle_exposure (f, event);
#endif #endif
#ifdef HAVE_XDBE #ifdef HAVE_XDBE
@ -19980,7 +19971,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
event->xgraphicsexpose.width, event->xgraphicsexpose.width,
event->xgraphicsexpose.height); event->xgraphicsexpose.height);
#ifndef USE_TOOLKIT_SCROLL_BARS #ifndef USE_TOOLKIT_SCROLL_BARS
x_scroll_bar_handle_exposure (f, (XEvent *) event); x_scroll_bar_handle_exposure (f, event);
#endif #endif
#ifdef USE_GTK #ifdef USE_GTK
x_clear_under_internal_border (f); x_clear_under_internal_border (f);
@ -22215,7 +22206,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
x_find_modifier_meanings (dpyinfo); x_find_modifier_meanings (dpyinfo);
FALLTHROUGH; FALLTHROUGH;
case MappingKeyboard: case MappingKeyboard:
XRefreshKeyboardMapping ((XMappingEvent *) &event->xmapping); XRefreshKeyboardMapping (&event->xmapping);
} }
goto OTHER; goto OTHER;
@ -24251,7 +24242,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
{ {
Status status_return; Status status_return;
nbytes = XmbLookupString (FRAME_XIC (f), nbytes = XmbLookupString (FRAME_XIC (f),
&xkey, (char *) copy_bufptr, &xkey, copy_bufptr,
copy_bufsiz, &keysym, copy_bufsiz, &keysym,
&status_return); &status_return);
coding = FRAME_X_XIM_CODING (f); coding = FRAME_X_XIM_CODING (f);
@ -24261,7 +24252,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
copy_bufsiz = nbytes + 1; copy_bufsiz = nbytes + 1;
copy_bufptr = SAFE_ALLOCA (copy_bufsiz); copy_bufptr = SAFE_ALLOCA (copy_bufsiz);
nbytes = XmbLookupString (FRAME_XIC (f), nbytes = XmbLookupString (FRAME_XIC (f),
&xkey, (char *) copy_bufptr, &xkey, copy_bufptr,
copy_bufsiz, &keysym, copy_bufsiz, &keysym,
&status_return); &status_return);
} }
@ -25494,7 +25485,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
if (event->type == (dpyinfo->xrandr_event_base if (event->type == (dpyinfo->xrandr_event_base
+ RRScreenChangeNotify)) + RRScreenChangeNotify))
XRRUpdateConfiguration ((XEvent *) event); XRRUpdateConfiguration (event);
if (event->type == (dpyinfo->xrandr_event_base if (event->type == (dpyinfo->xrandr_event_base
+ RRScreenChangeNotify)) + RRScreenChangeNotify))
@ -25566,9 +25557,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
&& event->xconfigure.height != 0)) && event->xconfigure.height != 0))
{ {
#if defined USE_X_TOOLKIT && defined HAVE_XINPUT2 #if defined USE_X_TOOLKIT && defined HAVE_XINPUT2
XtDispatchEvent (use_copy ? &copy : (XEvent *) event); XtDispatchEvent (use_copy ? &copy : event);
#else #else
XtDispatchEvent ((XEvent *) event); XtDispatchEvent (event);
#endif #endif
} }
} }

View file

@ -794,7 +794,7 @@ emacs_module_init (struct emacs_runtime *ert)
{ {
fprintf (stderr, "Runtime size of runtime structure (%"pT" bytes) " fprintf (stderr, "Runtime size of runtime structure (%"pT" bytes) "
"smaller than compile-time size (%"pZ" bytes)", "smaller than compile-time size (%"pZ" bytes)",
(T_TYPE) ert->size, (Z_TYPE) sizeof (*ert)); (T_TYPE) {ert->size}, (Z_TYPE) {sizeof (*ert)});
return 1; return 1;
} }
@ -804,7 +804,7 @@ emacs_module_init (struct emacs_runtime *ert)
{ {
fprintf (stderr, "Runtime size of environment structure (%"pT" bytes) " fprintf (stderr, "Runtime size of environment structure (%"pT" bytes) "
"smaller than compile-time size (%"pZ" bytes)", "smaller than compile-time size (%"pZ" bytes)",
(T_TYPE) env->size, (Z_TYPE) sizeof (*env)); (T_TYPE) {env->size}, (Z_TYPE) {sizeof (*env)});
return 2; return 2;
} }