Commit 65969f63 authored by Chong Yidong's avatar Chong Yidong

Fix more GCC strict-aliasing warnings.

* src/ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use
unsigned char, to match FcChar8 type definition.

* src/xmenu.c (create_and_show_popup_menu):
* src/xselect.c (x_decline_selection_request)
(x_reply_selection_request): Avoid type-punned deref of X events.
parent 5324d904
2011-04-08 Chong Yidong <cyd@stupidchicken.com> 2011-04-08 Chong Yidong <cyd@stupidchicken.com>
* xterm.c (handle_one_xevent): Avoid type-punned derefencing of X * ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use
events. unsigned char, to match FcChar8 type definition.
* xterm.c (handle_one_xevent):
* xmenu.c (create_and_show_popup_menu):
* xselect.c (x_decline_selection_request)
(x_reply_selection_request): Avoid type-punned deref of X events.
2011-04-08 Svante Signell <svante.signell@telia.com> (tiny change) 2011-04-08 Svante Signell <svante.signell@telia.com> (tiny change)
......
...@@ -162,7 +162,7 @@ extern Lisp_Object Qc, Qm, Qp, Qd; ...@@ -162,7 +162,7 @@ extern Lisp_Object Qc, Qm, Qp, Qd;
static Lisp_Object static Lisp_Object
get_adstyle_property (FcPattern *p) get_adstyle_property (FcPattern *p)
{ {
char *str, *end; unsigned char *str, *end;
Lisp_Object adstyle; Lisp_Object adstyle;
if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch) if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch)
...@@ -193,7 +193,7 @@ ftfont_pattern_entity (p, extra) ...@@ -193,7 +193,7 @@ ftfont_pattern_entity (p, extra)
Lisp_Object extra; Lisp_Object extra;
{ {
Lisp_Object key, cache, entity; Lisp_Object key, cache, entity;
char *file, *str; unsigned char *file, *str;
int index; int index;
int numeric; int numeric;
double dbl; double dbl;
......
...@@ -1594,7 +1594,8 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) ...@@ -1594,7 +1594,8 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp)
int i; int i;
Arg av[2]; Arg av[2];
int ac = 0; int ac = 0;
XButtonPressedEvent dummy; XEvent dummy;
XButtonPressedEvent *event = &(dummy.xbutton);
LWLIB_ID menu_id; LWLIB_ID menu_id;
Widget menu; Widget menu;
...@@ -1608,36 +1609,35 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) ...@@ -1608,36 +1609,35 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp)
popup_deactivate_callback, popup_deactivate_callback,
menu_highlight_callback); menu_highlight_callback);
dummy.type = ButtonPress; event->type = ButtonPress;
dummy.serial = 0; event->serial = 0;
dummy.send_event = 0; event->send_event = 0;
dummy.display = FRAME_X_DISPLAY (f); event->display = FRAME_X_DISPLAY (f);
dummy.time = CurrentTime; event->time = CurrentTime;
dummy.root = FRAME_X_DISPLAY_INFO (f)->root_window; event->root = FRAME_X_DISPLAY_INFO (f)->root_window;
dummy.window = dummy.root; event->window = event->subwindow = event->root;
dummy.subwindow = dummy.root; event->x = x;
dummy.x = x; event->y = y;
dummy.y = y;
/* Adjust coordinates to be root-window-relative. */ /* Adjust coordinates to be root-window-relative. */
x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
dummy.x_root = x; event->x_root = x;
dummy.y_root = y; event->y_root = y;
dummy.state = 0; event->state = 0;
dummy.button = 0; event->button = 0;
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i)) if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
dummy.button = i; event->button = i;
/* Don't allow any geometry request from the user. */ /* Don't allow any geometry request from the user. */
XtSetArg (av[ac], XtNgeometry, 0); ac++; XtSetArg (av[ac], XtNgeometry, 0); ac++;
XtSetValues (menu, av, ac); XtSetValues (menu, av, ac);
/* Display the menu. */ /* Display the menu. */
lw_popup_menu (menu, (XEvent *) &dummy); lw_popup_menu (menu, &dummy);
popup_activated_flag = 1; popup_activated_flag = 1;
x_activate_timeout_atimer (); x_activate_timeout_atimer ();
......
...@@ -564,22 +564,23 @@ static void ...@@ -564,22 +564,23 @@ static void
x_decline_selection_request (event) x_decline_selection_request (event)
struct input_event *event; struct input_event *event;
{ {
XSelectionEvent reply; XEvent reply_base;
XSelectionEvent *reply = &(reply_base.xselection);
reply.type = SelectionNotify; reply->type = SelectionNotify;
reply.display = SELECTION_EVENT_DISPLAY (event); reply->display = SELECTION_EVENT_DISPLAY (event);
reply.requestor = SELECTION_EVENT_REQUESTOR (event); reply->requestor = SELECTION_EVENT_REQUESTOR (event);
reply.selection = SELECTION_EVENT_SELECTION (event); reply->selection = SELECTION_EVENT_SELECTION (event);
reply.time = SELECTION_EVENT_TIME (event); reply->time = SELECTION_EVENT_TIME (event);
reply.target = SELECTION_EVENT_TARGET (event); reply->target = SELECTION_EVENT_TARGET (event);
reply.property = None; reply->property = None;
/* The reason for the error may be that the receiver has /* The reason for the error may be that the receiver has
died in the meantime. Handle that case. */ died in the meantime. Handle that case. */
BLOCK_INPUT; BLOCK_INPUT;
x_catch_errors (reply.display); x_catch_errors (reply->display);
XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply); XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base);
XFlush (reply.display); XFlush (reply->display);
x_uncatch_errors (); x_uncatch_errors ();
UNBLOCK_INPUT; UNBLOCK_INPUT;
} }
...@@ -690,7 +691,8 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -690,7 +691,8 @@ x_reply_selection_request (event, format, data, size, type)
unsigned char *data; unsigned char *data;
Atom type; Atom type;
{ {
XSelectionEvent reply; XEvent reply_base;
XSelectionEvent *reply = &(reply_base.xselection);
Display *display = SELECTION_EVENT_DISPLAY (event); Display *display = SELECTION_EVENT_DISPLAY (event);
Window window = SELECTION_EVENT_REQUESTOR (event); Window window = SELECTION_EVENT_REQUESTOR (event);
int bytes_remaining; int bytes_remaining;
...@@ -702,15 +704,15 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -702,15 +704,15 @@ x_reply_selection_request (event, format, data, size, type)
if (max_bytes > MAX_SELECTION_QUANTUM) if (max_bytes > MAX_SELECTION_QUANTUM)
max_bytes = MAX_SELECTION_QUANTUM; max_bytes = MAX_SELECTION_QUANTUM;
reply.type = SelectionNotify; reply->type = SelectionNotify;
reply.display = display; reply->display = display;
reply.requestor = window; reply->requestor = window;
reply.selection = SELECTION_EVENT_SELECTION (event); reply->selection = SELECTION_EVENT_SELECTION (event);
reply.time = SELECTION_EVENT_TIME (event); reply->time = SELECTION_EVENT_TIME (event);
reply.target = SELECTION_EVENT_TARGET (event); reply->target = SELECTION_EVENT_TARGET (event);
reply.property = SELECTION_EVENT_PROPERTY (event); reply->property = SELECTION_EVENT_PROPERTY (event);
if (reply.property == None) if (reply->property == None)
reply.property = reply.target; reply->property = reply->target;
BLOCK_INPUT; BLOCK_INPUT;
/* The protected block contains wait_for_property_change, which can /* The protected block contains wait_for_property_change, which can
...@@ -721,8 +723,8 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -721,8 +723,8 @@ x_reply_selection_request (event, format, data, size, type)
#ifdef TRACE_SELECTION #ifdef TRACE_SELECTION
{ {
char *sel = XGetAtomName (display, reply.selection); char *sel = XGetAtomName (display, reply->selection);
char *tgt = XGetAtomName (display, reply.target); char *tgt = XGetAtomName (display, reply->target);
TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt); TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt);
if (sel) XFree (sel); if (sel) XFree (sel);
if (tgt) XFree (tgt); if (tgt) XFree (tgt);
...@@ -737,10 +739,10 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -737,10 +739,10 @@ x_reply_selection_request (event, format, data, size, type)
{ {
/* Send all the data at once, with minimal handshaking. */ /* Send all the data at once, with minimal handshaking. */
TRACE1 ("Sending all %d bytes", bytes_remaining); TRACE1 ("Sending all %d bytes", bytes_remaining);
XChangeProperty (display, window, reply.property, type, format, XChangeProperty (display, window, reply->property, type, format,
PropModeReplace, data, size); PropModeReplace, data, size);
/* At this point, the selection was successfully stored; ack it. */ /* At this point, the selection was successfully stored; ack it. */
XSendEvent (display, window, False, 0L, (XEvent *) &reply); XSendEvent (display, window, False, 0L, &reply_base);
} }
else else
{ {
...@@ -766,19 +768,19 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -766,19 +768,19 @@ x_reply_selection_request (event, format, data, size, type)
error ("Attempt to transfer an INCR to ourself!"); error ("Attempt to transfer an INCR to ourself!");
TRACE2 ("Start sending %d bytes incrementally (%s)", TRACE2 ("Start sending %d bytes incrementally (%s)",
bytes_remaining, XGetAtomName (display, reply.property)); bytes_remaining, XGetAtomName (display, reply->property));
wait_object = expect_property_change (display, window, reply.property, wait_object = expect_property_change (display, window, reply->property,
PropertyDelete); PropertyDelete);
TRACE1 ("Set %s to number of bytes to send", TRACE1 ("Set %s to number of bytes to send",
XGetAtomName (display, reply.property)); XGetAtomName (display, reply->property));
{ {
/* XChangeProperty expects an array of long even if long is more than /* XChangeProperty expects an array of long even if long is more than
32 bits. */ 32 bits. */
long value[1]; long value[1];
value[0] = bytes_remaining; value[0] = bytes_remaining;
XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR, XChangeProperty (display, window, reply->property, dpyinfo->Xatom_INCR,
32, PropModeReplace, 32, PropModeReplace,
(unsigned char *) value, 1); (unsigned char *) value, 1);
} }
...@@ -787,7 +789,7 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -787,7 +789,7 @@ x_reply_selection_request (event, format, data, size, type)
/* Tell 'em the INCR data is there... */ /* Tell 'em the INCR data is there... */
TRACE0 ("Send SelectionNotify event"); TRACE0 ("Send SelectionNotify event");
XSendEvent (display, window, False, 0L, (XEvent *) &reply); XSendEvent (display, window, False, 0L, &reply_base);
XFlush (display); XFlush (display);
had_errors = x_had_errors_p (display); had_errors = x_had_errors_p (display);
...@@ -798,7 +800,7 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -798,7 +800,7 @@ x_reply_selection_request (event, format, data, size, type)
if (! had_errors) if (! had_errors)
{ {
TRACE1 ("Waiting for ACK (deletion of %s)", TRACE1 ("Waiting for ACK (deletion of %s)",
XGetAtomName (display, reply.property)); XGetAtomName (display, reply->property));
wait_for_property_change (wait_object); wait_for_property_change (wait_object);
} }
else else
...@@ -814,15 +816,15 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -814,15 +816,15 @@ x_reply_selection_request (event, format, data, size, type)
BLOCK_INPUT; BLOCK_INPUT;
wait_object wait_object
= expect_property_change (display, window, reply.property, = expect_property_change (display, window, reply->property,
PropertyDelete); PropertyDelete);
TRACE1 ("Sending increment of %d elements", i); TRACE1 ("Sending increment of %d elements", i);
TRACE1 ("Set %s to increment data", TRACE1 ("Set %s to increment data",
XGetAtomName (display, reply.property)); XGetAtomName (display, reply->property));
/* Append the next chunk of data to the property. */ /* Append the next chunk of data to the property. */
XChangeProperty (display, window, reply.property, type, format, XChangeProperty (display, window, reply->property, type, format,
PropModeAppend, data, i); PropModeAppend, data, i);
bytes_remaining -= i * format_bytes; bytes_remaining -= i * format_bytes;
if (format == 32) if (format == 32)
...@@ -839,7 +841,7 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -839,7 +841,7 @@ x_reply_selection_request (event, format, data, size, type)
/* Now wait for the requester to ack this chunk by deleting the /* Now wait for the requester to ack this chunk by deleting the
property. This can run random lisp code or signal. */ property. This can run random lisp code or signal. */
TRACE1 ("Waiting for increment ACK (deletion of %s)", TRACE1 ("Waiting for increment ACK (deletion of %s)",
XGetAtomName (display, reply.property)); XGetAtomName (display, reply->property));
wait_for_property_change (wait_object); wait_for_property_change (wait_object);
} }
...@@ -850,8 +852,8 @@ x_reply_selection_request (event, format, data, size, type) ...@@ -850,8 +852,8 @@ x_reply_selection_request (event, format, data, size, type)
XSelectInput (display, window, 0L); XSelectInput (display, window, 0L);
TRACE1 ("Set %s to a 0-length chunk to indicate EOF", TRACE1 ("Set %s to a 0-length chunk to indicate EOF",
XGetAtomName (display, reply.property)); XGetAtomName (display, reply->property));
XChangeProperty (display, window, reply.property, type, format, XChangeProperty (display, window, reply->property, type, format,
PropModeReplace, data, 0); PropModeReplace, data, 0);
TRACE0 ("Done sending incrementally"); TRACE0 ("Done sending incrementally");
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment