[PATCH keyboard] Use sigsafe logging for keyboard debug messages

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 16 21:32:34 PDT 2012


This changes the log format to simple hex display, the server's signal-safe
printf implementation doesn't handle %2.2x.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
The second line in hunk 2 is a whitespace removal, I got annoyed by the red
blob (let c_space_errors=1 in vim)

Alan: please test this on Solaris.

 src/at_scancode.c |  4 ++--
 src/kbd.c         |  4 ++--
 src/sun_kbd.c     | 20 +++++++++++---------
 src/xf86OSKbd.h   |  4 ++++
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/at_scancode.c b/src/at_scancode.c
index 7209c20..a519a6c 100644
--- a/src/at_scancode.c
+++ b/src/at_scancode.c
@@ -112,8 +112,8 @@ ATScancode(InputInfoPtr pInfo, int *scanCode)
             case 0x36:
 	         return TRUE;
             default:
-                 xf86MsgVerb(X_INFO, 4, "Unreported Prefix0 scancode: 0x%02x\n",
-		             *scanCode);
+                 LogMessageVerbSigSafe(X_INFO, 4, "Unreported Prefix0 scancode: 0x%x\n",
+                                       *scanCode);
                  *scanCode += 0x78;
           }
        break;
diff --git a/src/kbd.c b/src/kbd.c
index 94523aa..9a013b7 100644
--- a/src/kbd.c
+++ b/src/kbd.c
@@ -410,9 +410,9 @@ PostKbdEvent(InputInfoPtr pInfo, unsigned int scanCode, Bool down)
   int state;
 
 #ifdef DEBUG
-  ErrorF("kbd driver rec scancode: 0x02%x %s\n", scanCode, down?"down":"up");
+  LogMessageVerbSigSafe(X_INFO, -1, "kbd driver rec scancode: 0x%x %s\n", scanCode, down ? "down" : "up");
 #endif
-	  
+
   /*
    * First do some special scancode remapping ...
    */
diff --git a/src/sun_kbd.c b/src/sun_kbd.c
index f1e530e..2e7add6 100644
--- a/src/sun_kbd.c
+++ b/src/sun_kbd.c
@@ -459,20 +459,22 @@ ReadInput(InputInfoPtr pInfo)
 		case EINTR:  /* Interrupted, try again */
 		    break;
 		case ENODEV: /* May happen when USB kbd is unplugged */
-		    /* We use X_NONE here because it doesn't alloc since we
-		       may be called from SIGIO handler */
-		    xf86MsgVerb(X_NONE, 0,
-				"%s: Device no longer present - removing.\n",
-				pInfo->name);
+		    /* We use X_NONE here because it didn't alloc since we
+		       may be called from SIGIO handler. No longer true for
+		       sigsafe logging, but matters for older servers  */
+		    LogMessageVerbSigSafe(X_NONE, 0,
+					  "%s: Device no longer present - removing.\n",
+					  pInfo->name);
 		    xf86RemoveEnabledDevice(pInfo);
 		    priv->remove_timer = TimerSet(priv->remove_timer, 0, 1,
 						  RemoveKeyboard, pInfo);
 		    return;
 		default:     /* All other errors */
-		    /* We use X_NONE here because it doesn't alloc since we
-		       may be called from SIGIO handler */
-		    xf86MsgVerb(X_NONE, 0, "%s: Read error: %s\n", pInfo->name,
-				strerror(errno));
+		    /* We use X_NONE here because it didn't alloc since we
+		       may be called from SIGIO handler. No longer true for
+		       sigsafe logging, but matters for older servers  */
+		    LogMessageVerbSigSafe(X_NONE, 0, "%s: Read error: %s\n", pInfo->name,
+					  strerror(errno));
 		    return;
 	    }
 	} else { /* nBytes == 0, so nothing more to read */
diff --git a/src/xf86OSKbd.h b/src/xf86OSKbd.h
index cba049f..7349b1a 100644
--- a/src/xf86OSKbd.h
+++ b/src/xf86OSKbd.h
@@ -29,6 +29,10 @@
 
 #include "xf86Xinput.h"
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 18
+#define LogMessageVerbSigSafe xf86MsgVerb
+#endif
+
 Bool ATScancode(InputInfoPtr pInfo, int *scanCode);
 
 /* Public interface to OS-specific keyboard support. */
-- 
1.7.11.2



More information about the xorg-devel mailing list