aboutsummaryrefslogtreecommitdiff
path: root/libX11
diff options
context:
space:
mode:
Diffstat (limited to 'libX11')
-rw-r--r--libX11/include/X11/Xlibint.h16
-rw-r--r--libX11/src/ChProp.c6
-rw-r--r--libX11/src/ErrDes.c9
-rw-r--r--libX11/src/GetDflt.c2
-rw-r--r--libX11/src/KeyBind.c2
-rw-r--r--libX11/src/KeysymStr.c26
-rw-r--r--libX11/src/SetHints.c4
-rw-r--r--libX11/src/SetPntMap.c2
-rw-r--r--libX11/src/StBytes.c2
-rw-r--r--libX11/src/StName.c6
-rw-r--r--libX11/src/StrKeysym.c2
-rw-r--r--libX11/src/XlibInt.c20
-rw-r--r--libX11/src/xcms/cmsColNm.c2
13 files changed, 49 insertions, 50 deletions
diff --git a/libX11/include/X11/Xlibint.h b/libX11/include/X11/Xlibint.h
index 03856a671..5609b962d 100644
--- a/libX11/include/X11/Xlibint.h
+++ b/libX11/include/X11/Xlibint.h
@@ -577,7 +577,7 @@ extern void _XFlushGCCache(Display *dpy, GC gc);
* 32 bit word alignment. Transmit if the buffer fills.
*
* "dpy" is a pointer to a Display.
- * "data" is a pinter to a data buffer.
+ * "data" is a pointer to a data buffer.
* "len" is the length of the data buffer.
*/
#ifndef DataRoutineIsProcedure
@@ -587,7 +587,7 @@ extern void _XFlushGCCache(Display *dpy, GC gc);
dpy->bufptr += ((len) + 3) & ~3;\
} else\
_XSend(dpy, data, len);\
- }
+}
#endif /* DataRoutineIsProcedure */
@@ -613,17 +613,17 @@ extern void _XFlushGCCache(Display *dpy, GC gc);
dpy->bufptr += (n);
#ifdef WORD64
-#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)
-#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#define Data16(dpy, data, len) _XData16(dpy, (_Xconst short *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)data, len)
#else
-#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define Data16(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
#ifdef LONG64
-#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (_Xconst long *)data, len)
extern int _XData32(
Display *dpy,
- register long *data,
+ register _Xconst long *data,
unsigned len
);
extern void _XRead32(
@@ -632,7 +632,7 @@ extern void _XRead32(
long len
);
#else
-#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define Data32(dpy, data, len) Data((dpy), (_Xconst char *)(data), (len))
#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
#endif
#endif /* not WORD64 */
diff --git a/libX11/src/ChProp.c b/libX11/src/ChProp.c
index b95775128..190a224f8 100644
--- a/libX11/src/ChProp.c
+++ b/libX11/src/ChProp.c
@@ -62,7 +62,7 @@ XChangeProperty (
len = ((long)nelements + 3)>>2;
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
- Data (dpy, (char *)data, nelements);
+ Data (dpy, (_Xconst char *)data, nelements);
} /* else force BadLength */
break;
@@ -71,7 +71,7 @@ XChangeProperty (
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
len = (long)nelements << 1;
- Data16 (dpy, (short *) data, len);
+ Data16 (dpy, (_Xconst short *) data, len);
} /* else force BadLength */
break;
@@ -80,7 +80,7 @@ XChangeProperty (
if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
SetReqLen(req, len, len);
len = (long)nelements << 2;
- Data32 (dpy, (long *) data, len);
+ Data32 (dpy, (_Xconst long *) data, len);
} /* else force BadLength */
break;
diff --git a/libX11/src/ErrDes.c b/libX11/src/ErrDes.c
index 9a5b1805f..ef5edad6c 100644
--- a/libX11/src/ErrDes.c
+++ b/libX11/src/ErrDes.c
@@ -109,7 +109,7 @@ XGetErrorText(
if (nbytes == 0) return 0;
if (code <= BadImplementation && code > 0) {
- sprintf(buf, "%d", code);
+ snprintf(buf, sizeof(buf), "%d", code);
(void) XGetErrorDatabaseText(dpy, "XProtoError", buf,
_XErrorList + _XErrorOffsets[code],
buffer, nbytes);
@@ -125,11 +125,12 @@ XGetErrorText(
bext = ext;
}
if (!buffer[0] && bext) {
- sprintf(buf, "%s.%d", bext->name, code - bext->codes.first_error);
+ snprintf(buf, sizeof(buf), "%s.%d",
+ bext->name, code - bext->codes.first_error);
(void) XGetErrorDatabaseText(dpy, "XProtoError", buf, "", buffer, nbytes);
}
if (!buffer[0])
- sprintf(buffer, "%d", code);
+ snprintf(buffer, nbytes, "%d", code);
return 0;
}
@@ -190,7 +191,7 @@ XGetErrorDatabaseText(
else
tptr = Xmalloc (tlen);
if (tptr) {
- sprintf(tptr, "%s.%s", name, type);
+ snprintf(tptr, tlen, "%s.%s", name, type);
XrmGetResource(db, tptr, "ErrorType.ErrorNumber",
&type_str, &result);
if (tptr != temp)
diff --git a/libX11/src/GetDflt.c b/libX11/src/GetDflt.c
index 0443e2d1a..fa7d366f5 100644
--- a/libX11/src/GetDflt.c
+++ b/libX11/src/GetDflt.c
@@ -110,7 +110,7 @@ GetHomeDir(
len2 = strlen (ptr2);
}
if ((len1 + len2 + 1) < len)
- sprintf (dest, "%s%s", ptr1, (ptr2) ? ptr2 : "");
+ snprintf (dest, len, "%s%s", ptr1, (ptr2) ? ptr2 : "");
else
*dest = '\0';
#else
diff --git a/libX11/src/KeyBind.c b/libX11/src/KeyBind.c
index 221cedd8c..f22feca59 100644
--- a/libX11/src/KeyBind.c
+++ b/libX11/src/KeyBind.c
@@ -1014,7 +1014,7 @@ XRebindKeysym (
dpy->key_bindings = p;
dpy->free_funcs->key_bindings = _XFreeKeyBindings;
p->next = tmp; /* chain onto list */
- memcpy (p->string, (char *) str, nbytes);
+ memcpy (p->string, str, nbytes);
p->len = nbytes;
memcpy ((char *) p->modifiers, (char *) mlist, nb);
p->key = keysym;
diff --git a/libX11/src/KeysymStr.c b/libX11/src/KeysymStr.c
index 101f29733..c7c470468 100644
--- a/libX11/src/KeysymStr.c
+++ b/libX11/src/KeysymStr.c
@@ -70,11 +70,6 @@ SameValue(
char *XKeysymToString(KeySym ks)
{
- register int i, n;
- int h;
- register int idx;
- const unsigned char *entry;
- unsigned char val1, val2, val3, val4;
XrmDatabase keysymdb;
if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
@@ -83,16 +78,17 @@ char *XKeysymToString(KeySym ks)
ks = 0;
if (ks <= 0x1fffffff)
{
- val1 = ks >> 24;
- val2 = (ks >> 16) & 0xff;
- val3 = (ks >> 8) & 0xff;
- val4 = ks & 0xff;
- i = ks % VTABLESIZE;
- h = i + 1;
- n = VMAXHASH;
+ unsigned char val1 = ks >> 24;
+ unsigned char val2 = (ks >> 16) & 0xff;
+ unsigned char val3 = (ks >> 8) & 0xff;
+ unsigned char val4 = ks & 0xff;
+ int i = ks % VTABLESIZE;
+ int h = i + 1;
+ int n = VMAXHASH;
+ int idx;
while ((idx = hashKeysym[i]))
{
- entry = &_XkeyTable[idx];
+ const unsigned char *entry = &_XkeyTable[idx];
if ((entry[0] == val1) && (entry[1] == val2) &&
(entry[2] == val3) && (entry[3] == val4))
return ((char *)entry + 4);
@@ -111,7 +107,7 @@ char *XKeysymToString(KeySym ks)
XrmQuark empty = NULLQUARK;
GRNData data;
- sprintf(buf, "%lX", ks);
+ snprintf(buf, sizeof(buf), "%lX", ks);
resval.addr = (XPointer)buf;
resval.size = strlen(buf) + 1;
data.name = (char *)NULL;
@@ -136,7 +132,7 @@ char *XKeysymToString(KeySym ks)
i--;
s[i--] = '\0';
for (; i; i--){
- val1 = val & 0xf;
+ unsigned char val1 = val & 0xf;
val >>= 4;
if (val1 < 10)
s[i] = '0'+ val1;
diff --git a/libX11/src/SetHints.c b/libX11/src/SetHints.c
index 0c33f5901..1cde48f85 100644
--- a/libX11/src/SetHints.c
+++ b/libX11/src/SetHints.c
@@ -259,7 +259,9 @@ XSetStandardProperties (
if (icon_string != NULL) {
XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
- PropModeReplace, (unsigned char *)icon_string, safestrlen(icon_string));
+ PropModeReplace,
+ (_Xconst unsigned char *)icon_string,
+ safestrlen(icon_string));
}
if (icon_pixmap != None) {
diff --git a/libX11/src/SetPntMap.c b/libX11/src/SetPntMap.c
index 2e292019f..14e104d6d 100644
--- a/libX11/src/SetPntMap.c
+++ b/libX11/src/SetPntMap.c
@@ -43,7 +43,7 @@ XSetPointerMapping (
GetReq (SetPointerMapping, req);
req->nElts = nmaps;
req->length += (nmaps + 3)>>2;
- Data (dpy, (char *)map, (long) nmaps);
+ Data (dpy, (_Xconst char *)map, (long) nmaps);
if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0)
rep.success = MappingSuccess;
UnlockDisplay(dpy);
diff --git a/libX11/src/StBytes.c b/libX11/src/StBytes.c
index 13ac879c5..07ee441ab 100644
--- a/libX11/src/StBytes.c
+++ b/libX11/src/StBytes.c
@@ -94,7 +94,7 @@ XStoreBuffer (
{
if ((buffer < 0) || (buffer > 7)) return 0;
return XChangeProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
- XA_STRING, 8, PropModeReplace, (unsigned char *) bytes, nbytes);
+ XA_STRING, 8, PropModeReplace, (_Xconst unsigned char *) bytes, nbytes);
}
int
diff --git a/libX11/src/StName.c b/libX11/src/StName.c
index fb1e6f5e1..b4048bff0 100644
--- a/libX11/src/StName.c
+++ b/libX11/src/StName.c
@@ -37,7 +37,7 @@ XStoreName (
_Xconst char *name)
{
return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING,
- 8, PropModeReplace, (unsigned char *)name,
+ 8, PropModeReplace, (_Xconst unsigned char *)name,
name ? strlen(name) : 0);
}
@@ -47,7 +47,7 @@ XSetIconName (
Window w,
_Xconst char *icon_name)
{
- return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING,
- 8, PropModeReplace, (unsigned char *)icon_name,
+ return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
+ PropModeReplace, (_Xconst unsigned char *)icon_name,
icon_name ? strlen(icon_name) : 0);
}
diff --git a/libX11/src/StrKeysym.c b/libX11/src/StrKeysym.c
index 2ac9076e4..8b875a328 100644
--- a/libX11/src/StrKeysym.c
+++ b/libX11/src/StrKeysym.c
@@ -96,7 +96,7 @@ XStringToKeysym(_Xconst char *s)
{
entry = &_XkeyTable[idx];
if ((entry[0] == sig1) && (entry[1] == sig2) &&
- !strcmp(s, (char *)entry + 6))
+ !strcmp(s, (const char *)entry + 6))
{
val = (entry[2] << 24) | (entry[3] << 16) |
(entry[4] << 8) | entry[5];
diff --git a/libX11/src/XlibInt.c b/libX11/src/XlibInt.c
index 59a7585d8..c0a45d41e 100644
--- a/libX11/src/XlibInt.c
+++ b/libX11/src/XlibInt.c
@@ -1451,7 +1451,7 @@ static int _XPrintDefaultError(
mesg, BUFSIZ);
(void) fprintf(fp, mesg, event->request_code);
if (event->request_code < 128) {
- sprintf(number, "%d", event->request_code);
+ snprintf(number, sizeof(number), "%d", event->request_code);
XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
} else {
for (ext = dpy->ext_procs;
@@ -1471,7 +1471,7 @@ static int _XPrintDefaultError(
fputs(" ", fp);
(void) fprintf(fp, mesg, event->minor_code);
if (ext) {
- sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ snprintf(mesg, sizeof(mesg), "%s.%d", ext->name, event->minor_code);
XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
(void) fprintf(fp, " (%s)", buffer);
}
@@ -1494,8 +1494,8 @@ static int _XPrintDefaultError(
bext = ext;
}
if (bext)
- sprintf(buffer, "%s.%d", bext->name,
- event->error_code - bext->codes.first_error);
+ snprintf(buffer, sizeof(buffer), "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
else
strcpy(buffer, "Value");
XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
@@ -1741,7 +1741,7 @@ void _Xbcopy(b1, b2, length)
#ifdef DataRoutineIsProcedure
void Data(
Display *dpy,
- char *data,
+ _Xconst char *data,
long len)
{
if (dpy->bufptr + (len) <= dpy->bufmax) {
@@ -1758,7 +1758,7 @@ void Data(
int
_XData32(
Display *dpy,
- register long *data,
+ register _Xconst long *data,
unsigned len)
{
register int *buf;
@@ -1800,7 +1800,7 @@ _XData32(
static doData16(
register Display *dpy,
- short *data,
+ _Xconst short *data,
unsigned len,
char *packbuffer)
{
@@ -1833,7 +1833,7 @@ static doData16(
_XData16 (
Display *dpy,
- short *data,
+ _Xconst short *data,
unsigned len)
{
char packbuffer[PACKBUFFERSIZE];
@@ -1855,7 +1855,7 @@ _XData16 (
static doData32(
register Display *dpy
- long *data,
+ _Xconst long *data,
unsigned len,
char *packbuffer)
{
@@ -1886,7 +1886,7 @@ static doData32(
void _XData32(
Display *dpy,
- long *data,
+ _Xconst long *data,
unsigned len)
{
char packbuffer[PACKBUFFERSIZE];
diff --git a/libX11/src/xcms/cmsColNm.c b/libX11/src/xcms/cmsColNm.c
index 73977e5fc..a6749c02e 100644
--- a/libX11/src/xcms/cmsColNm.c
+++ b/libX11/src/xcms/cmsColNm.c
@@ -254,7 +254,7 @@ FirstCmp(const void *p1, const void *p2)
*
*/
{
- return(strcmp(((XcmsPair *)p1)->first, ((XcmsPair *)p2)->first));
+ return(strcmp(((const XcmsPair *)p1)->first, ((const XcmsPair *)p2)->first));
}