summaryrefslogtreecommitdiff
path: root/dix
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-11-15 21:57:05 +0900
committerKeith Packard <keithp@keithp.com>2014-01-12 10:14:49 -0800
commitd89b42bda46d36fc0879611cc3b3566957ce36d0 (patch)
treefdbf1dc37a86b98e63ca5235506e5ff1f90e6b28 /dix
parentd6da9f23cca562fc0c6ae398665ab7fa770a4fa8 (diff)
Clean up warnings in DIX
As usual, mostly const char changes. However, filter_device_events had a potentially uninitialized value, 'raw', which I added a bunch of checks for. I suspect most of those are 'can't happen', but it's hard to see that inside the function. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'dix')
-rw-r--r--dix/dispatch.c4
-rw-r--r--dix/dixfonts.c31
-rw-r--r--dix/events.c5
-rw-r--r--dix/extension.c14
-rw-r--r--dix/getevents.c11
-rw-r--r--dix/globals.c8
-rw-r--r--dix/window.c6
7 files changed, 44 insertions, 35 deletions
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 8dcd9cbcf..64f8ef9ed 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -470,7 +470,7 @@ Dispatch(void)
}
static int VendorRelease = VENDOR_RELEASE;
-static char *VendorString = VENDOR_NAME;
+static const char *VendorString = VENDOR_NAME;
void
SetVendorRelease(int release)
@@ -479,7 +479,7 @@ SetVendorRelease(int release)
}
void
-SetVendorString(char *string)
+SetVendorString(const char *string)
{
VendorString = string;
}
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 2e34d370f..57177acc9 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -128,7 +128,7 @@ dixGetGlyphs(FontPtr font, unsigned long count, unsigned char *chars,
* adding RT_FONT prevents conflict with default cursor font
*/
Bool
-SetDefaultFont(char *defaultfontname)
+SetDefaultFont(const char *defaultfontname)
{
int err;
FontPtr pf;
@@ -224,7 +224,7 @@ FreeFPE(FontPathElementPtr fpe)
fpe->refcount--;
if (fpe->refcount == 0) {
(*fpe_functions[fpe->type].free_fpe) (fpe);
- free(fpe->name);
+ free((void *) fpe->name);
free(fpe);
}
}
@@ -288,7 +288,7 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
if (err == FontNameAlias && alias) {
newlen = strlen(alias);
- newname = (char *) realloc(c->fontname, newlen);
+ newname = (char *) realloc((char *) c->fontname, newlen);
if (!newname) {
err = AllocError;
break;
@@ -368,14 +368,14 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
FreeFPE(c->fpe_list[i]);
}
free(c->fpe_list);
- free(c->fontname);
+ free((void *) c->fontname);
free(c);
return TRUE;
}
int
OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
- char *pfontname)
+ const char *pfontname)
{
OFclosurePtr c;
int i;
@@ -426,7 +426,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
*/
c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
if (!c->fpe_list) {
- free(c->fontname);
+ free((void *) c->fontname);
free(c);
return BadAlloc;
}
@@ -1537,7 +1537,7 @@ ImageText(ClientPtr client, DrawablePtr pDraw, GC * pGC, int nChars,
/* does the necessary magic to figure out the fpe type */
static int
-DetermineFPEType(char *pathname)
+DetermineFPEType(const char *pathname)
{
int i;
@@ -1633,21 +1633,23 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
}
/* if error or can't do it, act like it's a new one */
if (!fpe) {
+ char *name;
fpe = malloc(sizeof(FontPathElementRec));
if (!fpe) {
err = BadAlloc;
goto bail;
}
- fpe->name = malloc(len + 1);
- if (!fpe->name) {
+ name = malloc(len + 1);
+ if (!name) {
free(fpe);
err = BadAlloc;
goto bail;
}
fpe->refcount = 1;
- strncpy(fpe->name, (char *) cp, (int) len);
- fpe->name[len] = '\0';
+ strncpy(name, (char *) cp, (int) len);
+ name[len] = '\0';
+ fpe->name = name;
fpe->name_length = len;
fpe->type = DetermineFPEType(fpe->name);
if (fpe->type == -1)
@@ -1660,7 +1662,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
("[dix] Could not init font path element %s, removing from list!\n",
fpe->name);
}
- free(fpe->name);
+ free((void *) fpe->name);
free(fpe);
}
}
@@ -1712,9 +1714,10 @@ SetFontPath(ClientPtr client, int npaths, unsigned char *paths)
}
int
-SetDefaultFontPath(char *path)
+SetDefaultFontPath(const char *path)
{
- char *temp_path, *start, *end;
+ const char *start, *end;
+ char *temp_path;
unsigned char *cp, *pp, *nump, *newpath;
int num = 1, len, err, size = 0, bad;
diff --git a/dix/events.c b/dix/events.c
index 4aaa54c85..e198112eb 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2671,6 +2671,9 @@ DeliverOneEvent(InternalEvent *event, DeviceIntPtr dev, enum InputLevel level,
case CORE:
rc = EventToCore(event, &xE, &count);
break;
+ default:
+ rc = BadImplementation;
+ break;
}
if (rc == Success) {
@@ -3828,6 +3831,8 @@ MatchForType(const GrabPtr grab, GrabPtr tmp, enum InputLevel level,
match = CORE_MATCH;
ignore_device = TRUE;
break;
+ default:
+ return NO_MATCH;
}
tmp->grabtype = grabtype;
diff --git a/dix/extension.c b/dix/extension.c
index 6380db364..ede4bf5bd 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -96,7 +96,7 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
}
ext->name = strdup(name);
ext->num_aliases = 0;
- ext->aliases = (char **) NULL;
+ ext->aliases = (const char **) NULL;
if (!ext->name) {
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext);
@@ -106,7 +106,7 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
newexts = (ExtensionEntry **) realloc(extensions,
(i + 1) * sizeof(ExtensionEntry *));
if (!newexts) {
- free(ext->name);
+ free((void *) ext->name);
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext);
return ((ExtensionEntry *) NULL);
@@ -147,12 +147,12 @@ Bool
AddExtensionAlias(const char *alias, ExtensionEntry * ext)
{
char *name;
- char **aliases;
+ const char **aliases;
if (!ext)
return FALSE;
- aliases = (char **) realloc(ext->aliases,
- (ext->num_aliases + 1) * sizeof(char *));
+ aliases = realloc(ext->aliases,
+ (ext->num_aliases + 1) * sizeof(char *));
if (!aliases)
return FALSE;
ext->aliases = aliases;
@@ -229,9 +229,9 @@ CloseDownExtensions(void)
if (extensions[i]->CloseDown)
extensions[i]->CloseDown(extensions[i]);
NumExtensions = i;
- free(extensions[i]->name);
+ free((void *) extensions[i]->name);
for (j = extensions[i]->num_aliases; --j >= 0;)
- free(extensions[i]->aliases[j]);
+ free((void *) extensions[i]->aliases[j]);
free(extensions[i]->aliases);
dixFreePrivates(extensions[i]->devPrivates, PRIVATE_EXTENSION);
free(extensions[i]);
diff --git a/dix/getevents.c b/dix/getevents.c
index 14b65cabc..646c723ea 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1382,10 +1382,10 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
{
int num_events = 1;
DeviceEvent *event;
- RawDeviceEvent *raw;
+ RawDeviceEvent *raw = NULL;
double screenx = 0.0, screeny = 0.0; /* desktop coordinate system */
double devx = 0.0, devy = 0.0; /* desktop-wide in device coords */
- int sx, sy; /* for POINTER_SCREEN */
+ int sx = 0, sy = 0; /* for POINTER_SCREEN */
ValuatorMask mask;
ScreenPtr scr;
int num_barrier_events = 0;
@@ -1437,7 +1437,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
transformAbsolute(pDev, &mask);
clipAbsolute(pDev, &mask);
- if ((flags & POINTER_NORAW) == 0)
+ if ((flags & POINTER_NORAW) == 0 && raw)
set_raw_valuators(raw, &mask, raw->valuators.data);
}
else {
@@ -1445,7 +1445,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
if (flags & POINTER_ACCELERATE)
accelPointer(pDev, &mask, ms);
- if ((flags & POINTER_NORAW) == 0)
+ if ((flags & POINTER_NORAW) == 0 && raw)
set_raw_valuators(raw, &mask, raw->valuators.data);
moveRelative(pDev, flags, &mask);
@@ -1512,7 +1512,8 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
event_set_root_coordinates(event, screenx - scr->x, screeny - scr->y);
if (flags & POINTER_EMULATED) {
- raw->flags = XIPointerEmulated;
+ if (raw)
+ raw->flags = XIPointerEmulated;
event->flags = XIPointerEmulated;
}
diff --git a/dix/globals.c b/dix/globals.c
index ad9145b01..9738e9cdf 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -112,9 +112,9 @@ int defaultScreenSaverAllowExposures = DEFAULT_SCREEN_SAVER_EXPOSURES;
Bool screenSaverSuspended = FALSE;
#endif
-char *defaultFontPath = COMPILEDDEFAULTFONTPATH;
-char *defaultTextFont = COMPILEDDEFAULTFONT;
-char *defaultCursorFont = COMPILEDCURSORFONT;
+const char *defaultFontPath = COMPILEDDEFAULTFONTPATH;
+const char *defaultTextFont = COMPILEDDEFAULTFONT;
+const char *defaultCursorFont = COMPILEDCURSORFONT;
FontPtr defaultFont; /* not declared in dix.h to avoid including font.h in
every compilation of dix code */
CursorPtr rootCursor;
@@ -126,7 +126,7 @@ TimeStamp currentTime;
int defaultColorVisualClass = -1;
int monitorResolution = 0;
-char *display;
+const char *display;
int displayfd;
char *ConnectionInfo;
diff --git a/dix/window.c b/dix/window.c
index 0e9109e89..fad57fab0 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -227,7 +227,7 @@ log_window_info(WindowPtr pWin, int depth)
win_name = get_window_name(pWin);
ErrorF("win 0x%.8x (%s), [%d, %d] to [%d, %d]",
- pWin->drawable.id,
+ (unsigned) pWin->drawable.id,
win_name ? win_name : "no name",
pWin->drawable.x, pWin->drawable.y,
pWin->drawable.x + pWin->drawable.width,
@@ -240,7 +240,7 @@ log_window_info(WindowPtr pWin, int depth)
ErrorF(" (%s compositing: pixmap %x)",
(pWin->redirectDraw == RedirectDrawAutomatic) ?
"automatic" : "manual",
- pScreen->GetWindowPixmap(pWin)->drawable.id);
+ (unsigned) pScreen->GetWindowPixmap(pWin)->drawable.id);
#endif
switch (pWin->visibility) {
@@ -283,7 +283,7 @@ PrintWindowTree(void)
for (scrnum = 0; scrnum < screenInfo.numScreens; scrnum++) {
pScreen = screenInfo.screens[scrnum];
ErrorF("[dix] Dumping windows for screen %d (pixmap %x):\n", scrnum,
- pScreen->GetScreenPixmap(pScreen)->drawable.id);
+ (unsigned) pScreen->GetScreenPixmap(pScreen)->drawable.id);
pWin = pScreen->root;
depth = 1;
while (pWin) {