emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100542: Fix more GCC strict-alias


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-23 r100542: Fix more GCC strict-aliasing warnings.
Date: Fri, 08 Apr 2011 16:41:28 -0400
User-agent: Bazaar (2.1.2)

------------------------------------------------------------
revno: 100542
committer: Chong Yidong <address@hidden>
branch nick: emacs-23
timestamp: Fri 2011-04-08 16:41:28 -0400
message:
  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.
modified:
  src/ChangeLog
  src/ftfont.c
  src/xmenu.c
  src/xselect.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-04-08 19:18:25 +0000
+++ b/src/ChangeLog     2011-04-08 20:41:28 +0000
@@ -1,7 +1,12 @@
 2011-04-08  Chong Yidong  <address@hidden>
 
-       * 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  <address@hidden>  (tiny change)
 

=== modified file 'src/ftfont.c'
--- a/src/ftfont.c      2011-02-02 02:15:29 +0000
+++ b/src/ftfont.c      2011-04-08 20:41:28 +0000
@@ -162,7 +162,7 @@
 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 @@
      Lisp_Object extra;
 {
   Lisp_Object key, cache, entity;
-  char *file, *str;
+  unsigned char *file, *str;
   int index;
   int numeric;
   double dbl;

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2011-01-02 23:50:46 +0000
+++ b/src/xmenu.c       2011-04-08 20:41:28 +0000
@@ -1594,7 +1594,8 @@
   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 @@
                            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 ();
 

=== modified file 'src/xselect.c'
--- a/src/xselect.c     2011-01-02 23:50:46 +0000
+++ b/src/xselect.c     2011-04-08 20:41:28 +0000
@@ -564,22 +564,23 @@
 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 @@
      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 @@
   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 @@
 
 #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 @@
     {
       /* 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 @@
        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 @@
 
       /* 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 @@
       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 @@
          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 @@
          /* 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 @@
        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");
     }


reply via email to

[Prev in Thread] Current Thread [Next in Thread]