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>
* xterm.c (handle_one_xevent): Avoid type-punned derefencing of X
events.
* ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use
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)
......
......@@ -162,7 +162,7 @@ extern Lisp_Object Qc, Qm, Qp, Qd;
static Lisp_Object
get_adstyle_property (FcPattern *p)
{
char *str, *end;
unsigned char *str, *end;
Lisp_Object adstyle;
if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch)
......@@ -193,7 +193,7 @@ ftfont_pattern_entity (p, extra)
Lisp_Object extra;
{
Lisp_Object key, cache, entity;
char *file, *str;
unsigned char *file, *str;
int index;
int numeric;
double dbl;
......
......@@ -1594,7 +1594,8 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp)
int i;
Arg av[2];
int ac = 0;
XButtonPressedEvent dummy;
XEvent dummy;
XButtonPressedEvent *event = &(dummy.xbutton);
LWLIB_ID menu_id;
Widget menu;
......@@ -1608,36 +1609,35 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp)
popup_deactivate_callback,
menu_highlight_callback);
dummy.type = ButtonPress;
dummy.serial = 0;
dummy.send_event = 0;
dummy.display = FRAME_X_DISPLAY (f);
dummy.time = CurrentTime;
dummy.root = FRAME_X_DISPLAY_INFO (f)->root_window;
dummy.window = dummy.root;
dummy.subwindow = dummy.root;
dummy.x = x;
dummy.y = y;
event->type = ButtonPress;
event->serial = 0;
event->send_event = 0;
event->display = FRAME_X_DISPLAY (f);
event->time = CurrentTime;
event->root = FRAME_X_DISPLAY_INFO (f)->root_window;
event->window = event->subwindow = event->root;
event->x = x;
event->y = y;
/* Adjust coordinates to be root-window-relative. */
x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
dummy.x_root = x;
dummy.y_root = y;
event->x_root = x;
event->y_root = y;
dummy.state = 0;
dummy.button = 0;
event->state = 0;
event->button = 0;
for (i = 0; i < 5; 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. */
XtSetArg (av[ac], XtNgeometry, 0); ac++;
XtSetValues (menu, av, ac);
/* Display the menu. */
lw_popup_menu (menu, (XEvent *) &dummy);
lw_popup_menu (menu, &dummy);
popup_activated_flag = 1;
x_activate_timeout_atimer ();
......
......@@ -564,22 +564,23 @@ static void
x_decline_selection_request (event)
struct input_event *event;
{
XSelectionEvent reply;
XEvent reply_base;
XSelectionEvent *reply = &(reply_base.xselection);
reply.type = SelectionNotify;
reply.display = SELECTION_EVENT_DISPLAY (event);
reply.requestor = SELECTION_EVENT_REQUESTOR (event);
reply.selection = SELECTION_EVENT_SELECTION (event);
reply.time = SELECTION_EVENT_TIME (event);
reply.target = SELECTION_EVENT_TARGET (event);
reply.property = None;
reply->type = SelectionNotify;
reply->display = SELECTION_EVENT_DISPLAY (event);
reply->requestor = SELECTION_EVENT_REQUESTOR (event);
reply->selection = SELECTION_EVENT_SELECTION (event);
reply->time = SELECTION_EVENT_TIME (event);
reply->target = SELECTION_EVENT_TARGET (event);
reply->property = None;
/* The reason for the error may be that the receiver has
died in the meantime. Handle that case. */
BLOCK_INPUT;
x_catch_errors (reply.display);
XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply);
XFlush (reply.display);
x_catch_errors (reply->display);
XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base);
XFlush (reply->display);
x_uncatch_errors ();
UNBLOCK_INPUT;
}
......@@ -690,7 +691,8 @@ x_reply_selection_request (event, format, data, size, type)
unsigned char *data;
Atom type;
{
XSelectionEvent reply;
XEvent reply_base;
XSelectionEvent *reply = &(reply_base.xselection);
Display *display = SELECTION_EVENT_DISPLAY (event);
Window window = SELECTION_EVENT_REQUESTOR (event);
int bytes_remaining;
......@@ -702,15 +704,15 @@ x_reply_selection_request (event, format, data, size, type)
if (max_bytes > MAX_SELECTION_QUANTUM)
max_bytes = MAX_SELECTION_QUANTUM;
reply.type = SelectionNotify;
reply.display = display;
reply.requestor = window;
reply.selection = SELECTION_EVENT_SELECTION (event);
reply.time = SELECTION_EVENT_TIME (event);
reply.target = SELECTION_EVENT_TARGET (event);
reply.property = SELECTION_EVENT_PROPERTY (event);
if (reply.property == None)
reply.property = reply.target;
reply->type = SelectionNotify;
reply->display = display;
reply->requestor = window;
reply->selection = SELECTION_EVENT_SELECTION (event);
reply->time = SELECTION_EVENT_TIME (event);
reply->target = SELECTION_EVENT_TARGET (event);
reply->property = SELECTION_EVENT_PROPERTY (event);
if (reply->property == None)
reply->property = reply->target;
BLOCK_INPUT;
/* The protected block contains wait_for_property_change, which can
......@@ -721,8 +723,8 @@ x_reply_selection_request (event, format, data, size, type)
#ifdef TRACE_SELECTION
{
char *sel = XGetAtomName (display, reply.selection);
char *tgt = XGetAtomName (display, reply.target);
char *sel = XGetAtomName (display, reply->selection);
char *tgt = XGetAtomName (display, reply->target);
TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt);
if (sel) XFree (sel);
if (tgt) XFree (tgt);
......@@ -737,10 +739,10 @@ x_reply_selection_request (event, format, data, size, type)
{
/* Send all the data at once, with minimal handshaking. */
TRACE1 ("Sending all %d bytes", bytes_remaining);
XChangeProperty (display, window, reply.property, type, format,
XChangeProperty (display, window, reply->property, type, format,
PropModeReplace, data, size);
/* 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
{
......@@ -766,19 +768,19 @@ x_reply_selection_request (event, format, data, size, type)
error ("Attempt to transfer an INCR to ourself!");
TRACE2 ("Start sending %d bytes incrementally (%s)",
bytes_remaining, XGetAtomName (display, reply.property));
wait_object = expect_property_change (display, window, reply.property,
bytes_remaining, XGetAtomName (display, reply->property));
wait_object = expect_property_change (display, window, reply->property,
PropertyDelete);
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
32 bits. */
long value[1];
value[0] = bytes_remaining;
XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR,
XChangeProperty (display, window, reply->property, dpyinfo->Xatom_INCR,
32, PropModeReplace,
(unsigned char *) value, 1);
}
......@@ -787,7 +789,7 @@ x_reply_selection_request (event, format, data, size, type)
/* Tell 'em the INCR data is there... */
TRACE0 ("Send SelectionNotify event");
XSendEvent (display, window, False, 0L, (XEvent *) &reply);
XSendEvent (display, window, False, 0L, &reply_base);
XFlush (display);
had_errors = x_had_errors_p (display);
......@@ -798,7 +800,7 @@ x_reply_selection_request (event, format, data, size, type)
if (! had_errors)
{
TRACE1 ("Waiting for ACK (deletion of %s)",
XGetAtomName (display, reply.property));
XGetAtomName (display, reply->property));
wait_for_property_change (wait_object);
}
else
......@@ -814,15 +816,15 @@ x_reply_selection_request (event, format, data, size, type)
BLOCK_INPUT;
wait_object
= expect_property_change (display, window, reply.property,
= expect_property_change (display, window, reply->property,
PropertyDelete);
TRACE1 ("Sending increment of %d elements", i);
TRACE1 ("Set %s to increment data",
XGetAtomName (display, reply.property));
XGetAtomName (display, reply->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);
bytes_remaining -= i * format_bytes;
if (format == 32)
......@@ -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
property. This can run random lisp code or signal. */
TRACE1 ("Waiting for increment ACK (deletion of %s)",
XGetAtomName (display, reply.property));
XGetAtomName (display, reply->property));
wait_for_property_change (wait_object);
}
......@@ -850,8 +852,8 @@ x_reply_selection_request (event, format, data, size, type)
XSelectInput (display, window, 0L);
TRACE1 ("Set %s to a 0-length chunk to indicate EOF",
XGetAtomName (display, reply.property));
XChangeProperty (display, window, reply.property, type, format,
XGetAtomName (display, reply->property));
XChangeProperty (display, window, reply->property, type, format,
PropModeReplace, data, 0);
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