[PATCH 5/5] xfree86: make xf86*Handler type-safe.

Peter Hutterer peter.hutterer at who-t.net
Wed Aug 10 20:03:14 PDT 2011


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 hw/xfree86/common/xf86.h       |   17 +++++----
 hw/xfree86/common/xf86Events.c |   76 ++++++++++++++++------------------------
 2 files changed, 39 insertions(+), 54 deletions(-)

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index ae152b9..f6b80d0 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -188,16 +188,17 @@ extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode;
 #endif
 
 /* xf86Events.c */
+typedef struct x_IHRec *IHPtr;
 
 extern _X_EXPORT void SetTimeSinceLastInputEvent(void);
-extern _X_EXPORT pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
-extern _X_EXPORT int xf86RemoveInputHandler(pointer handler);
-extern _X_EXPORT void xf86DisableInputHandler(pointer handler);
-extern _X_EXPORT void xf86EnableInputHandler(pointer handler);
-extern _X_EXPORT pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data);
-extern _X_EXPORT int xf86RemoveGeneralHandler(pointer handler);
-extern _X_EXPORT void xf86DisableGeneralHandler(pointer handler);
-extern _X_EXPORT void xf86EnableGeneralHandler(pointer handler);
+extern _X_EXPORT IHPtr xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
+extern _X_EXPORT int xf86RemoveInputHandler(IHPtr handler);
+extern _X_EXPORT void xf86DisableInputHandler(IHPtr handler);
+extern _X_EXPORT void xf86EnableInputHandler(IHPtr handler);
+extern _X_EXPORT IHPtr xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data);
+extern _X_EXPORT int xf86RemoveGeneralHandler(IHPtr handler);
+extern _X_EXPORT void xf86DisableGeneralHandler(IHPtr handler);
+extern _X_EXPORT void xf86EnableGeneralHandler(IHPtr handler);
 extern _X_EXPORT InputHandlerProc xf86SetConsoleHandler(InputHandlerProc handler, pointer data);
 extern _X_EXPORT void xf86InterceptSignals(int *signo);
 extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler)(void));
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index a4bad60..f4be559 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -116,7 +116,7 @@ typedef struct x_IHRec {
     pointer		data;
     Bool		enabled;
     struct x_IHRec *	next;
-} IHRec, *IHPtr;
+} IHRec;
 
 static IHPtr InputHandlers = NULL;
 
@@ -550,7 +550,7 @@ xf86VTSwitch(void)
 
 /* Input handler registration */
 
-static pointer
+static IHPtr
 addInputHandler(int fd, InputHandlerProc proc, pointer data)
 {
     IHPtr ih;
@@ -573,7 +573,7 @@ addInputHandler(int fd, InputHandlerProc proc, pointer data)
     return ih;
 }
 
-pointer
+IHPtr
 xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
 {
     IHPtr ih = addInputHandler(fd, proc, data);
@@ -583,7 +583,7 @@ xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
     return ih;
 }
 
-pointer
+IHPtr
 xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
 {
     IHPtr ih = addInputHandler(fd, proc, data);
@@ -632,97 +632,81 @@ removeInputHandler(IHPtr ih)
 }
 
 int
-xf86RemoveInputHandler(pointer handler)
+xf86RemoveInputHandler(IHPtr handler)
 {
-    IHPtr ih;
     int fd;
 
     if (!handler)
 	return -1;
 
-    ih = handler;
-    fd = ih->fd;
+    fd = handler->fd;
 
-    if (ih->fd >= 0)
-	RemoveEnabledDevice(ih->fd);
-    removeInputHandler(ih);
+    if (handler->fd >= 0)
+	RemoveEnabledDevice(handler->fd);
+    removeInputHandler(handler);
 
     return fd;
 }
 
 int
-xf86RemoveGeneralHandler(pointer handler)
+xf86RemoveGeneralHandler(IHPtr handler)
 {
-    IHPtr ih;
     int fd;
 
     if (!handler)
 	return -1;
 
-    ih = handler;
-    fd = ih->fd;
+    fd = handler->fd;
 
-    if (ih->fd >= 0)
-	RemoveGeneralSocket(ih->fd);
-    removeInputHandler(ih);
+    if (handler->fd >= 0)
+	RemoveGeneralSocket(handler->fd);
+    removeInputHandler(handler);
 
     return fd;
 }
 
 void
-xf86DisableInputHandler(pointer handler)
+xf86DisableInputHandler(IHPtr handler)
 {
-    IHPtr ih;
-
     if (!handler)
 	return;
 
-    ih = handler;
-    ih->enabled = FALSE;
-    if (ih->fd >= 0)
-	RemoveEnabledDevice(ih->fd);
+    handler->enabled = FALSE;
+    if (handler->fd >= 0)
+	RemoveEnabledDevice(handler->fd);
 }
 
 void
-xf86DisableGeneralHandler(pointer handler)
+xf86DisableGeneralHandler(IHPtr handler)
 {
-    IHPtr ih;
-
     if (!handler)
 	return;
 
-    ih = handler;
-    ih->enabled = FALSE;
-    if (ih->fd >= 0)
-	RemoveGeneralSocket(ih->fd);
+    handler->enabled = FALSE;
+    if (handler->fd >= 0)
+	RemoveGeneralSocket(handler->fd);
 }
 
 void
-xf86EnableInputHandler(pointer handler)
+xf86EnableInputHandler(IHPtr handler)
 {
-    IHPtr ih;
-
     if (!handler)
 	return;
 
-    ih = handler;
-    ih->enabled = TRUE;
-    if (ih->fd >= 0)
-	AddEnabledDevice(ih->fd);
+    handler->enabled = TRUE;
+    if (handler->fd >= 0)
+	AddEnabledDevice(handler->fd);
 }
 
 void
-xf86EnableGeneralHandler(pointer handler)
+xf86EnableGeneralHandler(IHPtr handler)
 {
-    IHPtr ih;
-
     if (!handler)
 	return;
 
-    ih = handler;
-    ih->enabled = TRUE;
-    if (ih->fd >= 0)
-	AddGeneralSocket(ih->fd);
+    handler->enabled = TRUE;
+    if (handler->fd >= 0)
+	AddGeneralSocket(handler->fd);
 }
 
 /*
-- 
1.7.6



More information about the xorg-devel mailing list