summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2011-09-18 20:47:04 -0500
committerJamey Sharp <jamey@minilop.net>2011-09-19 15:16:04 -0700
commit87cc83474d9890d14d9bc60926a97bd0d5b059af (patch)
tree6820dba6a3e081e3b42b9946ed546dde7d4fa794
parentdf4eeb1256c7c5e7a3f88f10da2915c7a07a8db8 (diff)
Replace XmuSnprintf with snprintf.
Alan Coopersmith explains: XmuSnprintf() can be replaced by snprintf() now. (It was a implementation X provided for it's libraries to use in the days before all platforms we cared about had snprintf in libc.) Reported-by: walter harms <wharms@bfs.de> Signed-off-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--hw/dmx/config/xdmxconfig.c23
-rw-r--r--hw/dmx/dmxclient.h1
-rw-r--r--hw/dmx/dmxinit.c11
-rw-r--r--hw/dmx/dmxprop.c9
-rw-r--r--hw/dmx/doc/dmx.xml2
-rw-r--r--hw/dmx/examples/dmxwininfo.c3
-rw-r--r--hw/dmx/input/dmxinputinit.c6
-rw-r--r--hw/dmx/input/lnx-keyboard.c4
-rw-r--r--hw/dmx/input/usb-common.c4
9 files changed, 31 insertions, 32 deletions
diff --git a/hw/dmx/config/xdmxconfig.c b/hw/dmx/config/xdmxconfig.c
index 2de7f2b85..3165ba000 100644
--- a/hw/dmx/config/xdmxconfig.c
+++ b/hw/dmx/config/xdmxconfig.c
@@ -49,7 +49,6 @@
#include <X11/Xaw/Viewport.h>
#include <X11/Xaw/Dialog.h>
#include <X11/keysym.h>
-#include <X11/Xmu/SysUtil.h>
#include "Canvas.h"
#include "dmxparse.h"
@@ -199,8 +198,8 @@ static void dmxConfigDataUpdate(void)
XtVaSetValues(ndbutton1, XtNsensitive, False, NULL);
} else {
name = dmxConfigCurrent->name;
- XmuSnprintf(cnambuf, sizeof(cnambuf), "%s", name ? name : "");
- XmuSnprintf(cdimbuf, sizeof(cdimbuf), "%dx%d",
+ snprintf(cnambuf, sizeof(cnambuf), "%s", name ? name : "");
+ snprintf(cdimbuf, sizeof(cdimbuf), "%dx%d",
dmxConfigWallWidth, dmxConfigWallHeight);
XtVaSetValues(cnamebox, XtNlabel, cnambuf, XtNsensitive, True, NULL);
XtVaSetValues(cdimbox, XtNlabel, cdimbuf, XtNsensitive, True, NULL);
@@ -219,22 +218,22 @@ static void dmxConfigDataUpdate(void)
XtVaSetValues(ddbutton, XtNsensitive, False, NULL);
} else {
name = dmxConfigCurrentDisplay->name;
- XmuSnprintf(nambuf, sizeof(nambuf), "%s", name ? name : "");
- XmuSnprintf(dimbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
+ snprintf(nambuf, sizeof(nambuf), "%s", name ? name : "");
+ snprintf(dimbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
dmxConfigCurrentDisplay->scrnWidth,
dmxConfigCurrentDisplay->scrnHeight,
dmxConfigCurrentDisplay->scrnXSign < 0 ? '-' : '+',
dmxConfigCurrentDisplay->scrnX,
dmxConfigCurrentDisplay->scrnYSign < 0 ? '-' : '+',
dmxConfigCurrentDisplay->scrnY);
- XmuSnprintf(rtbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
+ snprintf(rtbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
dmxConfigCurrentDisplay->rootWidth,
dmxConfigCurrentDisplay->rootHeight,
dmxConfigCurrentDisplay->rootXSign < 0 ? '-' : '+',
dmxConfigCurrentDisplay->rootX,
dmxConfigCurrentDisplay->rootYSign < 0 ? '-' : '+',
dmxConfigCurrentDisplay->rootY);
- XmuSnprintf(offbuf, sizeof(offbuf), "@%dx%d",
+ snprintf(offbuf, sizeof(offbuf), "@%dx%d",
dmxConfigCurrentDisplay->rootXOrigin,
dmxConfigCurrentDisplay->rootYOrigin);
XtVaSetValues(namebox, XtNlabel, nambuf, XtNsensitive, True, NULL);
@@ -596,14 +595,14 @@ static void dmxConfigCanCallback(Widget w, XtPointer closure,
static void dmxConfigECCallback(Widget w, XtPointer closure,
XtPointer callData)
{
- char buf[256]; /* RATS: Only used in XmuSnprintf */
+ char buf[256]; /* RATS: Only used in snprintf */
if (!dmxConfigCurrent) return;
dmxConfigSetPopupPosition(ecpopup);
XtVaSetValues(ecdialog0, XtNvalue,
dmxConfigCurrent->name ? dmxConfigCurrent->name : "",
NULL);
- XmuSnprintf(buf, sizeof(buf), "%dx%d",
+ snprintf(buf, sizeof(buf), "%dx%d",
dmxConfigCurrent->width, dmxConfigCurrent->height);
XtVaSetValues(ecdialog1, XtNvalue, buf, NULL);
XtPopup(ecpopup, XtGrabExclusive);
@@ -692,7 +691,7 @@ static void dmxConfigECCanCallback(Widget w, XtPointer closure,
static void dmxConfigEDCallback(Widget w, XtPointer closure,
XtPointer callData)
{
- char buf[256]; /* RATS: Only used in XmuSnprintf */
+ char buf[256]; /* RATS: Only used in snprintf */
if (!dmxConfigCurrent || !dmxConfigCurrentDisplay) return;
dmxConfigSetPopupPosition(edpopup);
@@ -701,7 +700,7 @@ static void dmxConfigEDCallback(Widget w, XtPointer closure,
? dmxConfigCurrentDisplay->name
: "",
NULL);
- XmuSnprintf(buf, sizeof(buf), "%dx%d%c%d%c%d",
+ snprintf(buf, sizeof(buf), "%dx%d%c%d%c%d",
dmxConfigCurrentDisplay->scrnWidth,
dmxConfigCurrentDisplay->scrnHeight,
dmxConfigCurrentDisplay->scrnXSign < 0 ? '-' : '+',
@@ -709,7 +708,7 @@ static void dmxConfigEDCallback(Widget w, XtPointer closure,
dmxConfigCurrentDisplay->scrnYSign < 0 ? '-' : '+',
dmxConfigCurrentDisplay->scrnY);
XtVaSetValues(eddialog1, XtNvalue, buf, NULL);
- XmuSnprintf(buf, sizeof(buf), "@%dx%d",
+ snprintf(buf, sizeof(buf), "@%dx%d",
dmxConfigCurrentDisplay->rootXOrigin,
dmxConfigCurrentDisplay->rootYOrigin);
XtVaSetValues(eddialog2, XtNvalue, buf, NULL);
diff --git a/hw/dmx/dmxclient.h b/hw/dmx/dmxclient.h
index c45f71fc0..f0f235f61 100644
--- a/hw/dmx/dmxclient.h
+++ b/hw/dmx/dmxclient.h
@@ -82,7 +82,6 @@ typedef XID KeySym64;
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
-#include <X11/Xmu/SysUtil.h> /* For XmuSnprintf */
#include <X11/extensions/shape.h>
diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
index bc1509b35..165476c5f 100644
--- a/hw/dmx/dmxinit.c
+++ b/hw/dmx/dmxinit.c
@@ -56,6 +56,7 @@
#include "dmxpict.h"
#include <X11/Xos.h> /* For gettimeofday */
+#include <X11/Xmu/SysUtil.h> /* For XmuGetHostname */
#include "dixstruct.h"
#ifdef PANORAMIX
#include "panoramiXsrv.h"
@@ -131,7 +132,7 @@ static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
/* Find major opcode name */
if (ev->request_code < 128) {
- XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
+ snprintf(request, sizeof(request), "%d", ev->request_code);
XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
} else {
for (ext = dpy->ext_procs;
@@ -145,8 +146,8 @@ static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
/* Find minor opcode name */
if (ev->request_code >= 128 && ext) {
- XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
- XmuSnprintf(request, sizeof(request), "%s.%d",
+ snprintf(request, sizeof(request), "%d", ev->request_code);
+ snprintf(request, sizeof(request), "%s.%d",
ext->name, ev->minor_code);
XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
dmxLog(dmxWarning, " Minor opcode: %d (%s)\n",
@@ -515,7 +516,7 @@ static const char *dmxExecOS(void)
if (!initialized++) {
memset(buffer, 0, sizeof(buffer));
uname(&u);
- XmuSnprintf(buffer, sizeof(buffer)-1, "%s %s %s",
+ snprintf(buffer, sizeof(buffer)-1, "%s %s %s",
u.sysname, u.release, u.version);
}
return buffer;
@@ -530,7 +531,7 @@ static const char *dmxBuildCompiler(void)
if (!initialized++) {
memset(buffer, 0, sizeof(buffer));
#if defined(__GNUC__) && defined(__GNUC_MINOR__) &&defined(__GNUC_PATCHLEVEL__)
- XmuSnprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d",
+ snprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d",
__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#endif
}
diff --git a/hw/dmx/dmxprop.c b/hw/dmx/dmxprop.c
index d4618e3fa..b4695dd5d 100644
--- a/hw/dmx/dmxprop.c
+++ b/hw/dmx/dmxprop.c
@@ -62,6 +62,7 @@
#include "dmx.h"
#include "dmxprop.h"
#include "dmxlog.h"
+#include <X11/Xmu/SysUtil.h> /* For XmuGetHostname */
/** Holds the window id of all DMX windows on the backend X server. */
#define DMX_ATOMNAME "DMX_NAME"
@@ -87,7 +88,7 @@ static const unsigned char *dmxPropertyIdentifier(void)
if (initialized++) return (unsigned char *)buf;
XmuGetHostname(hostname, sizeof(hostname));
- XmuSnprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
+ snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
return (unsigned char *)buf;
}
@@ -319,7 +320,7 @@ void dmxPropertyWindow(DMXScreenInfo *dmxScreen)
Display *dpy = dmxScreen->beDisplay;
Window win = dmxScreen->scrnWin;
DMXScreenInfo *other;
- char buf[128]; /* RATS: only used with XmuSnprintf */
+ char buf[128]; /* RATS: only used with snprintf */
if (!dpy)
return; /* FIXME: What should be done here if Xdmx is started
@@ -336,12 +337,12 @@ void dmxPropertyWindow(DMXScreenInfo *dmxScreen)
other->index, other->name, other->scrnWin);
}
- XmuSnprintf(buf, sizeof(buf), ".%d,%lu", dmxScreen->index,
+ snprintf(buf, sizeof(buf), ".%d,%lu", dmxScreen->index,
(long unsigned)win);
XChangeProperty(dpy, RootWindow(dpy,0), atom, XA_STRING, 8,
PropModeAppend, (unsigned char *)buf, strlen(buf));
- XmuSnprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
+ snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
XChangeProperty(dpy, win, atom, XA_STRING, 8,
PropModeAppend, (unsigned char *)buf, strlen(buf));
}
diff --git a/hw/dmx/doc/dmx.xml b/hw/dmx/doc/dmx.xml
index 8dbb7d86f..ce472c2bf 100644
--- a/hw/dmx/doc/dmx.xml
+++ b/hw/dmx/doc/dmx.xml
@@ -3392,7 +3392,7 @@ Unrepaired warnings are as follows:
<orderedlist>
<listitem><para>
Fixed-size buffers are used in many areas, but code has been
- added to protect against buffer overflows (e.g., XmuSnprint).
+ added to protect against buffer overflows (e.g., snprintf).
The only instances that have not yet been fixed are in
config/xdmxconfig.c (which is not part of the Xdmx server) and
input/usb-common.c.
diff --git a/hw/dmx/examples/dmxwininfo.c b/hw/dmx/examples/dmxwininfo.c
index 6cf1d411e..3d027d530 100644
--- a/hw/dmx/examples/dmxwininfo.c
+++ b/hw/dmx/examples/dmxwininfo.c
@@ -39,7 +39,6 @@
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
-#include <X11/Xmu/SysUtil.h>
#include <X11/extensions/dmxext.h>
static const char *FontName = "fixed";
@@ -80,7 +79,7 @@ EventLoop(Display *dpy, Window win, GC gc)
y += 20;
for (i = 0; i < count; i++) {
char str[500];
- XmuSnprintf(str, sizeof(str),
+ snprintf(str, sizeof(str),
"screen %d: pos: %dx%d+%d+%d visible: %dx%d+%d+%d",
winInfo[i].screen,
winInfo[i].pos.width, winInfo[i].pos.height,
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 1b067c725..16ecae38d 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -671,9 +671,9 @@ static char *dmxMakeUniqueDeviceName(DMXLocalInputInfoPtr dmxLocal)
}
switch (dmxLocal->type) {
- case DMX_LOCAL_KEYBOARD: XmuSnprintf(buf, LEN, "Keyboard%d", k++); break;
- case DMX_LOCAL_MOUSE: XmuSnprintf(buf, LEN, "Mouse%d", m++); break;
- default: XmuSnprintf(buf, LEN, "Other%d", o++); break;
+ case DMX_LOCAL_KEYBOARD: snprintf(buf, LEN, "Keyboard%d", k++); break;
+ case DMX_LOCAL_MOUSE: snprintf(buf, LEN, "Mouse%d", m++); break;
+ default: snprintf(buf, LEN, "Other%d", o++); break;
}
return buf;
diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
index 5b92f3b8f..06e9ec722 100644
--- a/hw/dmx/input/lnx-keyboard.c
+++ b/hw/dmx/input/lnx-keyboard.c
@@ -430,10 +430,10 @@ static int kbdLinuxOpenVT(int vtno)
int fd = -1;
int i;
const char *vcs[] = { "/dev/vc/", "/dev/tty", NULL };
- char name[64]; /* RATS: Only used in XmuSnprintf */
+ char name[64]; /* RATS: Only used in snprintf */
for (i = 0; vcs[i]; i++) {
- XmuSnprintf(name, sizeof(name), "%s%d", vcs[i], vtno);
+ snprintf(name, sizeof(name), "%s%d", vcs[i], vtno);
if ((fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) break;
}
if (fd < 0)
diff --git a/hw/dmx/input/usb-common.c b/hw/dmx/input/usb-common.c
index 25479aea6..944033eba 100644
--- a/hw/dmx/input/usb-common.c
+++ b/hw/dmx/input/usb-common.c
@@ -272,7 +272,7 @@ device. */
void usbInit(DevicePtr pDev, usbType type)
{
GETPRIV;
- char name[64]; /* RATS: Only used in XmuSnprintf */
+ char name[64]; /* RATS: Only used in snprintf */
int i, j, k;
char buf[256] = { 0, }; /* RATS: Use ok */
int version;
@@ -284,7 +284,7 @@ void usbInit(DevicePtr pDev, usbType type)
if (priv->fd >=0) return;
for (i = 0; i < 32; i++) {
- XmuSnprintf(name, sizeof(name), "/dev/input/event%d", i);
+ snprintf(name, sizeof(name), "/dev/input/event%d", i);
if ((priv->fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) {
ioctl(priv->fd, EVIOCGVERSION, &version);
ioctl(priv->fd, EVIOCGNAME(sizeof(buf)), buf);