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

xorg-server: Changes to 'upstream-experimental'



 Xi/devbell.c                               |    3 
 Xi/exevents.c                              |   42 +++++-----
 Xi/extinit.c                               |   36 ++++-----
 Xi/xigrabdev.c                             |   15 +++
 configure.ac                               |   14 ++-
 dix/devices.c                              |    7 +
 dix/eventconvert.c                         |   23 ++---
 dix/getevents.c                            |   15 ++-
 dix/touch.c                                |    4 -
 glx/glxdri.c                               |    2 
 glx/glxdri2.c                              |    2 
 hw/kdrive/ephyr/ephyr.c                    |    6 -
 hw/kdrive/ephyr/hostx.c                    |    6 +
 hw/kdrive/ephyr/hostx.h                    |    3 
 hw/xfree86/common/xf86.h                   |    1 
 hw/xfree86/common/xf86Events.c             |   17 ++++
 hw/xfree86/common/xf86Init.c               |    2 
 hw/xfree86/common/xf86Xinput.c             |    2 
 hw/xfree86/common/xf86platformBus.c        |   19 ++++
 hw/xfree86/common/xf86platformBus.h        |    4 +
 hw/xfree86/modes/xf86Crtc.c                |    5 -
 hw/xfree86/os-support/linux/lnx_platform.c |   48 ++++++++++--
 hw/xfree86/os-support/solaris/sun_init.c   |    2 
 hw/xfree86/os-support/xf86_OSproc.h        |    3 
 include/dixstruct.h                        |    2 
 include/eventstr.h                         |    1 
 include/hotplug.h                          |    1 
 os/io.c                                    |    1 
 os/log.c                                   |  115 ++++++++++++++++++++++++++---
 test/signal-logging.c                      |   95 +++++++++++++++++++++--
 xkb/xkbInit.c                              |    3 
 31 files changed, 393 insertions(+), 106 deletions(-)

New commits:
commit 2767d9a17d62aede7cabac589c3388078bdb6022
Author: Matt Dew <marcoz@osource.org>
Date:   Tue Jun 25 09:49:08 2013 -0600

    Bump rev from  1.14.1.902  to 1.14.2

diff --git a/configure.ac b/configure.ac
index b977b54..99e3cd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.14.1.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2013-06-13"
-RELEASE_NAME="Act rc2-Normal"
+AC_INIT([xorg-server], 1.14.2, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2013-06-25"
+RELEASE_NAME="Act Abnormal"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 

commit 7dec1d38799d82923e3241f73c83aa1ad357f72b
Author: Matt Dew <marcoz@osource.org>
Date:   Fri Jun 21 10:24:16 2013 -0600

    Revert "dix: pre-scale x by the screen:device:resolution ratio"
    
    This reverts commit 14d89b9a466b521b985bc95fc4994637367362a8.

diff --git a/dix/getevents.c b/dix/getevents.c
index 51d4fd4..dfe4652 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -770,29 +770,6 @@ add_to_scroll_valuator(DeviceIntPtr dev, ValuatorMask *mask, int valuator, doubl
 }
 
 
-static void
-scale_for_device_resolution(DeviceIntPtr dev, ValuatorMask *mask)
-{
-    double x;
-    ValuatorClassPtr v = dev->valuator;
-    int xrange = v->axes[0].max_value - v->axes[0].min_value + 1;
-    int yrange = v->axes[1].max_value - v->axes[1].min_value + 1;
-
-    double screen_ratio = 1.0 * screenInfo.width/screenInfo.height;
-    double device_ratio = 1.0 * xrange/yrange;
-    double resolution_ratio = 1.0;
-    double ratio;
-
-    if (!valuator_mask_fetch_double(mask, 0, &x))
-        return;
-
-    if (v->axes[0].resolution != 0 && v->axes[1].resolution != 0)
-        resolution_ratio = 1.0 * v->axes[0].resolution/v->axes[1].resolution;
-
-    ratio = device_ratio/resolution_ratio/screen_ratio;
-    valuator_mask_set_double(mask, 0, x * ratio);
-}
-
 /**
  * Move the device's pointer by the values given in @valuators.
  *
@@ -804,14 +781,27 @@ moveRelative(DeviceIntPtr dev, int flags, ValuatorMask *mask)
 {
     int i;
     Bool clip_xy = IsMaster(dev) || !IsFloating(dev);
-    ValuatorClassPtr v = dev->valuator;
 
     /* for abs devices in relative mode, we've just scaled wrong, since we
        mapped the device's shape into the screen shape. Undo this. */
-    if ((flags & POINTER_ABSOLUTE) == 0 && v && v->numAxes > 1 &&
-        v->axes[0].min_value < v->axes[0].max_value &&
-        v->axes[1].min_value < v->axes[1].max_value) {
-        scale_for_device_resolution(dev, mask);
+    if ((flags & POINTER_ABSOLUTE) == 0 && dev->valuator &&
+        dev->valuator->axes[0].min_value < dev->valuator->axes[0].max_value) {
+
+        double ratio = 1.0 * screenInfo.width/screenInfo.height;
+
+        if (ratio > 1.0) {
+            double y;
+            if (valuator_mask_fetch_double(mask, 1, &y)) {
+                y *= ratio;
+                valuator_mask_set_double(mask, 1, y);
+            }
+        } else {
+            double x;
+            if (valuator_mask_fetch_double(mask, 0, &x)) {
+                x *= ratio;
+                valuator_mask_set_double(mask, 0, x);
+            }
+        }
     }
 
     /* calc other axes, clip, drop back into valuators */

commit 187cb5a037a03ab1e7702da5eebb2e7d884c6186
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Wed Apr 24 15:24:31 2013 -0700

    Only call xf86platformVTProbe() when it's defined
    
    Fixes build on non-udev systems, since XSERVER_PLATFORM_BUS is only
    defined in configure.ac if $CONFIG_UDEV_KMS is true.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Reviewed-by: Dave Airlie <airlied@redhat.com>

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 7a35250..2a05a0e 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -562,8 +562,10 @@ xf86VTSwitch(void)
         for (ih = InputHandlers; ih; ih = ih->next)
             xf86EnableInputHandler(ih);
 
+#ifdef XSERVER_PLATFORM_BUS
         /* check for any new output devices */
         xf86platformVTProbe();
+#endif
 
         OsReleaseSIGIO();
     }

commit 34259752340e287333fb03f3060c6db13d72f868
Author: Matt Dew <marcoz@osource.org>
Date:   Thu Jun 13 16:25:26 2013 -0600

    Bump rev from 1.14.1.901 to 1.14.1.902

diff --git a/configure.ac b/configure.ac
index b31559d..b977b54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.14.1.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2013-05-30"
-RELEASE_NAME="Act rc1-Normal"
+AC_INIT([xorg-server], 1.14.1.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2013-06-13"
+RELEASE_NAME="Act rc2-Normal"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 

commit 31e066546fd085725cc29e95867a04c70ce46ebc
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Apr 26 15:10:08 2013 +1000

    dix: fix device scaling to use a [min,max[ range.
    
    defmin/defmax are screen coords and thus use a min-inclusive, max-exclusive
    range. device axes ranges are inclusive, so bump the max up by one to get the
    scaling right.
    
    This fixes off-by-one coordinate errors if the coordinate matrix is used to
    bind the device to a fraction of the screen. It introduces an off-by-one
    scaling error in the device coordinate range, but since most devices have a
    higher resolution than the screen (e.g. a Wacom I4 has 5080 dpi) the effect
    of this should be limited.
    
    This error manifests when we have numScreens > 1, as the scaling from
    desktop size back to screen size drops one device unit.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 756ab88d93542f0589c9bf46f40ccc57df64f0fd)

diff --git a/dix/devices.c b/dix/devices.c
index b2db4aa..a0d545a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -112,8 +112,8 @@ DeviceSetTransform(DeviceIntPtr dev, float *transform_data)
      *  Transform is the user supplied (affine) transform
      *  InvScale scales coordinates back up into their native range
      */
-    sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value;
-    sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value;
+    sx = dev->valuator->axes[0].max_value - dev->valuator->axes[0].min_value + 1;
+    sy = dev->valuator->axes[1].max_value - dev->valuator->axes[1].min_value + 1;
 
     /* invscale */
     pixman_f_transform_init_scale(&scale, sx, sy);
diff --git a/dix/getevents.c b/dix/getevents.c
index ac0ccb2..51d4fd4 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -298,11 +298,11 @@ rescaleValuatorAxis(double coord, AxisInfoPtr from, AxisInfoPtr to,
 
     if (from && from->min_value < from->max_value) {
         fmin = from->min_value;
-        fmax = from->max_value;
+        fmax = from->max_value + 1;
     }
     if (to && to->min_value < to->max_value) {
         tmin = to->min_value;
-        tmax = to->max_value;
+        tmax = to->max_value + 1;
     }
 
     if (fmin == tmin && fmax == tmax)
@@ -924,9 +924,9 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
 
     /* scale x&y to desktop coordinates */
     *screenx = rescaleValuatorAxis(x, dev->valuator->axes + 0, NULL,
-                                   screenInfo.x, screenInfo.width - 1);
+                                   screenInfo.x, screenInfo.width);
     *screeny = rescaleValuatorAxis(y, dev->valuator->axes + 1, NULL,
-                                   screenInfo.y, screenInfo.height - 1);
+                                   screenInfo.y, screenInfo.height);
 
     *devx = x;
     *devy = y;
@@ -1366,6 +1366,12 @@ QueuePointerEvents(DeviceIntPtr device, int type,
  * is the last coordinate on the first screen and must be rescaled for the
  * event to be m. XI2 clients that do their own coordinate mapping would
  * otherwise interpret the position of the device elsewere to the cursor.
+ * However, this scaling leads to losses:
+ * if we have two ScreenRecs we scale from e.g. [0..44704]  (Wacom I4) to
+ * [0..2048[. that gives us 2047.954 as desktop coord, or the per-screen
+ * coordinate 1023.954. Scaling that back into the device coordinate range
+ * gives us 44703. So off by one device unit. It's a bug, but we'll have to
+ * live with it because with all this scaling, we just cannot win.
  *
  * @return the number of events written into events.
  */

commit 14d89b9a466b521b985bc95fc4994637367362a8
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Sat Mar 9 20:43:51 2013 +1000

    dix: pre-scale x by the screen:device:resolution ratio
    
    commit 61a99aff9d33728a0b67920254d2d4d79f80cf39
        dix: pre-scale relative events from abs devices to desktop ratio (#31636)
    
    added pre-scaling of relative coordinates coming from absolute devices to
    undo uneven scaling based on the screen dimensions.
    
    Devices have their own device width/height ratio as well (in a specific
    resolution) and this must be applied for relative devices as well to avoid
    scaling of the relative events into the device's ratio.
    
    e.g. a Wacom Intuos4 6x9 is in 16:10 format with equal horiz/vert
    resolution (dpi). A movement by 1000/1000 coordinates is a perfect diagonal
    on the tablet and must be reflected as such on the screen.
    
    However, we map the relative device-coordinate events to absolute screen
    coordinates based on the axis ranges. This results in an effective scaling
    of 1000/(1000 * 1.6) and thus an uneven x/y axis movement - the y
    axis is always faster.
    
    So we need to pre-scale not only by the desktop dimenstions but also by the
    device width/height ratio _and_ the resolution ratio.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 5cc2c96f824dbb28b9f8da61efc41596f8bd0561)

diff --git a/dix/getevents.c b/dix/getevents.c
index 241c7ec..ac0ccb2 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -770,6 +770,29 @@ add_to_scroll_valuator(DeviceIntPtr dev, ValuatorMask *mask, int valuator, doubl
 }
 
 
+static void
+scale_for_device_resolution(DeviceIntPtr dev, ValuatorMask *mask)
+{
+    double x;
+    ValuatorClassPtr v = dev->valuator;
+    int xrange = v->axes[0].max_value - v->axes[0].min_value + 1;
+    int yrange = v->axes[1].max_value - v->axes[1].min_value + 1;
+
+    double screen_ratio = 1.0 * screenInfo.width/screenInfo.height;
+    double device_ratio = 1.0 * xrange/yrange;
+    double resolution_ratio = 1.0;
+    double ratio;
+
+    if (!valuator_mask_fetch_double(mask, 0, &x))
+        return;
+
+    if (v->axes[0].resolution != 0 && v->axes[1].resolution != 0)
+        resolution_ratio = 1.0 * v->axes[0].resolution/v->axes[1].resolution;
+
+    ratio = device_ratio/resolution_ratio/screen_ratio;
+    valuator_mask_set_double(mask, 0, x * ratio);
+}
+
 /**
  * Move the device's pointer by the values given in @valuators.
  *
@@ -781,27 +804,14 @@ moveRelative(DeviceIntPtr dev, int flags, ValuatorMask *mask)
 {
     int i;
     Bool clip_xy = IsMaster(dev) || !IsFloating(dev);
+    ValuatorClassPtr v = dev->valuator;
 
     /* for abs devices in relative mode, we've just scaled wrong, since we
        mapped the device's shape into the screen shape. Undo this. */
-    if ((flags & POINTER_ABSOLUTE) == 0 && dev->valuator &&
-        dev->valuator->axes[0].min_value < dev->valuator->axes[0].max_value) {
-
-        double ratio = 1.0 * screenInfo.width/screenInfo.height;
-
-        if (ratio > 1.0) {
-            double y;
-            if (valuator_mask_fetch_double(mask, 1, &y)) {
-                y *= ratio;
-                valuator_mask_set_double(mask, 1, y);
-            }
-        } else {
-            double x;
-            if (valuator_mask_fetch_double(mask, 0, &x)) {
-                x *= ratio;
-                valuator_mask_set_double(mask, 0, x);
-            }
-        }
+    if ((flags & POINTER_ABSOLUTE) == 0 && v && v->numAxes > 1 &&
+        v->axes[0].min_value < v->axes[0].max_value &&
+        v->axes[1].min_value < v->axes[1].max_value) {
+        scale_for_device_resolution(dev, mask);
     }
 
     /* calc other axes, clip, drop back into valuators */

commit 57f6dbb3032b934a39c15cd1980b345f477ce1e6
Author: Robert Morell <rmorell@nvidia.com>
Date:   Thu May 9 13:09:02 2013 -0700

    os: Reset input buffer's 'ignoreBytes' field
    
    If a client sends a request larger than maxBigRequestSize, the server is
    supposed to ignore it.
    
    Before commit cf88363d, the server would simply disconnect the client.  After
    that commit, it attempts to gracefully ignore the request by remembering how
    long the client specified the request to be, and ignoring that many bytes.
    However, if a client sends a BigReq header with a large size and disconnects
    before actually sending the rest of the specified request, the server will
    reuse the ConnectionInput buffer without resetting the ignoreBytes field.  This
    makes the server ignore new X clients' requests.
    
    This fixes that behavior by resetting the ignoreBytes field when putting the
    ConnectionInput buffer back on the FreeInputs list.
    
    Signed-off-by: Robert Morell <rmorell@nvidia.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 67c66606c760c263d7a4c2d1bba43ed6225a4e7c)

diff --git a/os/io.c b/os/io.c
index 2f091c4..0d980ab 100644
--- a/os/io.c
+++ b/os/io.c
@@ -1063,6 +1063,7 @@ FreeOsBuffers(OsCommPtr oc)
             oci->bufptr = oci->buffer;
             oci->bufcnt = 0;
             oci->lenLastReq = 0;
+            oci->ignoreBytes = 0;
         }
     }
     if ((oco = oc->output)) {

commit 8cc686735296f1ff32089e64f78dfee46b8e7149
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu May 9 14:30:49 2013 +1000

    dix: don't overwrite proximity/focus classes
    
    InitPointerClassDeviceStruct/InitKeyboardDeviceStruct allocate a
    proximity/focus class, respectively. If a driver calls
    InitFocusClassDeviceStruct or InitProximityClassDeviceStruct beforehand,
    the previously allocated class is overwritten, leaking the memory.
    
    Neither takes a parameter other than the device, so we can simply skip
    initialising it if we already have one.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Dave Airlie <airlied@redhat.com>
    (cherry picked from commit 8a88b0ab52ba375ae84463a90503db88af10e368)

diff --git a/dix/devices.c b/dix/devices.c
index 85961a0..b2db4aa 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1366,7 +1366,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
     valc->numMotionEvents = numMotionEvents;
     valc->motionHintWindow = NullWindow;
 
-    if (mode & OutOfProximity)
+    if ((mode & OutOfProximity) && !dev->proximity)
         InitProximityClassDeviceStruct(dev);
 
     dev->valuator = valc;
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 4e8e267..ed01114 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -574,7 +574,8 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet * rmlvo,
     XkbUpdateActions(dev, xkb->min_key_code, XkbNumKeys(xkb), &changes,
                      &check, &cause);
 
-    InitFocusClassDeviceStruct(dev);
+    if (!dev->focus)
+        InitFocusClassDeviceStruct(dev);
 
     xkbi->kbdProc = ctrl_func;
     dev->kbdfeed->BellProc = bell_func;

commit bf115aa906795df872104083c1187c126c3b1d76
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Apr 17 19:47:42 2013 +1000

    dix: plug memory leak in freeing TouchClass
    
    ==15562== 1,800 bytes in 1 blocks are definitely lost in loss record 298 of 330
    ==15562==    at 0x4A06B6F: calloc (vg_replace_malloc.c:593)
    ==15562==    by 0x4312C7: InitTouchClassDeviceStruct (devices.c:1644)
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    (cherry picked from commit 7d722796c678532e8c5897c673c43184da353f44)

diff --git a/dix/devices.c b/dix/devices.c
index be236dd..85961a0 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -795,6 +795,7 @@ FreeDeviceClass(int type, pointer *class)
             free((*t)->touches[i].valuators);
         }
 
+        free((*t)->touches);
         free((*t));
         break;
     }

commit 6abc41689cfd274f5aa8bdfbfcd4e3dd7d0249fa
Author: Matt Dew <marcoz@osource.org>
Date:   Fri May 31 00:06:34 2013 -0600

    bah,  fixed release version: changed from rc1 to 1.901

diff --git a/configure.ac b/configure.ac
index 626aec4..b31559d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.14.2-rc1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.14.1.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 RELEASE_DATE="2013-05-30"
 RELEASE_NAME="Act rc1-Normal"
 AC_CONFIG_SRCDIR([Makefile.am])

commit 27c30396bf7ff16192fe5e17c6fe04ee58ee398b
Author: Matt Dew <marcoz@osource.org>
Date:   Thu May 30 22:34:17 2013 -0600

    bump release info to 1.14.2-rc1 (from 1.14.1)

diff --git a/configure.ac b/configure.ac
index bc53f16..626aec4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.14.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2013-04-17"
-RELEASE_NAME="Act Normal"
+AC_INIT([xorg-server], 1.14.2-rc1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2013-05-30"
+RELEASE_NAME="Act rc1-Normal"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 

commit bcc8eba00b57a63255e05bf80bad0cb95a5a5c3e
Author: Andreas Müller <schnitzeltony@googlemail.com>
Date:   Tue Apr 16 14:30:43 2013 +0200

    dixstruct.h: fix segfaults - char is unsigned for ARM and PowerPC architectures
    
    see ARM related bug reports [1-3]
    
    [1] https://github.com/archlinuxarm/PKGBUILDs/issues/446I
    [2] http://www.raspberrypi.org/phpBB3/viewtopic.php?t=38568&p=321673
    [3] http://lists.linuxtogo.org/pipermail/openembedded-core/2013-April/037805.html
    
    Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
    Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/include/dixstruct.h b/include/dixstruct.h
index 6784819..aef822c 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -96,7 +96,7 @@ typedef struct _Client {
     unsigned int clientGone:1;
     unsigned int closeDownMode:2;
     unsigned int clientState:2;
-    char smart_priority;
+    signed char smart_priority;
     short noClientException;      /* this client died or needs to be killed */
     int priority;
     ReplySwapPtr pSwapReplyFunc;

commit e90beb18000cf49b9108c4f977abfd111ed908ad
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Apr 30 15:44:37 2013 +1000

    os: Use ErrorFSigSafe from FatalError and it's friends
    
    Backtrace logging etc. is already sigsafe, but the actual FatalError message
    in response is not yet, leading to amusing logs like this:
    
        (EE) Segmentation fault at address 0x0
        (EE) BUG: triggered 'if (inSignalContext)'
        (EE) BUG: log.c:499 in LogVMessageVerb()
        (EE) Warning: attempting to log data in a signal unsafe manner while in
        signal context.
        Please update to check inSignalContext and/or use LogMessageVerbSigSafe() or
        ErrorFSigSafe().
        The offending log format message is:
    
        Fatal server error:
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 042c6d861f7bb7038ddcdd6b59766fd9094d0e52)

diff --git a/glx/glxdri.c b/glx/glxdri.c
index da46468..5891a68 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -885,7 +885,7 @@ glxDRILeaveVT(ScrnInfoPtr scrn)
     __GLXDRIscreen *screen = (__GLXDRIscreen *)
         glxGetScreen(xf86ScrnToScreen(scrn));
 
-    LogMessage(X_INFO, "AIGLX: Suspending AIGLX clients for VT switch\n");
+    LogMessageVerbSigSafe(X_INFO, -1, "AIGLX: Suspending AIGLX clients for VT switch\n");
 
     glxSuspendClients();
 
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index b26e501..16e7e3d 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -835,7 +835,7 @@ glxDRILeaveVT(ScrnInfoPtr scrn)
     __GLXDRIscreen *screen = (__GLXDRIscreen *)
         glxGetScreen(xf86ScrnToScreen(scrn));
 
-    LogMessage(X_INFO, "AIGLX: Suspending AIGLX clients for VT switch\n");
+    LogMessageVerbSigSafe(X_INFO, -1, "AIGLX: Suspending AIGLX clients for VT switch\n");
 
     glxSuspendClients();
 
diff --git a/os/log.c b/os/log.c
index 3dc675f..f19faf5 100644
--- a/os/log.c
+++ b/os/log.c
@@ -250,7 +250,7 @@ void
 LogClose(enum ExitCode error)
 {
     if (logFile) {
-        ErrorF("Server terminated %s (%d). Closing log file.\n",
+        ErrorFSigSafe("Server terminated %s (%d). Closing log file.\n",
                (error == EXIT_NO_ERROR) ? "successfully" : "with error", error);
         fclose(logFile);
         logFile = NULL;
@@ -878,9 +878,9 @@ FatalError(const char *f, ...)
     static Bool beenhere = FALSE;
 
     if (beenhere)
-        ErrorF("\nFatalError re-entered, aborting\n");
+        ErrorFSigSafe("\nFatalError re-entered, aborting\n");
     else
-        ErrorF("\nFatal server error:\n");
+        ErrorFSigSafe("\nFatal server error:\n");
 
     va_start(args, f);
 
@@ -897,9 +897,9 @@ FatalError(const char *f, ...)
         va_end(apple_args);
     }
 #endif
-    VErrorF(f, args);
+    VErrorFSigSafe(f, args);
     va_end(args);
-    ErrorF("\n");
+    ErrorFSigSafe("\n");
     if (!beenhere)
         OsVendorFatalError(f, args2);
     va_end(args2);

commit d0725a0b8672465cc4d3b85fb705ddb64d020476
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 14 16:24:53 2013 +1000

    os: complain about unsupported pnprintf directives
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit d9848fb4b182ca21bacf28ed7410d1a502cb000e)

diff --git a/os/log.c b/os/log.c
index 9f95743..3dc675f 100644
--- a/os/log.c
+++ b/os/log.c
@@ -461,6 +461,7 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
             string[s_idx++] = '%';
             break;
         default:
+            BUG_WARN_MSG(f[f_idx], "Unsupported printf directive '%c'\n", f[f_idx]);
             va_arg(args, char*);
             string[s_idx++] = '%';
             if (s_idx < size - 1)
diff --git a/test/signal-logging.c b/test/signal-logging.c
index b45d8d4..f6bc85c 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -206,6 +206,13 @@ static void logging_format(void)
     read_log_msg(logmsg);
     assert(strcmp(logmsg, "(EE) test a\n") == 0);
 
+    /* something unsupported % */
+    LogMessageVerbSigSafe(X_ERROR, -1, "test %Q\n");
+    read_log_msg(logmsg);
+    assert(strstr(logmsg, "BUG") != NULL);
+    LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+    fseek(f, 0, SEEK_END);
+
     /* string substitution */
     LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
     read_log_msg(logmsg);

commit 7eb73779a0c82386710c4b670a342c0340485d19
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 14 16:19:34 2013 +1000

    os: support %c in pnprintf
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit d903d17d7f006fa333265b8476063b189c20d082)

diff --git a/os/log.c b/os/log.c
index e4e9e8b..9f95743 100644
--- a/os/log.c
+++ b/os/log.c
@@ -450,6 +450,13 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
                     string[s_idx++] = number[i];
             }
             break;
+        case 'c':
+            {
+                char c = va_arg(args, int);
+                if (s_idx < size - 1)
+                    string[s_idx++] = c;
+            }
+            break;
         case '%':
             string[s_idx++] = '%';
             break;
diff --git a/test/signal-logging.c b/test/signal-logging.c
index 65baa45..b45d8d4 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -201,6 +201,11 @@ static void logging_format(void)
     read_log_msg(logmsg);
     assert(strcmp(logmsg, "(EE) test %\n") == 0);
 
+    /* character */
+    LogMessageVerbSigSafe(X_ERROR, -1, "test %c\n", 'a');
+    read_log_msg(logmsg);
+    assert(strcmp(logmsg, "(EE) test a\n") == 0);
+
     /* string substitution */
     LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
     read_log_msg(logmsg);

commit 6da756fb1d67d6de99077826a3d2434b0e3a1555
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 14 16:13:22 2013 +1000

    os: support %% in pnprintf
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 58ef34ee6d0f68aa28f6f1a26e56f49ec85ed9bf)

diff --git a/os/log.c b/os/log.c
index df025fb..e4e9e8b 100644
--- a/os/log.c
+++ b/os/log.c
@@ -450,6 +450,9 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
                     string[s_idx++] = number[i];
             }
             break;
+        case '%':
+            string[s_idx++] = '%';
+            break;
         default:
             va_arg(args, char*);
             string[s_idx++] = '%';
diff --git a/test/signal-logging.c b/test/signal-logging.c
index 9038cf8..65baa45 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -196,6 +196,11 @@ static void logging_format(void)
     read_log_msg(logmsg);
     assert(strcmp(logmsg, "(EE) %s %d %u %% %p %i\n") == 0);
 
+    /* literal % */
+    LogMessageVerbSigSafe(X_ERROR, -1, "test %%\n");
+    read_log_msg(logmsg);
+    assert(strcmp(logmsg, "(EE) test %\n") == 0);
+
     /* string substitution */
     LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
     read_log_msg(logmsg);

commit b606767f20c566e24704502eae682eacb41f450e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 14 15:34:32 2013 +1000

    os: support pnprintf length modifiers for integers
    
    Mainly for %ld, smaller than int is propagated anyway, and %lld isn't really
    used.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 5ea21560dd071ea4ab87430000d087fd5fe1f092)

diff --git a/os/log.c b/os/log.c
index dc6e288..df025fb 100644
--- a/os/log.c
+++ b/os/log.c
@@ -279,6 +279,55 @@ LogSetParameter(LogParameter param, int value)
     }
 }
 
+enum {
+    LMOD_LONG     = 0x1,
+    LMOD_LONGLONG = 0x2,
+    LMOD_SHORT    = 0x4,
+    LMOD_SIZET    = 0x8,
+};
+
+/**
+ * Parse non-digit length modifiers and set the corresponding flag in
+ * flags_return.
+ *
+ * @return the number of bytes parsed
+ */
+static int parse_length_modifier(const char *format, size_t len, int *flags_return)
+{
+    int idx = 0;
+    int length_modifier = 0;
+
+    while (idx < len) {
+        switch (format[idx]) {
+            case 'l':
+                BUG_RETURN_VAL(length_modifier & LMOD_SHORT, 0);
+
+                if (length_modifier & LMOD_LONG)
+                    length_modifier |= LMOD_LONGLONG;
+                else
+                    length_modifier |= LMOD_LONG;
+                break;
+            case 'h':
+                BUG_RETURN_VAL(length_modifier & (LMOD_LONG|LMOD_LONGLONG), 0);
+                length_modifier |= LMOD_SHORT;
+                /* gcc says 'short int' is promoted to 'int' when
+                 * passed through '...', so ignored during
+                 * processing */
+                break;
+            case 'z':
+                length_modifier |= LMOD_SIZET;
+                break;
+            default:
+                goto out;
+        }
+        idx++;
+    }
+
+out:
+    *flags_return = length_modifier;
+    return idx;
+}
+
 /**
  * Signal-safe snprintf, with some limitations over snprintf. Be careful
  * which directives you use.
@@ -297,6 +346,7 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
     int64_t si;
 
     for (; f_idx < f_len && s_idx < size - 1; f_idx++) {
+        int length_modifier = 0;
         if (f[f_idx] != '%') {
             string[s_idx++] = f[f_idx];
             continue;
@@ -304,10 +354,18 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
 
         f_idx++;
 
-        /* silently swallow length modifiers */
+        /* silently swallow digit length modifiers */
         while (f_idx < f_len && ((f[f_idx] >= '0' && f[f_idx] <= '9') || f[f_idx] == '.'))
             f_idx++;
 
+        /* non-digit length modifiers */
+        if (f_idx < f_len) {
+            int parsed_bytes = parse_length_modifier(&f[f_idx], f_len - f_idx, &length_modifier);
+            if (parsed_bytes < 0)
+                return 0;
+            f_idx += parsed_bytes;
+        }
+
         if (f_idx >= f_len)
             break;
 
@@ -321,7 +379,15 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
             break;
 
         case 'u':
-            ui = va_arg(args, unsigned);
+            if (length_modifier & LMOD_LONGLONG)
+                ui = va_arg(args, unsigned long long);
+            else if (length_modifier & LMOD_LONG)
+                ui = va_arg(args, unsigned long);
+            else if (length_modifier & LMOD_SIZET)
+                ui = va_arg(args, size_t);
+            else
+                ui = va_arg(args, unsigned);
+
             FormatUInt64(ui, number);
             p_len = strlen_sigsafe(number);
 
@@ -330,7 +396,15 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
             break;
         case 'i':
         case 'd':
-            si = va_arg(args, int);
+            if (length_modifier & LMOD_LONGLONG)
+                si = va_arg(args, long long);
+            else if (length_modifier & LMOD_LONG)
+                si = va_arg(args, long);
+            else if (length_modifier & LMOD_SIZET)
+                si = va_arg(args, ssize_t);
+            else
+                si = va_arg(args, int);
+
             FormatInt64(si, number);
             p_len = strlen_sigsafe(number);
 
@@ -351,7 +425,15 @@ pnprintf(char *string, size_t size, const char *f, va_list args)
             break;
 
         case 'x':
-            ui = va_arg(args, unsigned);
+            if (length_modifier & LMOD_LONGLONG)
+                ui = va_arg(args, unsigned long long);
+            else if (length_modifier & LMOD_LONG)
+                ui = va_arg(args, unsigned long);
+            else if (length_modifier & LMOD_SIZET)
+                ui = va_arg(args, size_t);
+            else
+                ui = va_arg(args, unsigned);
+
             FormatUInt64Hex(ui, number);
             p_len = strlen_sigsafe(number);
 
diff --git a/test/signal-logging.c b/test/signal-logging.c
index e0eb810..9038cf8 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -158,6 +158,8 @@ static void logging_format(void)
     char buf[1024];
     int i;
     unsigned int ui;
+    long li;
+    unsigned long lui;
     FILE *f;
     char read_buf[2048];
     char *logmsg;
@@ -207,6 +209,14 @@ static void logging_format(void)
     LogMessageVerbSigSafe(X_ERROR, -1, "\n");
     fseek(f, 0, SEEK_END);
 
+#warning Ignore compiler warning below "unknown conversion type character".  This is intentional.
+    /* %hld is bogus */
+    LogMessageVerbSigSafe(X_ERROR, -1, "%hld\n", 4);
+    read_log_msg(logmsg);
+    assert(strstr(logmsg, "BUG") != NULL);
+    LogMessageVerbSigSafe(X_ERROR, -1, "\n");
+    fseek(f, 0, SEEK_END);
+
     /* number substitution */
     ui = 0;
     do {
@@ -215,12 +225,47 @@ static void logging_format(void)
         LogMessageVerbSigSafe(X_ERROR, -1, "%u\n", ui);
         read_log_msg(logmsg);
         assert(strcmp(logmsg, expected) == 0);
+
+        sprintf(expected, "(EE) %x\n", ui);
+        LogMessageVerbSigSafe(X_ERROR, -1, "%x\n", ui);
+        read_log_msg(logmsg);
+        assert(strcmp(logmsg, expected) == 0);
+
         if (ui == 0)
             ui = 1;
         else
             ui <<= 1;
     } while(ui);
 
+    lui = 0;
+    do {
+        char expected[30];
+        sprintf(expected, "(EE) %lu\n", lui);
+        LogMessageVerbSigSafe(X_ERROR, -1, "%lu\n", lui);
+        read_log_msg(logmsg);
+
+        sprintf(expected, "(EE) %lld\n", (unsigned long long)ui);
+        LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (unsigned long long)ui);
+        read_log_msg(logmsg);
+        assert(strcmp(logmsg, expected) == 0);
+
+        sprintf(expected, "(EE) %lx\n", lui);
+        printf("%s\n", expected);
+        LogMessageVerbSigSafe(X_ERROR, -1, "%lx\n", lui);
+        read_log_msg(logmsg);
+        assert(strcmp(logmsg, expected) == 0);
+
+        sprintf(expected, "(EE) %llx\n", (unsigned long long)ui);
+        LogMessageVerbSigSafe(X_ERROR, -1, "%llx\n", (unsigned long long)ui);
+        read_log_msg(logmsg);
+        assert(strcmp(logmsg, expected) == 0);
+
+        if (lui == 0)
+            lui = 1;
+        else
+            lui <<= 1;
+    } while(lui);
+
     /* signed number substitution */
     i = 0;
     do {
@@ -230,7 +275,6 @@ static void logging_format(void)
         read_log_msg(logmsg);
         assert(strcmp(logmsg, expected) == 0);
 
-
         sprintf(expected, "(EE) %d\n", i | INT_MIN);


Reply to: