aboutsummaryrefslogtreecommitdiffstats
path: root/xorg-server-hwcursor-gamma/0001-linux-Do-not-call-FatalError-from-xf86CloseConsole.patch
blob: a33840adcf09d07cf289a2f647ebd18246fa9f66 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From ca355e9d6acab994453cdbb65cb213d09ee4a50f Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 14 Oct 2015 15:10:35 +0200
Subject: [PATCH] linux: Do not call FatalError from xf86CloseConsole

FatalError ends up calling xf86CloseConsole itself, so calling FatalError
from within xf86CloseConsole is not a good idea.

All the other error checking done in xf86CloseConsole uses
xf86Msg(X_WARNING, ...) except for the switch_to() helper function,
change things so that switch_to() also uses xf86Msg rather then FatalError
when called from xf86CloseConsole.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1269210
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 hw/xfree86/os-support/linux/lnx_init.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index ec06a05..9fec964 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -64,17 +64,25 @@ drain_console(int fd, void *closure)
 }
 
 static void
-switch_to(int vt, const char *from)
+switch_to(int vt, Bool is_open)
 {
     int ret;
 
     SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt));
-    if (ret < 0)
-        FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno));
+    if (ret < 0) {
+        if (is_open)
+            FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", strerror(errno));
+        else
+            xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n", strerror(errno));
+    }
 
     SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt));
-    if (ret < 0)
-        FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno));
+    if (ret < 0) {
+        if (is_open)
+            FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n", strerror(errno));
+        else
+            xf86Msg(X_WARNING, "xf86CloseConsole: VT_WAITACTIVE failed: %s\n", strerror(errno));
+    }
 }
 
 #pragma GCC diagnostic push
@@ -233,7 +241,7 @@ xf86OpenConsole(void)
             /*
              * now get the VT.  This _must_ succeed, or else fail completely.
              */
-            switch_to(xf86Info.vtno, "xf86OpenConsole");
+            switch_to(xf86Info.vtno, TRUE);
 
             SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_GETMODE, &VT));
             if (ret < 0)
@@ -294,7 +302,7 @@ xf86OpenConsole(void)
     else {                      /* serverGeneration != 1 */
         if (!xf86Info.ShareVTs && xf86Info.autoVTSwitch) {
             /* now get the VT */
-            switch_to(xf86Info.vtno, "xf86OpenConsole");
+            switch_to(xf86Info.vtno, TRUE);
         }
     }
 }
@@ -346,7 +354,7 @@ xf86CloseConsole(void)
          * Perform a switch back to the active VT when we were started
          */
         if (activeVT >= 0) {
-            switch_to(activeVT, "xf86CloseConsole");
+            switch_to(activeVT, FALSE);
             activeVT = -1;
         }
     }
-- 
2.5.0