Commit d89b42bd authored by Keith Packard's avatar Keith Packard

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's avatarKeith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson's avatarAdam Jackson <ajax@redhat.com>
parent d6da9f23
......@@ -800,8 +800,8 @@ XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
}
int
xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
char *busID, int major, int minor, int patchLevel)
xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name,
const char *busID, int major, int minor, int patchLevel)
{
XvMCScreenPtr pScreenPriv = XVMC_GET_PRIVATE(pScreen);
......
......@@ -91,8 +91,8 @@ extern _X_EXPORT int XvMCScreenInit(ScreenPtr pScreen,
extern _X_EXPORT XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id);
extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, char *name,
char *busID, int major, int minor,
extern _X_EXPORT int xf86XvMCRegisterDRInfo(ScreenPtr pScreen, const char *name,
const char *busID, int major, int minor,
int patchLevel);
#endif /* _XVMC_H */
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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]);
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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) {
......
......@@ -47,7 +47,7 @@ typedef struct _OFclosure {
Mask flags;
/* XXX -- get these from request buffer instead? */
char *origFontName;
const char *origFontName;
int origFontNameLen;
XID fontid;
char *fontname;
......
......@@ -289,7 +289,10 @@ extern _X_EXPORT void
SetVendorRelease(int release);
extern _X_EXPORT void
SetVendorString(char *string);
SetVendorString(const char *string);
int
dix_main(int argc, char *argv[], char *envp[]);
/* events.c */
......
......@@ -34,7 +34,7 @@ SOFTWARE.
typedef struct _DIXFontProp *DIXFontPropPtr;
extern _X_EXPORT Bool SetDefaultFont(char * /*defaultfontname */ );
extern _X_EXPORT Bool SetDefaultFont(const char * /*defaultfontname */ );
extern _X_EXPORT void QueueFontWakeup(FontPathElementPtr /*fpe */ );
......@@ -48,7 +48,7 @@ extern _X_EXPORT int OpenFont(ClientPtr /*client */ ,
XID /*fid */ ,
Mask /*flags */ ,
unsigned /*lenfname */ ,
char * /*pfontname */ );
const char * /*pfontname */ );
extern _X_EXPORT int CloseFont(pointer /*pfont */ ,
XID /*fid */ );
......@@ -99,7 +99,7 @@ extern _X_EXPORT int SetFontPath(ClientPtr /*client */ ,
int /*npaths */ ,
unsigned char * /*paths */ );
extern _X_EXPORT int SetDefaultFontPath(char * /*path */ );
extern _X_EXPORT int SetDefaultFontPath(const char * /*path */ );
extern _X_EXPORT int GetFontPath(ClientPtr client,
int *count,
......
......@@ -58,14 +58,14 @@ typedef struct _ExtensionEntry {
int index;
void (*CloseDown) ( /* called at server shutdown */
struct _ExtensionEntry * /* extension */ );
char *name; /* extension name */
const char *name; /* extension name */
int base; /* base request number */
int eventBase;
int eventLast;
int errorBase;
int errorLast;
int num_aliases;
char **aliases;
const char **aliases;
pointer extPrivate;
unsigned short (*MinorOpcode) ( /* called for errors */
ClientPtr /* client */ );
......
......@@ -276,8 +276,8 @@ typedef struct _GC {
pointer clientClip;
unsigned long stateChanges; /* masked with GC_<kind> */
unsigned long serialNumber;
GCFuncs *funcs;
GCOps *ops;
const GCFuncs *funcs;
const GCOps *ops;
PrivateRec *devPrivates;
/*
* The following were moved here from private storage to allow device-
......
......@@ -18,7 +18,7 @@ extern _X_EXPORT CARD32 ScreenSaverInterval;
extern _X_EXPORT Bool screenSaverSuspended;
#endif
extern _X_EXPORT char *defaultFontPath;
extern _X_EXPORT const char *defaultFontPath;
extern _X_EXPORT int monitorResolution;
extern _X_EXPORT int defaultColorVisualClass;
......
......@@ -33,8 +33,8 @@ from The Open Group.
#include "globals.h"
extern _X_EXPORT char *defaultTextFont;
extern _X_EXPORT char *defaultCursorFont;
extern _X_EXPORT const char *defaultTextFont;
extern _X_EXPORT const char *defaultCursorFont;
extern _X_EXPORT int MaxClients;
extern _X_EXPORT volatile char isItTimeToYield;
extern _X_EXPORT volatile char dispatchException;
......@@ -49,7 +49,7 @@ extern _X_EXPORT int ScreenSaverBlanking;
extern _X_EXPORT int ScreenSaverAllowExposures;
extern _X_EXPORT int defaultScreenSaverBlanking;
extern _X_EXPORT int defaultScreenSaverAllowExposures;
extern _X_EXPORT char *display;
extern _X_EXPORT const char *display;
extern _X_EXPORT int displayfd;
extern _X_EXPORT int defaultBackingStore;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment