aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2011-04-08 16:41:28 -0400
committerChong Yidong2011-04-08 16:41:28 -0400
commit65969f63dfe134bdb18177b13b83658627709358 (patch)
tree09ff58670d5d1e4b17738d34a2eefc2375b42baa /src
parent5324d904a3c7e2eaf0e15edab0d6c55fe7c9dcd2 (diff)
downloademacs-65969f63dfe134bdb18177b13b83658627709358.tar.gz
emacs-65969f63dfe134bdb18177b13b83658627709358.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/ftfont.c4
-rw-r--r--src/xmenu.c34
-rw-r--r--src/xselect.c76
4 files changed, 65 insertions, 58 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 82c1597e343..c536da41812 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,12 @@
12011-04-08 Chong Yidong <cyd@stupidchicken.com> 12011-04-08 Chong Yidong <cyd@stupidchicken.com>
2 2
3 * xterm.c (handle_one_xevent): Avoid type-punned derefencing of X 3 * ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use
4 events. 4 unsigned char, to match FcChar8 type definition.
5
6 * xterm.c (handle_one_xevent):
7 * xmenu.c (create_and_show_popup_menu):
8 * xselect.c (x_decline_selection_request)
9 (x_reply_selection_request): Avoid type-punned deref of X events.
5 10
62011-04-08 Svante Signell <svante.signell@telia.com> (tiny change) 112011-04-08 Svante Signell <svante.signell@telia.com> (tiny change)
7 12
diff --git a/src/ftfont.c b/src/ftfont.c
index 6009bd39537..6a7c09407b4 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -162,7 +162,7 @@ extern Lisp_Object Qc, Qm, Qp, Qd;
162static Lisp_Object 162static Lisp_Object
163get_adstyle_property (FcPattern *p) 163get_adstyle_property (FcPattern *p)
164{ 164{
165 char *str, *end; 165 unsigned char *str, *end;
166 Lisp_Object adstyle; 166 Lisp_Object adstyle;
167 167
168 if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch) 168 if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch)
@@ -193,7 +193,7 @@ ftfont_pattern_entity (p, extra)
193 Lisp_Object extra; 193 Lisp_Object extra;
194{ 194{
195 Lisp_Object key, cache, entity; 195 Lisp_Object key, cache, entity;
196 char *file, *str; 196 unsigned char *file, *str;
197 int index; 197 int index;
198 int numeric; 198 int numeric;
199 double dbl; 199 double dbl;
diff --git a/src/xmenu.c b/src/xmenu.c
index 9ce5fbc02a0..c2e70e13bf9 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1594,7 +1594,8 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp)
1594 int i; 1594 int i;
1595 Arg av[2]; 1595 Arg av[2];
1596 int ac = 0; 1596 int ac = 0;
1597 XButtonPressedEvent dummy; 1597 XEvent dummy;
1598 XButtonPressedEvent *event = &(dummy.xbutton);
1598 LWLIB_ID menu_id; 1599 LWLIB_ID menu_id;
1599 Widget menu; 1600 Widget menu;
1600 1601
@@ -1608,36 +1609,35 @@ create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp)
1608 popup_deactivate_callback, 1609 popup_deactivate_callback,
1609 menu_highlight_callback); 1610 menu_highlight_callback);
1610 1611
1611 dummy.type = ButtonPress; 1612 event->type = ButtonPress;
1612 dummy.serial = 0; 1613 event->serial = 0;
1613 dummy.send_event = 0; 1614 event->send_event = 0;
1614 dummy.display = FRAME_X_DISPLAY (f); 1615 event->display = FRAME_X_DISPLAY (f);
1615 dummy.time = CurrentTime; 1616 event->time = CurrentTime;
1616 dummy.root = FRAME_X_DISPLAY_INFO (f)->root_window; 1617 event->root = FRAME_X_DISPLAY_INFO (f)->root_window;
1617 dummy.window = dummy.root; 1618 event->window = event->subwindow = event->root;
1618 dummy.subwindow = dummy.root; 1619 event->x = x;
1619 dummy.x = x; 1620 event->y = y;
1620 dummy.y = y;
1621 1621
1622 /* Adjust coordinates to be root-window-relative. */ 1622 /* Adjust coordinates to be root-window-relative. */
1623 x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); 1623 x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
1624 y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); 1624 y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
1625 1625
1626 dummy.x_root = x; 1626 event->x_root = x;
1627 dummy.y_root = y; 1627 event->y_root = y;
1628 1628
1629 dummy.state = 0; 1629 event->state = 0;
1630 dummy.button = 0; 1630 event->button = 0;
1631 for (i = 0; i < 5; i++) 1631 for (i = 0; i < 5; i++)
1632 if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i)) 1632 if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i))
1633 dummy.button = i; 1633 event->button = i;
1634 1634
1635 /* Don't allow any geometry request from the user. */ 1635 /* Don't allow any geometry request from the user. */
1636 XtSetArg (av[ac], XtNgeometry, 0); ac++; 1636 XtSetArg (av[ac], XtNgeometry, 0); ac++;
1637 XtSetValues (menu, av, ac); 1637 XtSetValues (menu, av, ac);
1638 1638
1639 /* Display the menu. */ 1639 /* Display the menu. */
1640 lw_popup_menu (menu, (XEvent *) &dummy); 1640 lw_popup_menu (menu, &dummy);
1641 popup_activated_flag = 1; 1641 popup_activated_flag = 1;
1642 x_activate_timeout_atimer (); 1642 x_activate_timeout_atimer ();
1643 1643
diff --git a/src/xselect.c b/src/xselect.c
index fb0b2bc50e2..023d2eee8c3 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -564,22 +564,23 @@ static void
564x_decline_selection_request (event) 564x_decline_selection_request (event)
565 struct input_event *event; 565 struct input_event *event;
566{ 566{
567 XSelectionEvent reply; 567 XEvent reply_base;
568 XSelectionEvent *reply = &(reply_base.xselection);
568 569
569 reply.type = SelectionNotify; 570 reply->type = SelectionNotify;
570 reply.display = SELECTION_EVENT_DISPLAY (event); 571 reply->display = SELECTION_EVENT_DISPLAY (event);
571 reply.requestor = SELECTION_EVENT_REQUESTOR (event); 572 reply->requestor = SELECTION_EVENT_REQUESTOR (event);
572 reply.selection = SELECTION_EVENT_SELECTION (event); 573 reply->selection = SELECTION_EVENT_SELECTION (event);
573 reply.time = SELECTION_EVENT_TIME (event); 574 reply->time = SELECTION_EVENT_TIME (event);
574 reply.target = SELECTION_EVENT_TARGET (event); 575 reply->target = SELECTION_EVENT_TARGET (event);
575 reply.property = None; 576 reply->property = None;
576 577
577 /* The reason for the error may be that the receiver has 578 /* The reason for the error may be that the receiver has
578 died in the meantime. Handle that case. */ 579 died in the meantime. Handle that case. */
579 BLOCK_INPUT; 580 BLOCK_INPUT;
580 x_catch_errors (reply.display); 581 x_catch_errors (reply->display);
581 XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply); 582 XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base);
582 XFlush (reply.display); 583 XFlush (reply->display);
583 x_uncatch_errors (); 584 x_uncatch_errors ();
584 UNBLOCK_INPUT; 585 UNBLOCK_INPUT;
585} 586}
@@ -690,7 +691,8 @@ x_reply_selection_request (event, format, data, size, type)
690 unsigned char *data; 691 unsigned char *data;
691 Atom type; 692 Atom type;
692{ 693{
693 XSelectionEvent reply; 694 XEvent reply_base;
695 XSelectionEvent *reply = &(reply_base.xselection);
694 Display *display = SELECTION_EVENT_DISPLAY (event); 696 Display *display = SELECTION_EVENT_DISPLAY (event);
695 Window window = SELECTION_EVENT_REQUESTOR (event); 697 Window window = SELECTION_EVENT_REQUESTOR (event);
696 int bytes_remaining; 698 int bytes_remaining;
@@ -702,15 +704,15 @@ x_reply_selection_request (event, format, data, size, type)
702 if (max_bytes > MAX_SELECTION_QUANTUM) 704 if (max_bytes > MAX_SELECTION_QUANTUM)
703 max_bytes = MAX_SELECTION_QUANTUM; 705 max_bytes = MAX_SELECTION_QUANTUM;
704 706
705 reply.type = SelectionNotify; 707 reply->type = SelectionNotify;
706 reply.display = display; 708 reply->display = display;
707 reply.requestor = window; 709 reply->requestor = window;
708 reply.selection = SELECTION_EVENT_SELECTION (event); 710 reply->selection = SELECTION_EVENT_SELECTION (event);
709 reply.time = SELECTION_EVENT_TIME (event); 711 reply->time = SELECTION_EVENT_TIME (event);
710 reply.target = SELECTION_EVENT_TARGET (event); 712 reply->target = SELECTION_EVENT_TARGET (event);
711 reply.property = SELECTION_EVENT_PROPERTY (event); 713 reply->property = SELECTION_EVENT_PROPERTY (event);
712 if (reply.property == None) 714 if (reply->property == None)
713 reply.property = reply.target; 715 reply->property = reply->target;
714 716
715 BLOCK_INPUT; 717 BLOCK_INPUT;
716 /* The protected block contains wait_for_property_change, which can 718 /* The protected block contains wait_for_property_change, which can
@@ -721,8 +723,8 @@ x_reply_selection_request (event, format, data, size, type)
721 723
722#ifdef TRACE_SELECTION 724#ifdef TRACE_SELECTION
723 { 725 {
724 char *sel = XGetAtomName (display, reply.selection); 726 char *sel = XGetAtomName (display, reply->selection);
725 char *tgt = XGetAtomName (display, reply.target); 727 char *tgt = XGetAtomName (display, reply->target);
726 TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt); 728 TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt);
727 if (sel) XFree (sel); 729 if (sel) XFree (sel);
728 if (tgt) XFree (tgt); 730 if (tgt) XFree (tgt);
@@ -737,10 +739,10 @@ x_reply_selection_request (event, format, data, size, type)
737 { 739 {
738 /* Send all the data at once, with minimal handshaking. */ 740 /* Send all the data at once, with minimal handshaking. */
739 TRACE1 ("Sending all %d bytes", bytes_remaining); 741 TRACE1 ("Sending all %d bytes", bytes_remaining);
740 XChangeProperty (display, window, reply.property, type, format, 742 XChangeProperty (display, window, reply->property, type, format,
741 PropModeReplace, data, size); 743 PropModeReplace, data, size);
742 /* At this point, the selection was successfully stored; ack it. */ 744 /* At this point, the selection was successfully stored; ack it. */
743 XSendEvent (display, window, False, 0L, (XEvent *) &reply); 745 XSendEvent (display, window, False, 0L, &reply_base);
744 } 746 }
745 else 747 else
746 { 748 {
@@ -766,19 +768,19 @@ x_reply_selection_request (event, format, data, size, type)
766 error ("Attempt to transfer an INCR to ourself!"); 768 error ("Attempt to transfer an INCR to ourself!");
767 769
768 TRACE2 ("Start sending %d bytes incrementally (%s)", 770 TRACE2 ("Start sending %d bytes incrementally (%s)",
769 bytes_remaining, XGetAtomName (display, reply.property)); 771 bytes_remaining, XGetAtomName (display, reply->property));
770 wait_object = expect_property_change (display, window, reply.property, 772 wait_object = expect_property_change (display, window, reply->property,
771 PropertyDelete); 773 PropertyDelete);
772 774
773 TRACE1 ("Set %s to number of bytes to send", 775 TRACE1 ("Set %s to number of bytes to send",
774 XGetAtomName (display, reply.property)); 776 XGetAtomName (display, reply->property));
775 { 777 {
776 /* XChangeProperty expects an array of long even if long is more than 778 /* XChangeProperty expects an array of long even if long is more than
777 32 bits. */ 779 32 bits. */
778 long value[1]; 780 long value[1];
779 781
780 value[0] = bytes_remaining; 782 value[0] = bytes_remaining;
781 XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR, 783 XChangeProperty (display, window, reply->property, dpyinfo->Xatom_INCR,
782 32, PropModeReplace, 784 32, PropModeReplace,
783 (unsigned char *) value, 1); 785 (unsigned char *) value, 1);
784 } 786 }
@@ -787,7 +789,7 @@ x_reply_selection_request (event, format, data, size, type)
787 789
788 /* Tell 'em the INCR data is there... */ 790 /* Tell 'em the INCR data is there... */
789 TRACE0 ("Send SelectionNotify event"); 791 TRACE0 ("Send SelectionNotify event");
790 XSendEvent (display, window, False, 0L, (XEvent *) &reply); 792 XSendEvent (display, window, False, 0L, &reply_base);
791 XFlush (display); 793 XFlush (display);
792 794
793 had_errors = x_had_errors_p (display); 795 had_errors = x_had_errors_p (display);
@@ -798,7 +800,7 @@ x_reply_selection_request (event, format, data, size, type)
798 if (! had_errors) 800 if (! had_errors)
799 { 801 {
800 TRACE1 ("Waiting for ACK (deletion of %s)", 802 TRACE1 ("Waiting for ACK (deletion of %s)",
801 XGetAtomName (display, reply.property)); 803 XGetAtomName (display, reply->property));
802 wait_for_property_change (wait_object); 804 wait_for_property_change (wait_object);
803 } 805 }
804 else 806 else
@@ -814,15 +816,15 @@ x_reply_selection_request (event, format, data, size, type)
814 BLOCK_INPUT; 816 BLOCK_INPUT;
815 817
816 wait_object 818 wait_object
817 = expect_property_change (display, window, reply.property, 819 = expect_property_change (display, window, reply->property,
818 PropertyDelete); 820 PropertyDelete);
819 821
820 TRACE1 ("Sending increment of %d elements", i); 822 TRACE1 ("Sending increment of %d elements", i);
821 TRACE1 ("Set %s to increment data", 823 TRACE1 ("Set %s to increment data",
822 XGetAtomName (display, reply.property)); 824 XGetAtomName (display, reply->property));
823 825
824 /* Append the next chunk of data to the property. */ 826 /* Append the next chunk of data to the property. */
825 XChangeProperty (display, window, reply.property, type, format, 827 XChangeProperty (display, window, reply->property, type, format,
826 PropModeAppend, data, i); 828 PropModeAppend, data, i);
827 bytes_remaining -= i * format_bytes; 829 bytes_remaining -= i * format_bytes;
828 if (format == 32) 830 if (format == 32)
@@ -839,7 +841,7 @@ x_reply_selection_request (event, format, data, size, type)
839 /* Now wait for the requester to ack this chunk by deleting the 841 /* Now wait for the requester to ack this chunk by deleting the
840 property. This can run random lisp code or signal. */ 842 property. This can run random lisp code or signal. */
841 TRACE1 ("Waiting for increment ACK (deletion of %s)", 843 TRACE1 ("Waiting for increment ACK (deletion of %s)",
842 XGetAtomName (display, reply.property)); 844 XGetAtomName (display, reply->property));
843 wait_for_property_change (wait_object); 845 wait_for_property_change (wait_object);
844 } 846 }
845 847
@@ -850,8 +852,8 @@ x_reply_selection_request (event, format, data, size, type)
850 XSelectInput (display, window, 0L); 852 XSelectInput (display, window, 0L);
851 853
852 TRACE1 ("Set %s to a 0-length chunk to indicate EOF", 854 TRACE1 ("Set %s to a 0-length chunk to indicate EOF",
853 XGetAtomName (display, reply.property)); 855 XGetAtomName (display, reply->property));
854 XChangeProperty (display, window, reply.property, type, format, 856 XChangeProperty (display, window, reply->property, type, format,
855 PropModeReplace, data, 0); 857 PropModeReplace, data, 0);
856 TRACE0 ("Done sending incrementally"); 858 TRACE0 ("Done sending incrementally");
857 } 859 }