[PATCH xf86-input-mouse] Use signal-safe logging if available
Peter Hutterer
peter.hutterer at who-t.net
Wed Oct 3 19:00:53 PDT 2012
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Urgh, that's what I get for not upstreaming this patch. I wrote this a while
ago but somehow it never made it to the repo.
src/bsd_mouse.c | 10 ++++++----
src/hurd_mouse.c | 2 +-
src/mouse.c | 36 ++++++++++++++++++------------------
src/mouse.h | 3 +++
src/sun_mouse.c | 39 +++++++++++++++++++++------------------
5 files changed, 49 insertions(+), 41 deletions(-)
diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
index 441066f..ca4c9d0 100644
--- a/src/bsd_mouse.c
+++ b/src/bsd_mouse.c
@@ -435,8 +435,9 @@ wsconsReadInput(InputInfoPtr pInfo)
break;
#endif
default:
- xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name,
- event->type);
+ LogMessageVerbSigSafe(X_WARNING, -1,
+ "%s: bad wsmouse event type=%d\n", pInfo->name,
+ event->type);
++event;
continue;
}
@@ -584,8 +585,9 @@ usbReadInput(InputInfoPtr pInfo)
if (n == 0)
return;
if (n != pUsbMse->packetSize) {
- xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", pInfo->name,
- n);
+ LogMessageVerbSigSafe(X_WARNING, -1,
+ "%s: incomplete packet, size %d\n",
+ pInfo->name, n);
}
/* discard packets with an id that don't match the mouse */
/* XXX this is probably not the right thing */
diff --git a/src/hurd_mouse.c b/src/hurd_mouse.c
index 16ae945..2b0d786 100644
--- a/src/hurd_mouse.c
+++ b/src/hurd_mouse.c
@@ -122,7 +122,7 @@ OsMouseReadInput(InputInfoPtr pInfo)
dy = - event->value.mmotion.mm_deltaY;
break;
default:
- ErrorF("Bad mouse event (%d)\n",event->type);
+ LogMessageVerbSigSafe(X_ERROR, -1, "Bad mouse event (%d)\n",event->type);
continue;
}
pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0);
diff --git a/src/mouse.c b/src/mouse.c
index b65ea0e..0487067 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -1167,7 +1167,7 @@ MouseReadInput(InputInfoPtr pInfo)
u = (unsigned char)c;
#if defined (EXTMOUSEDEBUG) || defined (MOUSEDATADEBUG)
- ErrorF("mouse byte: %2.2x\n",u);
+ LogMessageVerbSigSafe(X_INFO, -1, "mouse byte: %x\n",u);
#endif
/* if we do autoprobing collect the data */
@@ -1225,7 +1225,7 @@ MouseReadInput(InputInfoPtr pInfo)
* preceeding the byte.
*/
#ifdef EXTMOUSEDEBUG
- ErrorF("mouse 4th byte %02x\n",u);
+ LogMessageVerbSigSafe(X_INFO, -1, "mouse 4th byte %x\n",u);
#endif
dx = dy = dz = dw = 0;
buttons = 0;
@@ -1275,10 +1275,10 @@ MouseReadInput(InputInfoPtr pInfo)
#ifdef EXTMOUSEDEBUG2
{
int i;
- ErrorF("received %d bytes",pBufP);
+ LogMessageVerbSigSafe(X_INFO, -1, "received %d bytes",pBufP);
for ( i=0; i < pBufP; i++)
- ErrorF(" %02x",pBuf[i]);
- ErrorF("\n");
+ LogMessageVerbSigSafe(X_INFO, -1, " %x",pBuf[i]);
+ LogMessageVerbSigSafe(X_INFO, -1, "\n");
}
#endif
@@ -1353,11 +1353,11 @@ MouseReadInput(InputInfoPtr pInfo)
if ((pBuf[0] & pMse->protoPara[0]) != pMse->protoPara[1] || baddata) {
if (pMse->inSync) {
#ifdef EXTMOUSEDEBUG
- ErrorF("mouse driver lost sync\n");
+ LogMessageVerbSigSafe(X_INFO, -1, "mouse driver lost sync\n");
#endif
}
#ifdef EXTMOUSEDEBUG
- ErrorF("skipping byte %02x\n",*pBuf);
+ LogMessageVerbSigSafe(X_INFO, -1, "skipping byte %x\n",*pBuf);
#endif
/* Tell auto probe that we are out of sync */
if (pMse->autoProbeMouse && pMse->autoProbe)
@@ -1374,7 +1374,7 @@ MouseReadInput(InputInfoPtr pInfo)
if (!pMse->inSync) {
#ifdef EXTMOUSEDEBUG
- ErrorF("mouse driver back in sync\n");
+ LogMessageVerbSigSafe(X_INFO, -1, "mouse driver back in sync\n");
#endif
pMse->inSync = 1;
}
@@ -1616,20 +1616,20 @@ MouseReadInput(InputInfoPtr pInfo)
default: /* There's a table error */
#ifdef EXTMOUSEDEBUG
- ErrorF("mouse table error\n");
+ LogMessageVerbSigSafe(X_INFO, -1, "mouse table error\n");
#endif
continue;
}
#ifdef EXTMOUSEDEBUG
- ErrorF("packet");
+ LogMessageVerbSigSafe(X_INFO, -1, "packet");
for ( j=0; j < pBufP; j++)
- ErrorF(" %02x",pBuf[j]);
- ErrorF("\n");
+ LogMessageVerbSigSafe(X_INFO, -1, " %x",pBuf[j]);
+ LogMessageVerbSigSafe(X_INFO, -1, "\n");
#endif
post_event:
#ifdef EXTMOUSEDEBUG
- ErrorF("dx=%i dy=%i dz=%i dw=%i buttons=%x\n",dx,dy,dz,dw,buttons);
+ LogMessageVerbSigSafe(X_INFO, -1, "dx=%i dy=%i dz=%i dw=%i buttons=%x\n",dx,dy,dz,dw,buttons);
#endif
/* When auto-probing check if data makes sense */
if (pMse->checkMovements && pMse->autoProbe)
@@ -2005,7 +2005,7 @@ buttonTimer(InputInfoPtr pInfo)
xf86PostButtonEvent(pInfo->dev, 0, abs(id), (id >= 0), 0, 0);
pMse->emulateState = stateTab[pMse->emulateState][4][2];
} else {
- ErrorF("Got unexpected buttonTimer in state %d\n", pMse->emulateState);
+ LogMessageVerbSigSafe(X_WARNING, -1, "Got unexpected buttonTimer in state %d\n", pMse->emulateState);
}
xf86UnblockSIGIO (sigstate);
@@ -2046,7 +2046,7 @@ Emulate3ButtonsSoft(InputInfoPtr pInfo)
if (!pMse->emulate3ButtonsSoft)
return TRUE;
- xf86Msg(X_INFO,"3rd Button detected: disabling emulate3Button\n");
+ LogMessageVerbSigSafe(X_INFO, 4, "mouse: 3rd Button detected: disabling emulate3Button\n");
Emulate3ButtonsSetEnabled(pInfo, FALSE);
@@ -3003,7 +3003,7 @@ mouseReset(InputInfoPtr pInfo, unsigned char val)
mousepriv->lastEvent = GetTimeInMillis();
#ifdef EXTMOUSEDEBUG
- ErrorF("byte: 0x%x time: %li\n",val,mousepriv->lastEvent);
+ LogMessageVerbSigSafe(X_INFO, -1, "byte: 0x%x time: %li\n",val,mousepriv->lastEvent);
#endif
/*
* We believe that the following is true:
@@ -3031,7 +3031,7 @@ mouseReset(InputInfoPtr pInfo, unsigned char val)
mousepriv->inReset = FALSE;
#ifdef EXTMOUSEDEBUG
- ErrorF("Mouse Current: %i 0x%x\n",mousepriv->current, val);
+ LogMessageVerbSigSafe(X_INFO, -1, "Mouse Current: %i 0x%x\n",mousepriv->current, val);
#endif
/* here we put the mouse specific reset detection */
@@ -3054,7 +3054,7 @@ mouseReset(InputInfoPtr pInfo, unsigned char val)
mousepriv->expires = GetTimeInMillis() + 1000;
#ifdef EXTMOUSEDEBUG
- ErrorF("Found PS/2 Reset string\n");
+ LogMessageVerbSigSafe(X_INFO, -1, "Found PS/2 Reset string\n");
#endif
RegisterBlockAndWakeupHandlers (ps2BlockHandler,
ps2WakeupHandler, (pointer) pInfo);
diff --git a/src/mouse.h b/src/mouse.h
index 0b3f709..e1165f2 100644
--- a/src/mouse.h
+++ b/src/mouse.h
@@ -38,6 +38,9 @@
#define COLLECT_INPUT_OPTIONS(pInfo, options) xf86CollectInputOptions((pInfo), (options))
#endif
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 18
+#define LogMessageVerbSigSafe LogMessageVerb
+#endif
/* Mouse interface classes */
#define MSE_NONE 0x00
diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index a291c19..16434e6 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -303,21 +303,23 @@ vuidReadInput(InputInfoPtr pInfo)
case EINTR: /* Interrupted, try again */
continue;
case ENODEV: /* May happen when USB mouse 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);
pVuidMse->remove_timer =
TimerSet(pVuidMse->remove_timer, 0, 1,
vuidRemoveMouse, 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 if (n != sizeof(Firm_event)) {
@@ -326,8 +328,8 @@ vuidReadInput(InputInfoPtr pInfo)
}
#ifdef DEBUG
- ErrorF("vuidReadInput: event type: %3d value: %5d\n",
- pVuidMse->event.id, pVuidMse->event.value);
+ LogMessageVerbSigSafe("vuidReadInput: event type: %d value: %d\n",
+ pVuidMse->event.id, pVuidMse->event.value);
#endif
if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) {
@@ -417,15 +419,16 @@ static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse)
} while ( (result != 0) && (errno == EINTR) );
if (result != 0) {
- xf86Msg(X_WARNING,
- "%s: couldn't set absolute mouse scaling resolution: %s\n",
- pInfo->name, strerror(errno));
+ LogMessageVerbSigSafe(X_WARNING, -1,
+ "%s: couldn't set absolute mouse scaling resolution: %s\n",
+ pInfo->name, strerror(errno));
#ifdef DEBUG
} else {
- xf86Msg(X_INFO,
- "%s: absolute mouse scaling resolution set to %d x %d\n",
- pInfo->name,
- pVuidMse->absres.width, pVuidMse->absres.height);
+ LogMessageVerbSigSafe(X_INFO,
+ "%s: absolute mouse scaling resolution set to %d x %d\n",
+ pInfo->name,
+ pVuidMse->absres.width,
+ pVuidMse->absres.height);
#endif
}
}
--
1.7.11.4
More information about the xorg-devel
mailing list