[PATCH] randr: set error numbers of resource types in RRExtenstionInit() (V2)

Tobias Droste tdroste at gmx.de
Wed Sep 29 13:51:48 PDT 2010


Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=30367

Currently the ddx calls xf86RandR12Init()
  (-> RRScreenInit()
     -> RRInit()
       -> RRModeInit()
       -> RRCrtcInit()
       -> RROutputInit())
before RRExtensionInit() is called. This causes RRErrorBase
being 0 while setting resource type error values (resource types:
RROutput, RRMode and RRCrtc). The fix moves the setting of error
values to own functions which are called in RRExtensionInit()
to get the right RRErrorBase.

V2: With header file

Signed-off-by: Tobias Droste <tdroste at gmx.de>
---
 randr/randr.c    |    5 +++++
 randr/randrstr.h |   18 ++++++++++++++++++
 randr/rrcrtc.c   |   11 ++++++++++-
 randr/rrmode.c   |   14 +++++++++++++-
 randr/rroutput.c |   11 ++++++++++-
 5 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/randr/randr.c b/randr/randr.c
index f52a46a..6077705 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -354,6 +354,11 @@ RRExtensionInit (void)
 	SRRScreenChangeNotifyEvent;
     EventSwapVector[RREventBase + RRNotify] = (EventSwapPtr)
 	SRRNotifyEvent;
+
+    RRModeInitErrorValue();
+    RRCrtcInitErrorValue();
+    RROutputInitErrorValue();
+
 #ifdef PANORAMIX
     RRXineramaExtensionInit();
 #endif
diff --git a/randr/randrstr.h b/randr/randrstr.h
index aad126f..03652ef 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -701,6 +701,12 @@ extern _X_EXPORT Bool
 RRCrtcInit (void);
 
 /*
+ * Initialize crtc type error value
+ */
+extern _X_EXPORT void
+RRCrtcInitErrorValue (void);
+
+/*
  * Crtc dispatch
  */
 
@@ -762,6 +768,12 @@ RRModesForScreen (ScreenPtr pScreen, int *num_ret);
  */
 extern _X_EXPORT Bool
 RRModeInit (void);
+
+/*
+ * Initialize mode type error value
+ */
+extern _X_EXPORT void
+RRModeInitErrorValue (void);
     
 extern _X_EXPORT int
 ProcRRCreateMode (ClientPtr client);
@@ -856,6 +868,12 @@ ProcRRGetOutputPrimary (ClientPtr client);
  */
 extern _X_EXPORT Bool
 RROutputInit (void);
+
+/*
+ * Initialize output type error value
+ */
+extern _X_EXPORT void
+RROutputInitErrorValue (void);
     
 /* rrpointer.c */
 extern _X_EXPORT void
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 14f6e45..98206a2 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -631,10 +631,19 @@ RRCrtcInit (void)
     RRCrtcType = CreateNewResourceType (RRCrtcDestroyResource, "CRTC");
     if (!RRCrtcType)
 	return FALSE;
-    SetResourceTypeErrorValue(RRCrtcType, RRErrorBase + BadRRCrtc);
+    
     return TRUE;
 }
 
+/*
+ * Initialize crtc type error value
+ */
+void
+RRCrtcInitErrorValue(void)
+{
+    SetResourceTypeErrorValue(RRCrtcType, RRErrorBase + BadRRCrtc);
+}
+
 int
 ProcRRGetCrtcInfo (ClientPtr client)
 {
diff --git a/randr/rrmode.c b/randr/rrmode.c
index deddd3c..5ffa400 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -260,6 +260,9 @@ RRModeDestroyResource (pointer value, XID pid)
     return 1;
 }
 
+/*
+ * Initialize mode type
+ */
 Bool
 RRModeInit (void)
 {
@@ -268,10 +271,19 @@ RRModeInit (void)
     RRModeType = CreateNewResourceType (RRModeDestroyResource, "MODE");
     if (!RRModeType)
 	return FALSE;
-    SetResourceTypeErrorValue(RRModeType, RRErrorBase + BadRRMode);
+    
     return TRUE;
 }
 
+/*
+ * Initialize mode type error value
+ */
+void
+RRModeInitErrorValue(void)
+{
+    SetResourceTypeErrorValue(RRModeType, RRErrorBase + BadRRMode);
+}
+
 int
 ProcRRCreateMode (ClientPtr client)
 {
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 937b14d..5edeb7d 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -418,10 +418,19 @@ RROutputInit (void)
     RROutputType = CreateNewResourceType (RROutputDestroyResource, "OUTPUT");
     if (!RROutputType)
 	return FALSE;
-    SetResourceTypeErrorValue(RROutputType, RRErrorBase + BadRROutput);
+
     return TRUE;
 }
 
+/*
+ * Initialize output type error value
+ */
+void
+RROutputInitErrorValue(void)
+{
+    SetResourceTypeErrorValue(RROutputType, RRErrorBase + BadRROutput);
+}
+
 #define OutputInfoExtra	(SIZEOF(xRRGetOutputInfoReply) - 32)
 
 int
-- 
1.7.1



More information about the xorg-devel mailing list