xserver: Branch 'server-1.14-branch' - 10 commits

Matt Dew marcoz at kemper.freedesktop.org
Thu May 23 21:13:59 PDT 2013


 configure.ac            |    8 +++
 dix/eventconvert.c      |    4 -
 dix/getevents.c         |    1 
 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 -
 include/eventstr.h      |    1 
 os/log.c                |  115 ++++++++++++++++++++++++++++++++++++++++++++----
 test/signal-logging.c   |   95 +++++++++++++++++++++++++++++++++++----
 11 files changed, 214 insertions(+), 29 deletions(-)

New commits:
commit a01839e8d3675abfef871a42415779961f1ee51c
Merge: 348de79 e90beb1
Author: Matt Dew <marcoz at osource.org>
Date:   Thu May 23 22:08:23 2013 -0600

    Merge branch 'server-1.14-branch' of git://people.freedesktop.org/~whot/xserver into server-1.14-branch

commit e90beb18000cf49b9108c4f977abfd111ed908ad
Author: Peter Hutterer <peter.hutterer at 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 at who-t.net>
    Reviewed-by: Keith Packard <keithp at 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 at 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 at who-t.net>
    Reviewed-by: Keith Packard <keithp at 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 at who-t.net>
Date:   Thu Feb 14 16:19:34 2013 +1000

    os: support %c in pnprintf
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at 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 at who-t.net>
Date:   Thu Feb 14 16:13:22 2013 +1000

    os: support %% in pnprintf
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at 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 at 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 at who-t.net>
    Reviewed-by: Keith Packard <keithp at 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);
         LogMessageVerbSigSafe(X_ERROR, -1, "%d\n", i | INT_MIN);
         read_log_msg(logmsg);
@@ -242,19 +286,35 @@ static void logging_format(void)
             i <<= 1;
     } while(i > INT_MIN);
 
-    /* hex number substitution */
-    ui = 0;
+    li = 0;
     do {
         char expected[30];
-        sprintf(expected, "(EE) %x\n", ui);
-        LogMessageVerbSigSafe(X_ERROR, -1, "%x\n", ui);
+        sprintf(expected, "(EE) %ld\n", li);
+        LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li);
         read_log_msg(logmsg);
         assert(strcmp(logmsg, expected) == 0);
-        if (ui == 0)
-            ui = 1;
+
+        sprintf(expected, "(EE) %ld\n", li | LONG_MIN);
+        LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li | LONG_MIN);
+        read_log_msg(logmsg);
+        assert(strcmp(logmsg, expected) == 0);
+
+        sprintf(expected, "(EE) %lld\n", (long long)li);
+        LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (long long)li);
+        read_log_msg(logmsg);
+        assert(strcmp(logmsg, expected) == 0);
+
+        sprintf(expected, "(EE) %lld\n", (long long)(li | LONG_MIN));
+        LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (long long)(li | LONG_MIN));
+        read_log_msg(logmsg);
+        assert(strcmp(logmsg, expected) == 0);
+
+        if (li == 0)
+            li = 1;
         else
-            ui <<= 1;
-    } while(ui);
+            li <<= 1;
+    } while(li > LONG_MIN);
+
 
     /* pointer substitution */
     /* we print a null-pointer differently to printf */
commit 00b8d11dafdbd1214695e0b54c6c2184ece6aa4d
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Feb 18 14:57:58 2013 +1000

    os: document pnprintf as sigsafe snprintf
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 44fc062f85df7288c17d2d64b73aa4957b91fd6d)

diff --git a/os/log.c b/os/log.c
index 95bd8cc..dc6e288 100644
--- a/os/log.c
+++ b/os/log.c
@@ -279,6 +279,10 @@ LogSetParameter(LogParameter param, int value)
     }
 }
 
+/**
+ * Signal-safe snprintf, with some limitations over snprintf. Be careful
+ * which directives you use.
+ */
 static int
 pnprintf(char *string, size_t size, const char *f, va_list args)
 {
commit 8318d6a89cb3ffad5c90670027ef997fd19994a1
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Feb 1 09:06:20 2013 +1000

    If neither HAL nor udev backends are enabled, warn the user
    
    If both are missing,  input device hotplugging will not work out of the box.
    While we still have a DBus-API or the user may want to set AAD off all the
    time, the most likely source of this is misconfiguration (i.e. lack of the
    udev/hal devel packages).
    
    Message printed last to make it more obvious to the user.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 623981ddaeb8836f3b0939e527c0e943f9c4e974)

diff --git a/configure.ac b/configure.ac
index 4289863..bc53f16 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2216,6 +2216,14 @@ AC_SUBST([prefix])
 
 AC_CONFIG_COMMANDS([sdksyms], [touch hw/xfree86/sdksyms.dep])
 
+if test "x$CONFIG_HAL" = xno && test "x$CONFIG_UDEV" = xno; then
+    AC_WARN([
+             ***********************************************
+             Neither HAL nor udev backend will be enabled.
+             Input device hotplugging will not be available!
+             ***********************************************])
+fi
+
 AC_OUTPUT([
 Makefile
 glx/Makefile
commit 1c215f5a9c7f8a75ad56f3b34b0b7de2ee9aa6ff
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Mar 14 11:07:57 2013 +1000

    dix: send the current axis value in DeviceChangedEvents (#62321)
    
    X.Org Bug 62321 <http://bugs.freedesktop.org/show_bug.cgi?id=62321>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 23d1bc69f305edd5a6e2cfec3dfc84befda0881c)

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index ebc52c3..f7ecdba 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -501,9 +501,7 @@ appendValuatorInfo(DeviceChangedEvent *dce, xXIValuatorInfo * info,
     info->min.frac = 0;
     info->max.integral = dce->valuators[axisnumber].max;
     info->max.frac = 0;
-    /* FIXME: value */
-    info->value.integral = 0;
-    info->value.frac = 0;
+    info->value = double_to_fp3232(dce->valuators[axisnumber].value);
     info->resolution = dce->valuators[axisnumber].resolution;
     info->number = axisnumber;
     info->mode = dce->valuators[axisnumber].mode;
diff --git a/dix/getevents.c b/dix/getevents.c
index a4f192c..241c7ec 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -277,6 +277,7 @@ CreateClassesChangedEvent(InternalEvent *event,
             dce->valuators[i].mode = slave->valuator->axes[i].mode;
             dce->valuators[i].name = slave->valuator->axes[i].label;
             dce->valuators[i].scroll = slave->valuator->axes[i].scroll;
+            dce->valuators[i].value = slave->valuator->axisVal[i];
         }
     }
     if (slave->key) {
diff --git a/include/eventstr.h b/include/eventstr.h
index 38fab4f..5c1adc4 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -175,6 +175,7 @@ struct _DeviceChangedEvent {
     struct {
         uint32_t min;           /**< Minimum value */
         uint32_t max;           /**< Maximum value */
+        double value;           /**< Current value */;
         /* FIXME: frac parts of min/max */
         uint32_t resolution;    /**< Resolution counts/m */
         uint8_t mode;           /**< Relative or Absolute */
commit 70236f770c7004016efe89dc5638ccbb9ef15bee
Author: Daniel Martin <consume.noise at gmail.com>
Date:   Thu Dec 20 13:50:17 2012 +0100

    ephyr: Fix crash on 24bpp host framebuffer
    
    Use bytes_per_line and bits_per_pixel from the created XImage to fix
        https://bugzilla.redhat.com/show_bug.cgi?id=518960
    
    Signed-off-by: Daniel Martin <consume.noise at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit bd58ebe4cf3b0ce60f87fb26a3715f774dabd349)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index e6520d0..c9672c0 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -237,13 +237,11 @@ ephyrMapFramebuffer(KdScreenInfo * screen)
     KdComputePointerMatrix(&m, ephyrRandr, screen->width, screen->height);
     KdSetPointerMatrix(&m);
 
-    priv->bytes_per_line =
-        ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
-
     buffer_height = ephyrBufferHeight(screen);
 
     priv->base =
-        hostx_screen_init(screen, screen->width, screen->height, buffer_height);
+        hostx_screen_init(screen, screen->width, screen->height, buffer_height,
+                          &priv->bytes_per_line, &screen->fb.bitsPerPixel);
 
     if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All)) {
         scrpriv->shadow = FALSE;
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 157ac36..6bbccd3 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -617,7 +617,8 @@ hostx_set_cmap_entry(unsigned char idx,
  */
 void *
 hostx_screen_init(EphyrScreenInfo screen,
-                  int width, int height, int buffer_height)
+                  int width, int height, int buffer_height,
+                  int *bytes_per_line, int *bits_per_pixel)
 {
     int bitmap_pad;
     Bool shm_success = False;
@@ -694,6 +695,9 @@ hostx_screen_init(EphyrScreenInfo screen,
             malloc(host_screen->ximg->bytes_per_line * buffer_height);
     }
 
+    *bytes_per_line = host_screen->ximg->bytes_per_line;
+    *bits_per_pixel = host_screen->ximg->bits_per_pixel;
+
     XResizeWindow(HostX.dpy, host_screen->win, width, height);
 
     /* Ask the WM to keep our size static */
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index 31c4053..38b7b37 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -193,7 +193,8 @@ hostx_set_cmap_entry(unsigned char idx,
                      unsigned char r, unsigned char g, unsigned char b);
 
 void *hostx_screen_init(EphyrScreenInfo screen,
-                        int width, int height, int buffer_height);
+                        int width, int height, int buffer_height,
+                        int *bytes_per_line, int *bits_per_pixel);
 
 void
 


More information about the xorg-commit mailing list