xserver: Branch 'master' - 19 commits

Keith Packard keithp at kemper.freedesktop.org
Wed Dec 8 11:51:18 PST 2010


 COPYING                                             |    2 
 composite/compalloc.c                               |    2 
 composite/compext.c                                 |    2 
 composite/compinit.c                                |    2 
 composite/compint.h                                 |    2 
 composite/compoverlay.c                             |    2 
 composite/compwindow.c                              |    2 
 config/hal.c                                        |   13 -
 config/udev.c                                       |   14 -
 configure.ac                                        |    4 
 dix/Xserver-dtrace.h.in                             |    2 
 dix/Xserver.d                                       |    2 
 dix/deprecated.c                                    |   30 +--
 dix/devices.c                                       |   17 +
 dix/dispatch.c                                      |    2 
 dix/dixfonts.c                                      |    4 
 dix/events.c                                        |    2 
 dix/resource.c                                      |    2 
 fb/fbcmap_mi.c                                      |    2 
 hw/dmx/dmx.c                                        |   10 -
 hw/dmx/dmxextension.c                               |   14 -
 hw/dmx/dmxgcops.c                                   |   10 -
 hw/dmx/dmxpict.c                                    |   54 +++--
 hw/dmx/dmxwindow.c                                  |   10 -
 hw/dmx/glxProxy/glxcmds.c                           |  182 +++++++++++++-------
 hw/dmx/glxProxy/glxext.c                            |    6 
 hw/xfree86/common/Makefile.am                       |    4 
 hw/xfree86/common/xf86AutoConfig.c                  |    4 
 hw/xfree86/common/xf86Config.c                      |   13 -
 hw/xfree86/common/xf86Configure.c                   |   33 +--
 hw/xfree86/common/xf86Helper.c                      |   15 -
 hw/xfree86/common/xf86Init.c                        |    3 
 hw/xfree86/common/xf86Option.c                      |    5 
 hw/xfree86/common/xf86ShowOpts.c                    |   10 -
 hw/xfree86/common/xf86pciBus.c                      |    4 
 hw/xfree86/common/xf86sbusBus.c                     |    6 
 hw/xfree86/dixmods/extmod/modinit.c                 |    5 
 hw/xfree86/dri/dri.c                                |    7 
 hw/xfree86/loader/loadmod.c                         |   18 -
 hw/xfree86/loader/sdksyms.sh                        |    1 
 hw/xfree86/modes/xf86Crtc.c                         |    8 
 hw/xfree86/modes/xf86Modes.c                        |    4 
 hw/xfree86/modes/xf86cvt.c                          |   10 -
 hw/xfree86/os-support/solaris/solaris-amd64.S       |    2 
 hw/xfree86/os-support/solaris/solaris-ia32.S        |    2 
 hw/xfree86/os-support/solaris/solaris-sparcv8plus.S |    2 
 hw/xfree86/os-support/solaris/sun_VTsw.c            |    2 
 hw/xfree86/os-support/solaris/sun_agp.c             |    2 
 hw/xfree86/os-support/solaris/sun_apm.c             |    2 
 hw/xfree86/os-support/solaris/sun_bell.c            |    2 
 hw/xfree86/os-support/solaris/sun_vid.c             |    2 
 hw/xfree86/parser/Flags.c                           |   13 -
 hw/xfree86/parser/Makefile.am                       |    1 
 hw/xfree86/parser/Pointer.c                         |   16 -
 hw/xfree86/ramdac/Makefile.am                       |    4 
 hw/xfree86/utils/cvt/Makefile.am                    |    7 
 hw/xfree86/utils/cvt/cvt.c                          |   18 +
 hw/xfree86/utils/gtf/Makefile.am                    |    2 
 hw/xfree86/vbe/vbeModes.c                           |    4 
 hw/xfree86/xaa/Makefile.am                          |   52 ++---
 hw/xwin/win.h                                       |    7 
 hw/xwin/windialogs.c                                |    5 
 hw/xwin/winerror.c                                  |   24 +-
 include/Makefile.am                                 |    1 
 include/Xprintf.h                                   |   69 +++++++
 include/dix-config.h.in                             |    3 
 include/os.h                                        |   13 -
 mi/micmap.c                                         |    2 
 os/access.c                                         |    2 
 os/log.c                                            |   12 -
 os/xprintf.c                                        |  170 ++++++++++++++++--
 render/render.c                                     |    8 
 xfixes/cursor.c                                     |    2 
 xfixes/xfixes.c                                     |    2 
 xfixes/xfixesint.h                                  |    2 
 xkb/ddxList.c                                       |   43 ++--
 xkb/ddxLoad.c                                       |   19 +-
 77 files changed, 670 insertions(+), 391 deletions(-)

New commits:
commit 2c70b650b342378898064cf27e2f95c4b2e53d24
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Dec 8 18:54:30 2010 +0000

    Fix Xwin build after af0f9f91
    
    Fix damage to XWIN_LIBS in commit af0f9f913398d34a885c3fb4e8d40c1a7e2b3ee9
    "Move some sync code to miext", which broke the XWin build
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index d2318da..38158f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1888,7 +1888,7 @@ if test "x$XWIN" = xyes; then
 			XWIN_SYS_LIBS=-lwinsock2
 			;;
 	esac
-	XWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $RANDR_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $OS_LIB"
+	XWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $RANDR_LIB $RENDER_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $OS_LIB"
 	XWIN_SYS_LIBS="$XWIN_SYS_LIBS $XWINMODULES_LIBS"
 	AC_SUBST(XWIN_LIBS)
 	AC_SUBST(XWIN_SERVER_NAME)
commit 519d243f0c8e3c80226701f71d2cfa62e42dbff7
Merge: 9f9c732... 446482e...
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Dec 7 13:39:58 2010 -0800

    Merge remote branch 'alanc/master'

commit 446482efaa3d266266e2a143492a3ec0523622bd
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sun Nov 28 09:41:17 2010 -0800

    Convert cvt code to use XNFasprintf()
    
    Requires linking xprintf.c into standalone cvt utility
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xfree86/modes/xf86cvt.c b/hw/xfree86/modes/xf86cvt.c
index 1da5fe5..244f3b9 100644
--- a/hw/xfree86/modes/xf86cvt.c
+++ b/hw/xfree86/modes/xf86cvt.c
@@ -279,15 +279,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
     if (Interlaced)
         Mode->VTotal *= 2;
 
-    {
-        char  Name[256];
-        Name[0] = 0;
-
-        snprintf(Name, 256, "%dx%d", HDisplay, VDisplay);
-
-        Mode->name = xnfalloc(strlen(Name) + 1);
-        memcpy(Mode->name, Name, strlen(Name) + 1);
-    }
+    XNFasprintf(&Mode->name, "%dx%d", HDisplay, VDisplay);
 
     if (Reduced)
         Mode->Flags |= V_PHSYNC | V_NVSYNC;
diff --git a/hw/xfree86/utils/cvt/Makefile.am b/hw/xfree86/utils/cvt/Makefile.am
index 0658682..ba02145 100644
--- a/hw/xfree86/utils/cvt/Makefile.am
+++ b/hw/xfree86/utils/cvt/Makefile.am
@@ -27,7 +27,10 @@ INCLUDES = $(XORG_INCS) \
 	   -I$(top_srcdir)/hw/xfree86/parser
 
 # gah
-cvt_SOURCES = cvt.c $(top_srcdir)/hw/xfree86/modes/xf86cvt.c
+cvt_SOURCES = cvt.c \
+	$(top_srcdir)/hw/xfree86/modes/xf86cvt.c \
+	$(top_srcdir)/os/xprintf.c
+
 cvt_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
 
 man1_MANS = cvt.man
diff --git a/hw/xfree86/utils/cvt/cvt.c b/hw/xfree86/utils/cvt/cvt.c
index cf0a479..fff500b 100644
--- a/hw/xfree86/utils/cvt/cvt.c
+++ b/hw/xfree86/utils/cvt/cvt.c
@@ -25,6 +25,24 @@
 
 #include "xf86.h"
 
+/* Error implementation used by the server code we built in */
+void
+Error(const char *str)
+{
+    perror(str);
+}
+
+/* FatalError implementation used by the server code we built in */
+void
+FatalError(const char *f, ...)
+{
+    va_list args;
+    va_start(args, f);
+    vfprintf(stderr, f, args);
+    va_end(args);
+    exit(1);
+}
+
 /* xnfalloc implementation used by the server code we built in */
 pointer
 XNFalloc(unsigned long n)
commit d2c42b102707db6c1ca9dccc4de9210a43650cb1
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Nov 27 23:10:46 2010 -0800

    Replace alloc+strcpy+strcat with asprintf() & XNFasprintf() calls
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/dix/devices.c b/dix/devices.c
index 708860a..6c0dc42 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2524,9 +2524,11 @@ AllocDevicePair (ClientPtr client, char* name,
     if (!pointer)
         return BadAlloc;
 
-    pointer->name = calloc(strlen(name) + strlen(" pointer") + 1, sizeof(char));
-    strcpy(pointer->name, name);
-    strcat(pointer->name, " pointer");
+    if (asprintf(&pointer->name, "%s pointer", name) == -1) {
+        pointer->name = NULL;
+        RemoveDevice(pointer, FALSE);
+        return BadAlloc;
+    }
 
     pointer->public.processInputProc = ProcessOtherEvent;
     pointer->public.realInputProc = ProcessOtherEvent;
@@ -2547,9 +2549,12 @@ AllocDevicePair (ClientPtr client, char* name,
         return BadAlloc;
     }
 
-    keyboard->name = calloc(strlen(name) + strlen(" keyboard") + 1, sizeof(char));
-    strcpy(keyboard->name, name);
-    strcat(keyboard->name, " keyboard");
+    if (asprintf(&keyboard->name, "%s keyboard", name) == -1) {
+        keyboard->name = NULL;
+        RemoveDevice(keyboard, FALSE);
+        RemoveDevice(pointer, FALSE);
+        return BadAlloc;
+    }
 
     keyboard->public.processInputProc = ProcessOtherEvent;
     keyboard->public.realInputProc = ProcessOtherEvent;
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 5f3b8e8..49d8fa8 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -208,9 +208,7 @@ xf86ValidateFontPath(char *path)
 	continue;
       }
       else {
-	p1 = xnfalloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
-	strcpy(p1, dir_elem);
-	strcat(p1, DIR_FILE);
+	XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE);
 	flag = stat(p1, &stat_buf);
 	if (flag == 0)
 	  if (!S_ISREG(stat_buf.st_mode))
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index af39b2b..d49aa31 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -638,13 +638,10 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
 	    newn = n + 2;
 	} else {
 	    free(n);
-	    n = malloc(strlen(p->name) + 2 + 1);
-	    if (!n) {
+	    if (asprintf(&n, "No%s", p->name) == -1) {
 		p->found = FALSE;
 		return FALSE;
 	    }
-	    strcpy(n, "No");
-	    strcat(n, p->name);
 	    newn = n;
 	}
 	if ((s = xf86findOptionValue(options, newn)) != NULL) {
diff --git a/hw/xfree86/common/xf86ShowOpts.c b/hw/xfree86/common/xf86ShowOpts.c
index ce86090..c0fa80a 100644
--- a/hw/xfree86/common/xf86ShowOpts.c
+++ b/hw/xfree86/common/xf86ShowOpts.c
@@ -97,11 +97,8 @@ void DoShowOptions (void) {
 				);
 				continue;                                                       
 			}
-			pSymbol = malloc(
-				strlen(xf86DriverList[i]->driverName) + strlen("ModuleData") + 1
-			);
-			strcpy (pSymbol, xf86DriverList[i]->driverName);
-			strcat (pSymbol, "ModuleData");
+			XNFasprintf(&pSymbol, "%sModuleData",
+				    xf86DriverList[i]->driverName);
 			initData = LoaderSymbol (pSymbol);
 			if (initData) {
 				XF86ModuleVersionInfo *vers = initData->vers;
diff --git a/hw/xfree86/dixmods/extmod/modinit.c b/hw/xfree86/dixmods/extmod/modinit.c
index f4e922c..168795d 100644
--- a/hw/xfree86/dixmods/extmod/modinit.c
+++ b/hw/xfree86/dixmods/extmod/modinit.c
@@ -146,11 +146,8 @@ extmodSetup(pointer module, pointer opts, int *errmaj, int *errmin)
     for (i = 0; extensionModules[i].name != NULL; i++) {
 	if (opts) {
 	    char *s;
-	    s = (char *)malloc(strlen(extensionModules[i].name) + 5);
-	    if (s) {
+	    if (Xasprinf(&s, "omit%s", extensionModules[i].name) != -1) {
 		pointer o;
-		strcpy(s, "omit");
-		strcat(s, extensionModules[i].name);
 		o = xf86FindOption(opts, s);
 		free(s);
 		if (o) {
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 1f6933a..3b3511c 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -933,16 +933,14 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
      * now check if the special data object <modulename>ModuleData is
      * present.
      */
-    p = malloc(strlen(name) + strlen("ModuleData") + 1);
-    if (!p) {
+    if (asprintf(&p, "%sModuleData", name) == -1) {
+	p = NULL;
 	if (errmaj)
 	    *errmaj = LDR_NOMEM;
 	if (errmin)
 	    *errmin = 0;
 	goto LoadModule_fail;
     }
-    strcpy(p, name);
-    strcat(p, "ModuleData");
     initdata = LoaderSymbol(p);
     if (initdata) {
 	ModuleSetupProc setup;
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 08d384f..c4470c3 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -510,7 +510,6 @@ static void
 xf86OutputSetMonitor (xf86OutputPtr output)
 {
     char    *option_name;
-    static const char monitor_prefix[] = "monitor-";
     char    *monitor;
 
     if (!output->name)
@@ -520,11 +519,8 @@ xf86OutputSetMonitor (xf86OutputPtr output)
 
     output->options = xnfalloc (sizeof (xf86OutputOptions));
     memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions));
-    
-    option_name = xnfalloc (strlen (monitor_prefix) +
-			    strlen (output->name) + 1);
-    strcpy (option_name, monitor_prefix);
-    strcat (option_name, output->name);
+
+    XNFasprintf(&option_name, "monitor-%s", output->name);
     monitor = xf86findOptionValue (output->scrn->options, option_name);
     if (!monitor)
 	monitor = output->name;
commit 3a9bb93dd178084f4ff1abcea331ca5a62f88ce6
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Nov 27 22:38:27 2010 -0800

    Convert alloc+sprintf pairs into asprintf() & XNFasprintf() calls
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/config/hal.c b/config/hal.c
index 5e35911..0b848a0 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -63,10 +63,8 @@ device_removed(LibHalContext *ctx, const char *udi)
 {
     char *value;
 
-    value = malloc(strlen(udi) + 5); /* "hal:" + NULL */
-    if (!value)
+    if (asprintf (&value, "hal:%s", udi) == -1)
         return;
-    sprintf(value, "hal:%s", udi);
 
     remove_devices("hal", value);
 
@@ -228,12 +226,11 @@ device_added(LibHalContext *hal_ctx, const char *udi)
     add_option(&options, "driver", driver);
     add_option(&options, "name", name);
 
-    config_info = malloc(strlen(udi) + 5); /* "hal:" and NULL */
-    if (!config_info) {
+    if (asprintf (&config_info, "hal:%s", udi) == -1) {
+        config_info = NULL;
         LogMessage(X_ERROR, "config/hal: couldn't allocate name\n");
         goto unwind;
     }
-    sprintf(config_info, "hal:%s", udi);
 
     /* Check for duplicate devices */
     if (device_is_duplicate(config_info))
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 7235c61..b89f701 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -205,12 +205,9 @@ configureScreenSection (int screennum)
     int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
     parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
 
-    ptr->scrn_identifier = malloc(18);
-    sprintf(ptr->scrn_identifier, "Screen%d", screennum);
-    ptr->scrn_monitor_str = malloc(19);
-    sprintf(ptr->scrn_monitor_str, "Monitor%d", screennum);
-    ptr->scrn_device_str = malloc(16);
-    sprintf(ptr->scrn_device_str, "Card%d", screennum);
+    XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
+    XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum);
+    XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum);
 
     for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
     {
@@ -256,14 +253,13 @@ optionTypeToString(OptionValueType type)
 static XF86ConfDevicePtr
 configureDeviceSection (int screennum)
 {
-    char identifier[16];
     OptionInfoPtr p;
     int i = 0;
     parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
 
     /* Move device info to parser structure */
-    sprintf(identifier, "Card%d", screennum);
-    ptr->dev_identifier = strdup(identifier);
+    if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
+        ptr->dev_identifier = NULL;
     ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
     ptr->dev_busid = DevToConfig[screennum].GDev.busID;
     ptr->dev_driver = DevToConfig[screennum].GDev.driver;
@@ -306,10 +302,8 @@ configureDeviceSection (int screennum)
 		int len = strlen(ptr->dev_comment) + strlen(prefix) +
 			  strlen(middle) + strlen(suffix) + 1;
 		
-		optname = malloc(strlen(p->name) + 2 + 1);
-		if (!optname)
+		if (asprintf(&optname, "\"%s\"", p->name) == -1)
 		    break;
-		sprintf(optname, "\"%s\"", p->name);
 
 		len += max(20, strlen(optname));
 		len += strlen(opttype);
@@ -370,16 +364,14 @@ configureLayoutSection (void)
 	aptr->adj_x = 0;
 	aptr->adj_y = 0;
 	aptr->adj_scrnum = scrnum;
-	aptr->adj_screen_str = xnfalloc(18);
-	sprintf(aptr->adj_screen_str, "Screen%d", scrnum);
+	XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
 	if (scrnum == 0) {
 	    aptr->adj_where = CONF_ADJ_ABSOLUTE;
 	    aptr->adj_refscreen = NULL;
 	}
 	else {
 	    aptr->adj_where = CONF_ADJ_RIGHTOF;
-	    aptr->adj_refscreen = xnfalloc(18);
-	    sprintf(aptr->adj_refscreen, "Screen%d", scrnum - 1);
+	    XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
 	}
     	ptr->lay_adjacency_lst =
 	    (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
@@ -443,8 +435,7 @@ configureMonitorSection (int screennum)
 {
     parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
 
-    ptr->mon_identifier = malloc(19);
-    sprintf(ptr->mon_identifier, "Monitor%d", screennum);
+    XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
     ptr->mon_vendor = strdup("Monitor Vendor");
     ptr->mon_modelname = strdup("Monitor Model");
 
@@ -491,11 +482,9 @@ configureDDCMonitorSection (int screennum)
 
     parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
 
-    ptr->mon_identifier = malloc(19);
-    sprintf(ptr->mon_identifier, "Monitor%d", screennum);
+    XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
     ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
-    ptr->mon_modelname = malloc(12);
-    sprintf(ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
+    XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
 
     /* features in centimetres, we want millimetres */
     mon_width  = 10 * ConfiguredMonitor->features.hsize ;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index ce14454..9e2ffaa 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1284,11 +1284,8 @@ xf86LogInit(void)
     /* Get the log file name */
     if (xf86LogFileFrom == X_DEFAULT) {
 	/* Append the display number and ".log" */
-	lf = malloc(strlen(xf86LogFile) + strlen("%s") +
-		    strlen(LOGSUFFIX) + 1);
-	if (!lf)
+	if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1)
 	    FatalError("Cannot allocate space for the log file name\n");
-	sprintf(lf, "%s%%s" LOGSUFFIX, xf86LogFile);
 	xf86LogFile = lf;
     }
 
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index ef90fa5..78f51e1 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -536,8 +536,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 
     for (i = 0; i < xf86NumScreens; i++) {
       if (xf86Screens[i]->name == NULL) {
-	xf86Screens[i]->name = xnfalloc(strlen("screen") + 10 + 1);
-	sprintf(xf86Screens[i]->name, "screen%d", i);
+	XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
 	xf86MsgVerb(X_WARNING, 0,
 		    "Screen driver %d has no name set, using `%s'.\n",
 		    i, xf86Screens[i]->name);
diff --git a/hw/xfree86/common/xf86ShowOpts.c b/hw/xfree86/common/xf86ShowOpts.c
index eac25d7..ce86090 100644
--- a/hw/xfree86/common/xf86ShowOpts.c
+++ b/hw/xfree86/common/xf86ShowOpts.c
@@ -111,6 +111,9 @@ void DoShowOptions (void) {
 				);
 				for (p = pOption; p->name != NULL; p++) {
 					const char *opttype = optionTypeToSting(p->type);
+					/* XXX: Why overallocate by 2 bytes?
+					 * Otherwise, this would be strdup()
+					 */
 					char *optname = malloc(strlen(p->name) + 2 + 1);
 					if (!optname) {
 						continue;                      
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index d689832..447b192 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -1347,9 +1347,9 @@ xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
 
     pVideo = (struct pci_device *) busData;
 
-    GDev->busID = xnfalloc(16);
     xf86FormatPciBusNumber(pVideo->bus, busnum);
-    sprintf(GDev->busID, "PCI:%s:%d:%d", busnum, pVideo->dev, pVideo->func);
+    XNFasprintf(&GDev->busID, "PCI:%s:%d:%d",
+		busnum, pVideo->dev, pVideo->func);
 
     GDev->chipID = pVideo->device_id;
     GDev->chipRev = pVideo->revision;
diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c
index d7c928b..8cfac84 100644
--- a/hw/xfree86/common/xf86sbusBus.c
+++ b/hw/xfree86/common/xf86sbusBus.c
@@ -706,11 +706,9 @@ xf86SbusConfigureNewDev(void *busData, sbusDevicePtr sBus, GDevRec *GDev)
         sparcPromClose();
     }
     if (promPath) {
-        GDev->busID = xnfalloc(strlen(promPath) + 6);
-        sprintf(GDev->busID, "SBUS:%s", promPath);
+        XNFasprintf(&GDev->busID, "SBUS:%s", promPath);
         free(promPath);
     } else {
-        GDev->busID = xnfalloc(12);
-        sprintf(GDev->busID, "SBUS:fb%d", sBus->fbNum);
+        XNFsprintf(&GDev->busID, "SBUS:fb%d", sBus->fbNum);
     }
 }
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index fe99a2d..1d83630 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -2426,13 +2426,10 @@ DRICreatePCIBusID(const struct pci_device * dev)
 {
     char *busID;
 
-    busID = malloc(20);
-    if (busID == NULL)
+    if (asprintf(&busID, "pci:%04x:%02x:%02x.%d",
+		 dev->domain, dev->bus, dev->dev, dev->func) == -1)
 	return NULL;
 
-    snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", dev->domain, dev->bus,
-	dev->dev, dev->func);
-
     return busID;
 }
 
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 06d082b..1f6933a 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -406,22 +406,22 @@ FindModuleInSubdir(const char *dirpath, const char *module)
  
         snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
         if (strcmp(direntry->d_name, tmpBuf) == 0) {
-            ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
-            sprintf(ret, "%s%s", dirpath, tmpBuf);
+            if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
+		ret = NULL;
             break;
         }
 
         snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module);
         if (strcmp(direntry->d_name, tmpBuf) == 0) {
-            ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
-            sprintf(ret, "%s%s", dirpath, tmpBuf);
+            if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
+		ret = NULL;
             break;
         }
 
         snprintf(tmpBuf, PATH_MAX, "%s.so", module);
         if (strcmp(direntry->d_name, tmpBuf) == 0) {
-            ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
-            sprintf(ret, "%s%s", dirpath, tmpBuf);
+            if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1)
+		ret = NULL;
             break;
         }
     }
diff --git a/hw/xfree86/vbe/vbeModes.c b/hw/xfree86/vbe/vbeModes.c
index 3f2cae5..ea24b61 100644
--- a/hw/xfree86/vbe/vbeModes.c
+++ b/hw/xfree86/vbe/vbeModes.c
@@ -356,8 +356,8 @@ VBESetModeNames(DisplayModePtr pMode)
 		pMode->VDisplay > 10000 || pMode->VDisplay < 0) {
 		pMode->name = strdup("BADMODE");
 	    } else {
-		pMode->name = xnfalloc(4 + 1 + 4 + 1);
-		sprintf(pMode->name, "%dx%d", pMode->HDisplay, pMode->VDisplay);
+		XNFasprintf(&pMode->name, "%dx%d",
+			    pMode->HDisplay, pMode->VDisplay);
 	    }
 	}
 	pMode = pMode->next;
diff --git a/os/log.c b/os/log.c
index 1ad87df..65195ba 100644
--- a/os/log.c
+++ b/os/log.c
@@ -177,10 +177,8 @@ LogInit(const char *fname, const char *backup)
     char *logFileName = NULL;
 
     if (fname && *fname) {
-	logFileName = malloc(strlen(fname) + strlen(display) + 1);
-	if (!logFileName)
+	if (asprintf(&logFileName, fname, display) == -1)
 	    FatalError("Cannot allocate space for the log file name\n");
-	sprintf(logFileName, fname, display);
 
 	if (backup && *backup) {
 	    struct stat buf;
@@ -189,13 +187,9 @@ LogInit(const char *fname, const char *backup)
 		char *suffix;
 		char *oldLog;
 
-		oldLog = malloc(strlen(logFileName) + strlen(backup) +
-				strlen(display) + 1);
-		suffix = malloc(strlen(backup) + strlen(display) + 1);
-		if (!oldLog || !suffix)
+		if ((asprintf(&suffix, backup, display) == -1) ||
+		    (asprintf(&oldLog, "%s%s", logFileName, suffix) == -1))
 		    FatalError("Cannot allocate space for the log file name\n");
-		sprintf(suffix, backup, display);
-		sprintf(oldLog, "%s%s", logFileName, suffix);
 		free(suffix);
 		if (rename(logFileName, oldLog) == -1) {
 		    FatalError("Cannot move old log file \"%s\" to \"%s\"\n",
commit 2416255f7e3fd9190a9e01bda57c992932de4bd9
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Nov 27 22:36:44 2010 -0800

    Convert hw/xfree86/parser code to use asprintf() calls
    
    Requires linking xprintf.c into libxf86config for those who build it.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c
index a9149c2..7a0794b 100644
--- a/hw/xfree86/parser/Flags.c
+++ b/hw/xfree86/parser/Flags.c
@@ -61,8 +61,8 @@
 #include "xf86Parser.h"
 #include "xf86tokens.h"
 #include "Configint.h"
-#include <math.h>
 #include <X11/Xfuncproto.h>
+#include "Xprintf.h"
 
 extern LexRec val;
 
@@ -143,9 +143,8 @@ xf86parseFlagsSection (void)
 							} else {
 								if (tokentype != NUMBER)
 									Error (NUMBER_MSG, tmp);
-								valstr = malloc(16);
-								if (valstr)
-									sprintf(valstr, "%d", val.num);
+								if (asprintf(&valstr, "%d", val.num) == -1)
+									valstr = NULL;
 							}
 						}
 						ptr->flg_option_lst = xf86addNewOption
@@ -426,13 +425,9 @@ char *
 xf86uLongToString(unsigned long i)
 {
 	char *s;
-	int l;
 
-	l = ceil(log10((double)i) + 2.5);
-	s = malloc(l);
-	if (!s)
+	if (asprintf(&s, "%lu", i) == -1)
 		return NULL;
-	sprintf(s, "%lu", i);
 	return s;
 }
 
diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am
index caf7079..a5adc01 100644
--- a/hw/xfree86/parser/Makefile.am
+++ b/hw/xfree86/parser/Makefile.am
@@ -31,6 +31,7 @@ libxf86config_internal_la_SOURCES = \
 	$(INTERNAL_SOURCES)
 
 libxf86config_a_SOURCES = \
+	$(TOP_SRCDIR)/os/xprintf.c \
 	$(INTERNAL_SOURCES)
 libxf86config_a_CFLAGS = $(AM_CFLAGS)
 
diff --git a/hw/xfree86/parser/Pointer.c b/hw/xfree86/parser/Pointer.c
index 56a26ba..65397cd 100644
--- a/hw/xfree86/parser/Pointer.c
+++ b/hw/xfree86/parser/Pointer.c
@@ -62,6 +62,7 @@
 #include "xf86Parser.h"
 #include "xf86tokens.h"
 #include "Configint.h"
+#include "Xprintf.h"
 
 extern LexRec val;
 
@@ -99,8 +100,8 @@ static xf86ConfigSymTabRec ZMapTab[] =
 XF86ConfInputPtr
 xf86parsePointerSection (void)
 {
-	char *s, *s1, *s2;
-	int l;
+	char *s;
+	unsigned long val1;
 	int token;
 	parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
 
@@ -184,17 +185,12 @@ xf86parsePointerSection (void)
 			case NUMBER:
 				if (val.num < 0)
 					Error (ZAXISMAPPING_MSG, NULL);
-				s1 = xf86uLongToString(val.num);
+				val1 = val.num;
 				if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER || val.num < 0) {
-					free(s1);
 					Error (ZAXISMAPPING_MSG, NULL);
 				}
-				s2 = xf86uLongToString(val.num);
-				l = strlen(s1) + 1 + strlen(s2) + 1;
-				s = malloc(l);
-				sprintf(s, "%s %s", s1, s2);
-				free(s1);
-				free(s2);
+				if (asprintf(&s, "%ul %ul", val1, val.num) == -1)
+				    s = NULL;
 				break;
 			case XAXIS:
 				s = strdup("x");
commit 03e8bfa1d122f7dea905d48c93cfd54afd991dfd
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Nov 27 20:09:04 2010 -0800

    Convert existing Xprintf style calls to asprintf style
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/config/hal.c b/config/hal.c
index 6e2850c..5e35911 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -200,7 +200,9 @@ device_added(LibHalContext *hal_ctx, const char *udi)
                        "config/hal: getting usb.product_id on %s "
                        "returned %04x\n", parent, usb_product);
         if (usb_vendor && usb_product)
-            attrs.usb_id = Xprintf("%04x:%04x", usb_vendor, usb_product);
+            if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_product)
+		== -1)
+		attrs.usb_id = NULL;
 
         free(parent);
     }
diff --git a/config/udev.c b/config/udev.c
index 31f4f80..496bfbf 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -108,8 +108,10 @@ device_added(struct udev_device *udev_device)
 
         /* construct USB ID in lowercase hex - "0000:ffff" */
         if (product && sscanf(product, "%*x/%4x/%4x/%*x", &usb_vendor, &usb_model) == 2) {
-            attrs.usb_id = Xprintf("%04x:%04x", usb_vendor, usb_model);
-            if (attrs.usb_id)
+            if (asprintf(&attrs.usb_id, "%04x:%04x", usb_vendor, usb_model)
+                == -1)
+                attrs.usb_id = NULL;
+            else
                 LOG_PROPERTY(path, "PRODUCT", product);
         }
     }
@@ -127,9 +129,10 @@ device_added(struct udev_device *udev_device)
     LOG_PROPERTY(path, "ID_INPUT.tags", tags_prop);
     attrs.tags = xstrtokenize(tags_prop, ",");
 
-    config_info = Xprintf("udev:%s", syspath);
-    if (!config_info)
+    if (asprintf(&config_info, "udev:%s", syspath) == -1) {
+        config_info = NULL;
         goto unwind;
+    }
 
     if (device_is_duplicate(config_info)) {
         LogMessage(X_WARNING, "config/udev: device %s already added. "
@@ -217,8 +220,7 @@ device_removed(struct udev_device *device)
     char *value;
     const char *syspath = udev_device_get_syspath(device);
 
-    value = Xprintf("udev:%s", syspath);
-    if (!value)
+    if (asprintf(&value, "udev:%s", syspath) == -1)
         return;
 
     remove_devices("udev", value);
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index ccb4627..bd1ad30 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1817,7 +1817,9 @@ SetDefaultFontPath(char *path)
 	start = end;
     }
     if (!start) {
-	temp_path = Xprintf("%s%sbuilt-ins", path, *path ? "," : "");
+	if (asprintf(&temp_path, "%s%sbuilt-ins", path, *path ? "," : "")
+	    == -1)
+	    temp_path = NULL;
     } else {
 	temp_path = strdup(path);
     }
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 3cd5ef6..eb61f87 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -297,8 +297,8 @@ copyScreen(confScreenPtr oscreen, GDevPtr odev, int i, char *driver)
     }
     memcpy(cptr, odev, sizeof(GDevRec));
 
-    cptr->identifier = Xprintf("Autoconfigured Video Device %s", driver);
-    if (!cptr->identifier) {
+    if (asprintf(&cptr->identifier, "Autoconfigured Video Device %s", driver)
+        == -1) {
         free(cptr);
         free(nscreen);
         return FALSE;
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index ae9592e..5f3b8e8 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -585,12 +585,11 @@ configFiles(XF86ConfFilesPtr fileconf)
     else if (fileconf && fileconf->file_fontpath) {
 	pathFrom = X_CONFIG;
 	if (xf86Info.useDefaultFontPath) {
-	    defaultFontPath = Xprintf("%s%s%s",
-				      fileconf->file_fontpath,
-				      *temp_path ? "," : "", temp_path);
-	    if (defaultFontPath != NULL) {
+	    if (asprintf(&defaultFontPath, "%s%s%s", fileconf->file_fontpath,
+			 *temp_path ? "," : "", temp_path) == -1)
+		defaultFontPath = NULL;
+	    else
 		must_copy = FALSE;
-	    }
 	}
 	else
 	    defaultFontPath = fileconf->file_fontpath;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 01f9864..ce14454 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1193,9 +1193,13 @@ xf86VIDrvMsgVerb(InputInfoPtr dev, MessageType type, int verb, const char *forma
 {
     char *msg;
 
-    msg = Xprintf("%s: %s: %s", dev->drv->driverName, dev->name, format);
-    LogVMessageVerb(type, verb, msg, args);
-    free(msg);
+    if (asprintf(&msg, "%s: %s: %s", dev->drv->driverName, dev->name, format)
+	== -1) {
+	LogVMessageVerb(type, verb, "%s", args);
+    } else {
+	LogVMessageVerb(type, verb, msg, args);
+	free(msg);
+    }
 }
 
 /* Print input driver message, with verbose level specified directly */
diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index 51eb4c9..75584cf 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -132,8 +132,8 @@ xf86SetModeDefaultName(DisplayModePtr mode)
 
     free(mode->name);
 
-    mode->name = XNFprintf("%dx%d%s", mode->HDisplay, mode->VDisplay,
-			   interlaced ? "i" : "");
+    XNFasprintf(&mode->name, "%dx%d%s", mode->HDisplay, mode->VDisplay,
+		interlaced ? "i" : "");
 }
 
 /*
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index f22a2d5..4430781 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -221,9 +221,10 @@ if (fDebugProcMsg) \
 { \
   char *pszTemp; \
   int iLength; \
-  pszTemp = Xprintf (str, ##__VA_ARGS__); \
-  MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \
-  free(pszTemp); \
+  if (asprintf (&pszTemp, str, ##__VA_ARGS__) != -1) { \
+    MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \
+    free (pszTemp); \
+  } \
 }
 #else
 #define DEBUG_MSG(str,...)
diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c
index 22d8cd7..679b3fa 100644
--- a/hw/xwin/windialogs.c
+++ b/hw/xwin/windialogs.c
@@ -341,11 +341,10 @@ winExitDlgProc (HWND hDialog, UINT message,
 	winInitDialog (hDialog);
 
 	/* Format the connected clients string */
-	pszConnectedClients = Xprintf (CONNECTED_CLIENTS_FORMAT,
+	if (asprintf (&pszConnectedClients, CONNECTED_CLIENTS_FORMAT,
            (s_pScreenPriv->iConnectedClients == 1) ? "is" : "are",
             s_pScreenPriv->iConnectedClients,
-           (s_pScreenPriv->iConnectedClients == 1) ? "" : "s");
-	if (!pszConnectedClients)
+           (s_pScreenPriv->iConnectedClients == 1) ? "" : "s") == -1)
 	    return TRUE;
      
         
diff --git a/hw/xwin/winerror.c b/hw/xwin/winerror.c
index aadfd28..5e32d09 100644
--- a/hw/xwin/winerror.c
+++ b/hw/xwin/winerror.c
@@ -101,12 +101,15 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
   char *	pszErrorF = NULL;
   char *	pszMsgBox = NULL;
   va_list	args;
+  int		size;
 
   va_start(args, uType);
-  pszErrorF = Xvprintf(pszError, args);
+  size = vasprintf (&pszErrorF, pszError, args);
   va_end(args);
-  if (!pszErrorF)
+  if (size == -1) {
+    pszErrorF = NULL;
     goto winMessageBoxF_Cleanup;
+  }
 
 #define MESSAGEBOXF \
 	"%s\n" \
@@ -117,15 +120,18 @@ winMessageBoxF (const char *pszError, UINT uType, ...)
 	"XWin was started with the following command-line:\n\n" \
 	"%s\n"
 
-  pszMsgBox = Xprintf (MESSAGEBOXF,
-                       pszErrorF, XVENDORNAME,
-		       XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP, XORG_VERSION_CURRENT,
-		       BUILDERADDR,
-		       BUILDERSTRING,
-		       g_pszCommandLine);
+  size = asprintf (&pszMsgBox, MESSAGEBOXF,
+		   pszErrorF, XVENDORNAME,
+		   XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH,
+		    XORG_VERSION_SNAP, XORG_VERSION_CURRENT,
+		   BUILDERADDR,
+		   BUILDERSTRING,
+		   g_pszCommandLine);
 
-  if (!pszMsgBox)
+  if (size == -1) {
+    pszMsgBox = NULL;
     goto winMessageBoxF_Cleanup;
+  }
 
   /* Display the message box string */
   MessageBox (NULL,
diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index c1ada5c..9623cb6 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -156,34 +156,45 @@ char	tmpname[PATH_MAX];
 #endif
     if (XkbBaseDirectory!=NULL) {
 	if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) {
-	    buf = Xprintf("%s/%s.dir",XkbBaseDirectory,componentDirs[what]);
-	    in= fopen(buf,"r");
+	    if (asprintf(&buf, "%s/%s.dir", XkbBaseDirectory,
+			 componentDirs[what]) == -1)
+		buf = NULL;
+	    else
+		in = fopen(buf,"r");
 	}
 	if (!in) {
 	    haveDir= FALSE;
 	    free(buf);
-	    buf = Xprintf(
-		"'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg,
-                XkbBinDirectory,XkbBaseDirectory,componentDirs[what],(long)
-		((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)),
-		file W32_tmpfile
-                );
+	    if (asprintf
+		(&buf,
+		 "'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg,
+		 XkbBinDirectory, XkbBaseDirectory, componentDirs[what],
+		 (long) ((xkbDebugFlags < 2) ? 1 :
+			 ((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),
+		 file W32_tmpfile
+		    ) == -1)
+		buf = NULL;
 	}
     }
     else {
 	if ((list->pattern[what][0]=='*')&&(list->pattern[what][1]=='\0')) {
-	    buf = Xprintf("%s.dir",componentDirs[what]);
-	    in= fopen(buf,"r");
+	    if (asprintf(&buf, "%s.dir", componentDirs[what]) == -1)
+		buf = NULL;
+	    else
+		in = fopen(buf,"r");
 	}
 	if (!in) {
 	    haveDir= FALSE;
 	    free(buf);
-	    buf = Xprintf(
-		"xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg,
-                componentDirs[what],(long)
-		((xkbDebugFlags<2)?1:((xkbDebugFlags>10)?10:xkbDebugFlags)),
-		file W32_tmpfile
-                );
+	    if (asprintf
+		(&buf,
+		 "xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg,
+		 componentDirs[what],
+		 (long)	((xkbDebugFlags < 2) ? 1 :
+			 ((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),
+		 file W32_tmpfile
+		    ) == -1)
+		buf = NULL;
 	}
     }
     status= Success;
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index cfc6198..e6904a5 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -210,7 +210,8 @@ XkbDDXCompileKeymapByNames(	XkbDescPtr		xkb,
 #endif
 
     if (XkbBaseDirectory != NULL) {
-	xkbbasedirflag = Xprintf("\"-R%s\"", XkbBaseDirectory);
+	if (asprintf(&xkbbasedirflag, "\"-R%s\"", XkbBaseDirectory) == -1)
+	    xkbbasedirflag = NULL;
     }
 
     if (XkbBinDirectory != NULL) {
@@ -225,14 +226,16 @@ XkbDDXCompileKeymapByNames(	XkbDescPtr		xkb,
 	}
     }
 
-    buf = Xprintf("\"%s%sxkbcomp\" -w %d %s -xkm \"%s\" "
+    if (asprintf(&buf,
+		 "\"%s%sxkbcomp\" -w %d %s -xkm \"%s\" "
 		  "-em1 %s -emp %s -eml %s \"%s%s.xkm\"",
-		  xkbbindir, xkbbindirsep,
-		  ( (xkbDebugFlags < 2) ? 1 :
-		    ((xkbDebugFlags > 10) ? 10 : (int)xkbDebugFlags) ),
-		  xkbbasedirflag ? xkbbasedirflag : "", xkmfile,
-		  PRE_ERROR_MSG, ERROR_PREFIX, POST_ERROR_MSG1,
-		  xkm_output_dir, keymap);
+		 xkbbindir, xkbbindirsep,
+		 ((xkbDebugFlags < 2) ? 1 :
+		  ((xkbDebugFlags > 10) ? 10 : (int) xkbDebugFlags)),
+		 xkbbasedirflag ? xkbbasedirflag : "", xkmfile,
+		 PRE_ERROR_MSG, ERROR_PREFIX, POST_ERROR_MSG1,
+		 xkm_output_dir, keymap) == -1)
+	buf = NULL;
 
     free(xkbbasedirflag);
 
commit c95c1d338fdb62dbe3dba934b97324fa778b7fce
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Nov 27 18:43:12 2010 -0800

    Add asprintf() implementation for platforms without it
    
    Provides a portable implementation of this common allocating sprintf()
    API found in many, but not yet all, of the platforms we support.
    If the platform provides vasprintf() we simply wrap it, otherwise we
    implement it - either way callers can use it regardless of platform.
    
    Since not all platforms guarantee to NULL out the return pointer on
    failure, we don't either, and require callers to check the return
    value for -1.
    
    The old Xprintf() API is deprecated, but left for compatibility for now.
    
    The new API is added in a new header so that it can be used in parts of
    the server such as hw/xfree86/parser that don't include all the server
    headers.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/COPYING b/COPYING
index bbf09ca..cd9e80a 100644
--- a/COPYING
+++ b/COPYING
@@ -15,7 +15,7 @@ Copyright © 2006 Nokia Corporation
 Copyright © 2006-2008 Peter Hutterer
 Copyright © 2006 Adam Jackson
 Copyright © 2009-2010 NVIDIA Corporation
-Copyright © 1987, 2003-2006, 2008-2009 Oracle and/or its affiliates.
+Copyright © 1987, 2003-2006, 2008-2010 Oracle and/or its affiliates.
 Copyright © 1999 Keith Packard
 Copyright © 2007-2009 Red Hat, Inc.
 Copyright © 2005-2008 Daniel Stone
diff --git a/configure.ac b/configure.ac
index b56d3e8..d2318da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -203,7 +203,7 @@ dnl Checks for library functions.
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
 		strtol getopt getopt_long vsnprintf walkcontext backtrace \
-		getisax getzoneid shmctl64 strcasestr ffs])
+		getisax getzoneid shmctl64 strcasestr ffs vasprintf])
 AC_FUNC_ALLOCA
 dnl Old HAS_* names used in os/*.c.
 AC_CHECK_FUNC([getdtablesize],
diff --git a/hw/xfree86/loader/sdksyms.sh b/hw/xfree86/loader/sdksyms.sh
index 4ac3c81..356d490 100755
--- a/hw/xfree86/loader/sdksyms.sh
+++ b/hw/xfree86/loader/sdksyms.sh
@@ -253,6 +253,7 @@ cat > sdksyms.c << EOF
 
 /* include/Makefile.am */
 #include "XIstubs.h"
+#include "Xprintf.h"
 #include "closestr.h"
 #include "closure.h"
 #include "colormap.h"
diff --git a/include/Makefile.am b/include/Makefile.am
index 966d215..42f0082 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,6 +1,7 @@
 if XORG
 sdk_HEADERS =		\
 	XIstubs.h	\
+	Xprintf.h	\
 	callback.h	\
 	closestr.h	\
 	closure.h	\
diff --git a/include/Xprintf.h b/include/Xprintf.h
new file mode 100644
index 0000000..5177122
--- /dev/null
+++ b/include/Xprintf.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef XPRINTF_H
+#define XPRINTF_H
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <X11/Xfuncproto.h>
+
+#ifndef _X_RESTRICT_KYWD
+# if defined(restrict) /* assume autoconf set it correctly */ || \
+   (defined(__STDC__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */
+#  define _X_RESTRICT_KYWD  restrict
+# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */
+#  define _X_RESTRICT_KYWD __restrict__
+# else
+#  define _X_RESTRICT_KYWD
+# endif
+#endif
+
+/*
+ * These functions provide a portable implementation of the common (but not
+ * yet universal) asprintf & vasprintf routines to allocate a buffer big
+ * enough to sprintf the arguments to.  The XNF variants terminate the server
+ * if the allocation fails.
+ * The buffer allocated is returned in the pointer provided in the first
+ * argument.   The return value is the size of the allocated buffer, or -1
+ * on failure.
+ */
+extern _X_EXPORT int Xasprintf (char **ret,
+				const char * _X_RESTRICT_KYWD fmt,
+				...) _X_ATTRIBUTE_PRINTF(2,3);
+extern _X_EXPORT int Xvasprintf (char **ret,
+				 const char * _X_RESTRICT_KYWD fmt,
+				 va_list va) _X_ATTRIBUTE_PRINTF(2,0);
+extern _X_EXPORT int XNFasprintf (char **ret,
+				  const char * _X_RESTRICT_KYWD fmt,
+				  ...) _X_ATTRIBUTE_PRINTF(2,3);
+extern _X_EXPORT int XNFvasprintf (char **ret,
+				   const char * _X_RESTRICT_KYWD fmt,
+				   va_list va) _X_ATTRIBUTE_PRINTF(2,0);
+
+#if !defined(HAVE_ASPRINTF) && !defined(HAVE_VASPRINTF)
+# define asprintf  Xasprintf
+# define vasprintf Xvasprintf
+#endif
+
+#endif /* XPRINTF_H */
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 6a33264..5622766 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -243,6 +243,9 @@
 /* Define to 1 if you have the `vprintf' function. */
 #undef HAVE_VPRINTF
 
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
+
 /* Support IPv6 for TCP connections */
 #undef IPv6
 
diff --git a/include/os.h b/include/os.h
index 566514d..88f23ae 100644
--- a/include/os.h
+++ b/include/os.h
@@ -263,10 +263,14 @@ extern _X_EXPORT char *Xstrdup(const char *s);
  */
 extern _X_EXPORT char *XNFstrdup(const char *s);
 
-extern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
-extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va);
-extern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2);
-extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va);
+/* Include new X*asprintf API */
+#include "Xprintf.h"
+
+/* Older api deprecated in favor of the asprintf versions */
+extern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_DEPRECATED;
+extern _X_EXPORT char *Xvprintf(const char *fmt, va_list va)_X_ATTRIBUTE_PRINTF(1,0) _X_DEPRECATED;
+extern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_DEPRECATED;
+extern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va)_X_ATTRIBUTE_PRINTF(1,0) _X_DEPRECATED;
 
 typedef void (*OsSigHandlerPtr)(int /* sig */);
 typedef int (*OsSigWrapperPtr)(int /* sig */);
diff --git a/os/xprintf.c b/os/xprintf.c
index 71a4424..0a8bd06 100644
--- a/os/xprintf.c
+++ b/os/xprintf.c
@@ -1,6 +1,13 @@
-/* 
- * printf routines which xalloc their buffer
- */ 
+/**
+ * @file
+ *
+ * @section DESCRIPTION
+ *
+ * These functions provide a portable implementation of the common (but not
+ * yet universal) asprintf & vasprintf routines to allocate a buffer big
+ * enough to sprintf the arguments to.  The XNF variants terminate the server
+ * if the allocation fails.
+ */
 /*
  * Copyright (c) 2004 Alexander Gottwald
  *
@@ -26,6 +33,29 @@
  * holders shall not be used in advertising or otherwise to promote the sale,
  * use or other dealings in this Software without prior written authorization.
  */
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
 #endif
@@ -35,6 +65,13 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#ifdef asprintf
+# undef asprintf
+#endif
+#ifdef vasprintf
+# undef vasprintf
+#endif
+
 #ifndef va_copy
 # ifdef __va_copy
 #  define va_copy __va_copy
@@ -42,11 +79,23 @@
 #  error "no working va_copy was found"
 # endif
 #endif
-    
-char *
-Xvprintf(const char *format, va_list va)
+
+/**
+ * Varargs sprintf that allocates a string buffer the right size for
+ * the pattern & data provided and prints the requested data to it.
+ *
+ * @param ret     Pointer to which the newly allocated buffer is written
+ *                (contents undefined on error)
+ * @param format  printf style format string
+ * @param va      variable argument list
+ * @return        size of allocated buffer, or -1 on error.
+ */
+int
+Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
 {
-    char *ret;
+#ifdef HAVE_VASPRINTF
+    return vasprintf(ret, format, va);
+#else
     int size;
     va_list va2;
 
@@ -54,12 +103,94 @@ Xvprintf(const char *format, va_list va)
     size = vsnprintf(NULL, 0, format, va2);
     va_end(va2);
 
-    ret = (char *)malloc(size + 1);
-    if (ret == NULL)
-        return NULL;
+    *ret = malloc(size + 1);
+    if (*ret == NULL)
+        return -1;
 
-    vsnprintf(ret, size + 1, format, va);
+    vsnprintf(*ret, size + 1, format, va);
     ret[size] = 0;
+    return size;
+#endif
+}
+
+#ifndef HAVE_VASPRINTF
+# define vasprintf Xvasprintf
+#endif
+
+/**
+ * sprintf that allocates a string buffer the right size for
+ * the pattern & data provided and prints the requested data to it.
+ *
+ * @param ret     Pointer to which the newly allocated buffer is written
+ *                (contents undefined on error)
+ * @param format  printf style format string
+ * @param ...     arguments for specified format
+ * @return        size of allocated buffer, or -1 on error.
+ */
+int
+Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
+{
+    int size;
+    va_list va;
+    va_start(va, format);
+    size = vasprintf(ret, format, va);
+    va_end(va);
+    return size;
+}
+
+/**
+ * Varargs sprintf that allocates a string buffer the right size for
+ * the pattern & data provided and prints the requested data to it.
+ * On failure, issues a FatalError message and aborts the server.
+ *
+ * @param ret     Pointer to which the newly allocated buffer is written
+ *                (contents undefined on error)
+ * @param format  printf style format string
+ * @param va      variable argument list
+ * @return        size of allocated buffer
+ */
+int
+XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
+{
+    int size = vasprintf(ret, format, va);
+    if ((size == -1) || (*ret == NULL)) {
+	Error("XNFvasprintf");
+	FatalError("XNFvasprintf failed");
+    }
+    return size;
+}
+
+/**
+ * sprintf that allocates a string buffer the right size for
+ * the pattern & data provided and prints the requested data to it.
+ * On failure, issues a FatalError message and aborts the server.
+ *
+ * @param ret     Pointer to which the newly allocated buffer is written
+ *                (contents undefined on error)
+ * @param format  printf style format string
+ * @param ...     arguments for specified format
+ * @return        size of allocated buffer
+ */
+int
+XNFasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
+{
+    int size;
+    va_list va;
+    va_start(va, format);
+    size = XNFvasprintf(ret, format, va);
+    va_end(va);
+    return size;
+}
+
+/* Old api, now deprecated, may be removed in the future */
+char *
+Xvprintf(const char *format, va_list va)
+{
+    char *ret;
+
+    if (vasprintf(&ret, format, va) == -1)
+	ret = NULL;
+
     return ret;
 }
 
@@ -68,7 +199,8 @@ char *Xprintf(const char *format, ...)
     char *ret;
     va_list va;
     va_start(va, format);
-    ret = Xvprintf(format, va);
+    if (vasprintf(&ret, format, va) == -1)
+	ret = NULL;
     va_end(va);
     return ret;
 }
@@ -77,19 +209,9 @@ char *
 XNFvprintf(const char *format, va_list va)
 {
     char *ret;
-    int size;
-    va_list va2;
-
-    va_copy(va2, va);
-    size = vsnprintf(NULL, 0, format, va2);
-    va_end(va2);
 
-    ret = (char *)xnfalloc(size + 1);
-    if (ret == NULL)
-        return NULL;
+    XNFvasprintf(&ret, format, va);
 
-    vsnprintf(ret, size + 1, format, va);
-    ret[size] = 0;
     return ret;
 }
 
@@ -98,7 +220,7 @@ char *XNFprintf(const char *format, ...)
     char *ret;
     va_list va;
     va_start(va, format);
-    ret = XNFvprintf(format, va);
+    XNFvasprintf(&ret, format, va);
     va_end(va);
     return ret;
 }
commit 2db6951763115a4a5dfac53d1a8f78ac33f91235
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Dec 3 16:32:01 2010 -0800

    Sun's copyrights now belong to Oracle
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/COPYING b/COPYING
index 3aad5fa..bbf09ca 100644
--- a/COPYING
+++ b/COPYING
@@ -15,11 +15,11 @@ Copyright © 2006 Nokia Corporation
 Copyright © 2006-2008 Peter Hutterer
 Copyright © 2006 Adam Jackson
 Copyright © 2009-2010 NVIDIA Corporation
+Copyright © 1987, 2003-2006, 2008-2009 Oracle and/or its affiliates.
 Copyright © 1999 Keith Packard
 Copyright © 2007-2009 Red Hat, Inc.
 Copyright © 2005-2008 Daniel Stone
 Copyright © 2006-2009 Simon Thum
-Copyright © 1987, 2003-2006, 2008-2009 Sun Microsystems, Inc.
 Copyright © 2006 Luc Verhaegen
 
 Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/composite/compalloc.c b/composite/compalloc.c
index c86eb9b..93571ee 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/composite/compext.c b/composite/compext.c
index 7fddbba..fbd36b5 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/composite/compinit.c b/composite/compinit.c
index 5db9f02..159f7c2 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/composite/compint.h b/composite/compint.h
index ae41c44..9ba5dd0 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/composite/compoverlay.c b/composite/compoverlay.c
index 3bace79..047f069 100644
--- a/composite/compoverlay.c
+++ b/composite/compoverlay.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 62283ee..bbd5756 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/dix/Xserver-dtrace.h.in b/dix/Xserver-dtrace.h.in
index fce2836..daf3faf 100644
--- a/dix/Xserver-dtrace.h.in
+++ b/dix/Xserver-dtrace.h.in
@@ -1,4 +1,4 @@
-/* Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
+/* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/dix/Xserver.d b/dix/Xserver.d
index 4bc0b9a..2ad3373 100644
--- a/dix/Xserver.d
+++ b/dix/Xserver.d
@@ -1,4 +1,4 @@
-/* Copyright 2005-2006 Sun Microsystems, Inc.  All rights reserved.
+/* Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/dix/dispatch.c b/dix/dispatch.c
index b66861f..7b2132d 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -75,7 +75,7 @@ Equipment Corporation.
 ******************************************************************/
 
 /* XSERVER_DTRACE additions:
- * Copyright 2005-2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/dix/events.c b/dix/events.c
index e8cf8d4..ac07923 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -75,7 +75,7 @@ Equipment Corporation.
 ******************************************************************/
 
 /*
- * Copyright © 2003-2005 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2003-2005, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/dix/resource.c b/dix/resource.c
index a0fe719..6bd2403 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -73,7 +73,7 @@ Equipment Corporation.
 
 ******************************************************************/
 /* XSERVER_DTRACE additions:
- * Copyright 2005-2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2005-2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/fb/fbcmap_mi.c b/fb/fbcmap_mi.c
index d75a38f..227da31 100644
--- a/fb/fbcmap_mi.c
+++ b/fb/fbcmap_mi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 1987 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/solaris-amd64.S b/hw/xfree86/os-support/solaris/solaris-amd64.S
index 94ffa40..4cc0642 100644
--- a/hw/xfree86/os-support/solaris/solaris-amd64.S
+++ b/hw/xfree86/os-support/solaris/solaris-amd64.S
@@ -1,4 +1,4 @@
-/ Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+/ Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
 / 
 / Permission is hereby granted, free of charge, to any person obtaining a
 / copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/solaris-ia32.S b/hw/xfree86/os-support/solaris/solaris-ia32.S
index 4dadf7f..74d787d 100644
--- a/hw/xfree86/os-support/solaris/solaris-ia32.S
+++ b/hw/xfree86/os-support/solaris/solaris-ia32.S
@@ -1,4 +1,4 @@
-/ Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+/ Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
 / 
 / Permission is hereby granted, free of charge, to any person obtaining a
 / copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S b/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S
index 0f6d694..0ecafb3 100644
--- a/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S
+++ b/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S
@@ -1,4 +1,4 @@
-/* Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
+/* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/sun_VTsw.c b/hw/xfree86/os-support/solaris/sun_VTsw.c
index cff279e..e6f3187 100644
--- a/hw/xfree86/os-support/solaris/sun_VTsw.c
+++ b/hw/xfree86/os-support/solaris/sun_VTsw.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/sun_agp.c b/hw/xfree86/os-support/solaris/sun_agp.c
index dd4b1e2..a4517d6 100644
--- a/hw/xfree86/os-support/solaris/sun_agp.c
+++ b/hw/xfree86/os-support/solaris/sun_agp.c
@@ -6,7 +6,7 @@
  * Copyright © 2000 VA Linux Systems, Inc.
  * Copyright © 2001 The XFree86 Project, Inc.
  */
-/* Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+/* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/sun_apm.c b/hw/xfree86/os-support/solaris/sun_apm.c
index 23e14f1..55081b6 100644
--- a/hw/xfree86/os-support/solaris/sun_apm.c
+++ b/hw/xfree86/os-support/solaris/sun_apm.c
@@ -27,7 +27,7 @@
  * XFree86 Project.
  */
 
-/* Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+/* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/sun_bell.c b/hw/xfree86/os-support/solaris/sun_bell.c
index bab3913..b59835e 100644
--- a/hw/xfree86/os-support/solaris/sun_bell.c
+++ b/hw/xfree86/os-support/solaris/sun_bell.c
@@ -1,4 +1,4 @@
-/* Copyright 2004-2005 Sun Microsystems, Inc.  All rights reserved.
+/* Copyright (c) 2004-2005, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/os-support/solaris/sun_vid.c b/hw/xfree86/os-support/solaris/sun_vid.c
index 9497973..f99bac5 100644
--- a/hw/xfree86/os-support/solaris/sun_vid.c
+++ b/hw/xfree86/os-support/solaris/sun_vid.c
@@ -22,7 +22,7 @@
  * OF THIS SOFTWARE.
  *
  */
-/* Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+/* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/utils/cvt/Makefile.am b/hw/xfree86/utils/cvt/Makefile.am
index 6b99cbd..0658682 100644
--- a/hw/xfree86/utils/cvt/Makefile.am
+++ b/hw/xfree86/utils/cvt/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
diff --git a/hw/xfree86/utils/gtf/Makefile.am b/hw/xfree86/utils/gtf/Makefile.am
index d1a6d61..ea1c5fb 100644
--- a/hw/xfree86/utils/gtf/Makefile.am
+++ b/hw/xfree86/utils/gtf/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
+# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
diff --git a/mi/micmap.c b/mi/micmap.c
index 8d76f4d..41e0300 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 1987 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/os/access.c b/os/access.c
index d9de264..a532db6 100644
--- a/os/access.c
+++ b/os/access.c
@@ -54,7 +54,7 @@ SOFTWARE.
 ******************************************************************/
 
 /*
- * Copyright © 2004 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 41ba0fb..54e5d75 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index 5dbfbec..e8c7bf1 100644
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h
index 9e50993..d005369 100644
--- a/xfixes/xfixesint.h
+++ b/xfixes/xfixesint.h
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2006 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
commit f06e8a61d6ed8f3054878167bffee619f852aad9
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Tue Nov 30 16:34:38 2010 -0800

    Move inclusion of panoramiX headers to top of render.c
    
    Fixes compiler error from Sun compilers due to _X_EXPORT declaration
    being included after the unlabeled version:
    
    "../Xext/panoramiXsrv.h", line 29: redeclaration must have the same or more restrictive linker scoping: XRT_PICTURE
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/render/render.c b/render/render.c
index 85a4392..0bbbae8 100644
--- a/render/render.c
+++ b/render/render.c
@@ -47,6 +47,11 @@
 #include "xace.h"
 #include "protocol-versions.h"
 
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
 #if HAVE_STDINT_H
 #include <stdint.h>
 #elif !defined(UINT32_MAX)
@@ -2651,9 +2656,6 @@ SProcRenderDispatch (ClientPtr client)
 }
 
 #ifdef PANORAMIX
-#include "panoramiX.h"
-#include "panoramiXsrv.h"
-
 #define VERIFY_XIN_PICTURE(pPicture, pid, client, mode) {\
     int rc = dixLookupResourceByType((pointer *)&(pPicture), pid,\
                                      XRT_PICTURE, client, mode);\
commit 9f9c732311ef0cc198e5ec44d02412eb7e8c3f3a
Author: Cyril Brulebois <kibi at debian.org>
Date:   Fri Nov 12 21:35:25 2010 +0100

    dix: Fix logic for displaying deprecation warning only once.
    
    As pointed out by Jamey Sharp (again), the logic is faulty: --warn is
    always going to be false. Replace it with warn-- accordingly, so that
    there's (at least, but also only) one warning showing up.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/dix/deprecated.c b/dix/deprecated.c
index 4cf596a..f05588e 100644
--- a/dix/deprecated.c
+++ b/dix/deprecated.c
@@ -67,7 +67,7 @@ SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode)
     WindowPtr pWin;
     static int warn = 1;
     dixLookupWindow(&pWin, id, client, access_mode);
-    if (warn > 0 && --warn)
+    if (warn > 0 && warn--)
 	ErrorF("Warning: LookupWindow()/SecurityLookupWindow() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupWindow().\n");
@@ -88,7 +88,7 @@ SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode)
     DrawablePtr pDraw;
     static int warn = 1;
     dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
-    if (warn > 0 && --warn)
+    if (warn > 0 && warn--)
 	ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupDrawable().\n");
@@ -109,7 +109,7 @@ LookupClient(XID id, ClientPtr client)
     ClientPtr pClient;
     static int warn = 1;
     dixLookupClient(&pClient, id, client, DixUnknownAccess);
-    if (warn > 0 && --warn)
+    if (warn > 0 && warn--)
 	ErrorF("Warning: LookupClient() is deprecated.  Please convert your "
 	       "driver/module to use dixLookupClient().\n");
     return pClient;
@@ -123,7 +123,7 @@ SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype,
     pointer retval;
     static int warn = 1;
     dixLookupResourceByType(&retval, id, rtype, client, access_mode);
-    if (warn > 0 && --warn)
+    if (warn > 0 && warn--)
 	ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupResourceByType().\n");
@@ -137,7 +137,7 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
     pointer retval;
     static int warn = 1;
     dixLookupResourceByClass(&retval, id, classes, client, access_mode);
-    if (warn > 0 && --warn)
+    if (warn > 0 && warn--)
 	ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupResourceByClass().\n");
commit a937803c1f671ef29332e5fe8c190d8b48239912
Author: Cyril Brulebois <kibi at debian.org>
Date:   Fri Nov 12 21:29:26 2010 +0100

    dix: Simplify deprecated *Lookup* wrappers around dixLookup*.
    
    As pointed out by Jamey Sharp: “the result pointer is already guaranteed
    to be NULL if the return value is not Success”, so get rid of the
    variable used to catch the return value, and used in a ternary operation
    to decide whether to return the pointer or NULL. Always return the
    result pointer instead.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/dix/deprecated.c b/dix/deprecated.c
index 21d0f57..4cf596a 100644
--- a/dix/deprecated.c
+++ b/dix/deprecated.c
@@ -65,13 +65,13 @@ WindowPtr
 SecurityLookupWindow(XID id, ClientPtr client, Mask access_mode)
 {
     WindowPtr pWin;
-    int i = dixLookupWindow(&pWin, id, client, access_mode);
     static int warn = 1;
+    dixLookupWindow(&pWin, id, client, access_mode);
     if (warn > 0 && --warn)
 	ErrorF("Warning: LookupWindow()/SecurityLookupWindow() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupWindow().\n");
-    return (i == Success) ? pWin : NULL;
+    return pWin;
 }
 
 /* replaced by dixLookupWindow */
@@ -86,13 +86,13 @@ pointer
 SecurityLookupDrawable(XID id, ClientPtr client, Mask access_mode)
 {
     DrawablePtr pDraw;
-    int i = dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
     static int warn = 1;
+    dixLookupDrawable(&pDraw, id, client, M_DRAWABLE, access_mode);
     if (warn > 0 && --warn)
 	ErrorF("Warning: LookupDrawable()/SecurityLookupDrawable() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupDrawable().\n");
-    return (i == Success) ? pDraw : NULL;
+    return pDraw;
 }
 
 /* replaced by dixLookupDrawable */
@@ -107,12 +107,12 @@ ClientPtr
 LookupClient(XID id, ClientPtr client)
 {
     ClientPtr pClient;
-    int i = dixLookupClient(&pClient, id, client, DixUnknownAccess);
     static int warn = 1;
+    dixLookupClient(&pClient, id, client, DixUnknownAccess);
     if (warn > 0 && --warn)
 	ErrorF("Warning: LookupClient() is deprecated.  Please convert your "
 	       "driver/module to use dixLookupClient().\n");
-    return (i == Success) ? pClient : NULL;
+    return pClient;
 }
 
 /* replaced by dixLookupResourceByType */
@@ -121,13 +121,13 @@ SecurityLookupIDByType(ClientPtr client, XID id, RESTYPE rtype,
 		       Mask access_mode)
 {
     pointer retval;
-    int i = dixLookupResourceByType(&retval, id, rtype, client, access_mode);
     static int warn = 1;
+    dixLookupResourceByType(&retval, id, rtype, client, access_mode);
     if (warn > 0 && --warn)
 	ErrorF("Warning: LookupIDByType()/SecurityLookupIDByType() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupResourceByType().\n");
-    return (i == Success) ? retval : NULL;
+    return retval;
 }
 
 pointer
@@ -135,13 +135,13 @@ SecurityLookupIDByClass(ClientPtr client, XID id, RESTYPE classes,
 			Mask access_mode)
 {
     pointer retval;
-    int i = dixLookupResourceByClass(&retval, id, classes, client, access_mode);
     static int warn = 1;
+    dixLookupResourceByClass(&retval, id, classes, client, access_mode);
     if (warn > 0 && --warn)
 	ErrorF("Warning: LookupIDByClass()/SecurityLookupIDByClass() "
 	       "are deprecated.  Please convert your driver/module "
 	       "to use dixLookupResourceByClass().\n");
-    return (i == Success) ? retval : NULL;
+    return retval;
 }
 
 /* replaced by dixLookupResourceByType */
commit 73fbc4a4a7997b3ee1c779d8f394114270bcb20d
Author: Cyril Brulebois <kibi at debian.org>
Date:   Fri Nov 12 12:04:11 2010 +0100

    Replace SecurityLookupIDByClass() with dixLookupResourceByClass().
    
    This patch has been prepared with the following Coccinelle semantic patch:
    
    @@
    expression a, b, c, d;
    identifier r;
    type t;
    @@
    -r = (t) SecurityLookupIDByClass(a, b, c, d);
    +dixLookupResourceByClass((pointer*) &r, b, c, a, d);
    
    The only occurrence not matching directly was processed after separating
    declaration of pXinDraw and call to SecurityLookupIDByClass().
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 0f8e8d8..a58eb35 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -1104,14 +1104,16 @@ static int MakeCurrent(__GLXclientState *cl,
        to_screen = screenInfo.numScreens - 1;
 
        if (pDraw && new_reply.writeType != GLX_PBUFFER_TYPE) {
-	  pXinDraw = (PanoramiXRes *)
-	     SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
+	  dixLookupResourceByClass((pointer*) &pXinDraw,
+				   pDraw->id, XRC_DRAWABLE,
+				   client, DixReadAccess);
        }
 
        if (pReadDraw && pReadDraw != pDraw && 
 	     new_reply.readType != GLX_PBUFFER_TYPE) {
-	  pXinReadDraw = (PanoramiXRes *)
-	     SecurityLookupIDByClass(client, pReadDraw->id, XRC_DRAWABLE, DixReadAccess);
+	  dixLookupResourceByClass((pointer*) &pXinReadDraw,
+				   pReadDraw->id, XRC_DRAWABLE,
+				   client, DixReadAccess);
        }
        else {
 	  pXinReadDraw = pXinDraw;
@@ -1765,8 +1767,9 @@ static int CreateGLXPixmap(__GLXclientState *cl,
        from_screen = 0;
        to_screen = screenInfo.numScreens - 1;
 
-       pXinDraw = (PanoramiXRes *)
-	  SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
+       dixLookupResourceByClass((pointer*) &pXinDraw,
+				pDraw->id, XRC_DRAWABLE,
+				client, DixReadAccess);
     }
 #endif
 
@@ -2013,8 +2016,9 @@ int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag)
     if (!noPanoramiXExtension) {
        from_screen = 0;
        to_screen = screenInfo.numScreens - 1;
-       pXinDraw = (PanoramiXRes *)
-        SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
+       dixLookupResourceByClass((pointer*) &pXinDraw,
+				pDraw->id, XRC_DRAWABLE,
+				client, DixReadAccess);
     }
 #endif
 
@@ -3369,9 +3373,9 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
 
 #ifdef PANORAMIX
        if (!noPanoramiXExtension) {
-	  pXinDraw = (PanoramiXRes *)
-	     SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
-	  if (!pXinDraw) {
+	  if (Success != dixLookupResourceByClass((pointer*) &pXinDraw,
+						  pDraw->id, XRC_DRAWABLE,
+						  client, DixReadAccess)) {
 	     client->errorValue = drawId;
 	     return __glXBadDrawable;
 	  }
@@ -3533,9 +3537,10 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
 
 #ifdef PANORAMIX
        if (!noPanoramiXExtension) {
-	  PanoramiXRes *pXinDraw = (PanoramiXRes *)
-	     SecurityLookupIDByClass(client, pDraw->id, XRC_DRAWABLE, DixReadAccess);
-	  if (!pXinDraw) {
+	  PanoramiXRes *pXinDraw;
+	  if (Success != dixLookupResourceByClass((pointer*) &pXinDraw,
+						  pDraw->id, XRC_DRAWABLE,
+						  client, DixReadAccess)) {
 	     client->errorValue = drawId;
 	     return __glXBadDrawable;
 	  }
commit 6e8b34b7048bc9e49ef52b81e2de1b518a05890e
Author: Cyril Brulebois <kibi at debian.org>
Date:   Fri Nov 12 11:36:36 2010 +0100

    Replace SecurityLookupIDByType() with dixLookupResourceByType(), take 2.
    
    These occurrences are a bit harder to catch through a semantic patch,
    so process them “manually”.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c
index 1dee077..f3e41ac 100644
--- a/hw/dmx/dmx.c
+++ b/hw/dmx/dmx.c
@@ -231,8 +231,9 @@ static int ProcDMXForceWindowCreation(ClientPtr client)
         PanoramiXRes *win;
         int          i;
 
-        if (!(win = SecurityLookupIDByType(client, stuff->window, XRT_WINDOW,
-                                           DixReadAccess)))
+        if (Success != dixLookupResourceByType((pointer*) &win,
+					       stuff->window, XRT_WINDOW,
+					       client, DixReadAccess))
             return -1;           /* BadWindow */
 
         FOR_NSCREENS(i) {
@@ -506,8 +507,9 @@ static int dmxPopulatePanoramiX(ClientPtr client, Window window,
     int                    count = 0;
     DMXWindowAttributesRec attr;
     
-    if (!(win = SecurityLookupIDByType(client, window, XRT_WINDOW,
-                                       DixReadAccess)))
+    if (Success != dixLookupResourceByType((pointer*) &win,
+					   window, XRT_WINDOW,
+					   client, DixReadAccess))
         return -1;               /* BadWindow */
     
     FOR_NSCREENS(i) {
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 4e2e62f..0f8e8d8 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -3074,7 +3074,10 @@ int __glXQueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
     int nReplyBytes;
 
     req = (xGLXQueryContextInfoEXTReq *)pc;
-    ctx = (__GLXcontext *) SecurityLookupIDByType(client, req->context, __glXContextRes, DixReadAccess);
+    dixLookupResourceByType((pointer*) &ctx,
+			    req->context, __glXContextRes,
+			    client,  DixReadAccess);
+
     if (!ctx) {
         client->errorValue = req->context;
         return __glXBadContext;
commit ac04c1377a42ab6803adf551756653fd8e1a694b
Author: Cyril Brulebois <kibi at debian.org>
Date:   Fri Nov 12 11:36:31 2010 +0100

    Replace SecurityLookupIDByType() with dixLookupResourceByType(), take 1.
    
    This patch has been prepared with the following Coccinelle semantic patch:
    
    @@
    expression a, b, c, d;
    identifier r;
    @@
    -r = SecurityLookupIDByType(a, b, c, d);
    +dixLookupResourceByType((pointer*) &r, b, c, a, d);
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/hw/dmx/dmxpict.c b/hw/dmx/dmxpict.c
index ab26593..bbde8fd 100644
--- a/hw/dmx/dmxpict.c
+++ b/hw/dmx/dmxpict.c
@@ -271,9 +271,11 @@ static int dmxProcRenderCreateGlyphSet(ClientPtr client)
 	/* Look up glyphSet that was just created ???? */
 	/* Store glyphsets from backends in glyphSet->devPrivate ????? */
 	/* Make sure we handle all errors here!! */
-	
-	glyphSet = SecurityLookupIDByType(client, stuff->gsid, GlyphSetType,
-					  DixDestroyAccess);
+
+	dixLookupResourceByType((pointer*) &glyphSet,
+				stuff->gsid, GlyphSetType,
+				client, DixDestroyAccess);
+
 	glyphPriv = malloc(sizeof(dmxGlyphPrivRec));
 	if (!glyphPriv) return BadAlloc;
         glyphPriv->glyphSets = NULL;
@@ -314,8 +316,9 @@ static int dmxProcRenderFreeGlyphSet(ClientPtr client)
     REQUEST(xRenderFreeGlyphSetReq);
 
     REQUEST_SIZE_MATCH(xRenderFreeGlyphSetReq);
-    glyphSet = SecurityLookupIDByType(client, stuff->glyphset, GlyphSetType,
-				      DixDestroyAccess);
+    dixLookupResourceByType((pointer*) &glyphSet,
+			    stuff->glyphset, GlyphSetType,
+			    client, DixDestroyAccess);
 
     if (glyphSet && glyphSet->refcnt == 1) {
 	dmxGlyphPrivPtr  glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
@@ -357,8 +360,9 @@ static int dmxProcRenderAddGlyphs(ClientPtr client)
 	CARD8           *bits;
 	int              nbytes;
 
-	glyphSet = SecurityLookupIDByType(client, stuff->glyphset,
-					  GlyphSetType, DixReadAccess);
+	dixLookupResourceByType((pointer*) &glyphSet,
+				stuff->glyphset, GlyphSetType,
+				client, DixReadAccess);
 	glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
 
 	nglyphs = stuff->nglyphs;
@@ -400,8 +404,9 @@ static int dmxProcRenderFreeGlyphs(ClientPtr client)
     REQUEST(xRenderFreeGlyphsReq);
 
     REQUEST_AT_LEAST_SIZE(xRenderFreeGlyphsReq);
-    glyphSet = SecurityLookupIDByType(client, stuff->glyphset, GlyphSetType,
-				      DixWriteAccess);
+    dixLookupResourceByType((pointer*) &glyphSet,
+			    stuff->glyphset, GlyphSetType,
+			    client, DixWriteAccess);
 
     if (glyphSet) {
 	dmxGlyphPrivPtr  glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
@@ -472,14 +477,18 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client)
 	GlyphSetPtr        glyphSet;
 	dmxGlyphPrivPtr    glyphPriv;
 
-	pSrc = SecurityLookupIDByType(client, stuff->src, PictureType,
-				      DixReadAccess);
+	dixLookupResourceByType((pointer*) &pSrc,
+				stuff->src, PictureType,
+				client, DixReadAccess);
+
 	pSrcPriv = DMX_GET_PICT_PRIV(pSrc);
 	if (!pSrcPriv->pict)
 	    return ret;
 
-	pDst = SecurityLookupIDByType(client, stuff->dst, PictureType,
-				      DixWriteAccess);
+	dixLookupResourceByType((pointer*) &pDst,
+				stuff->dst, PictureType,
+				client, DixWriteAccess);
+
 	pDstPriv = DMX_GET_PICT_PRIV(pDst);
 	if (!pDstPriv->pict)
 	    return ret;
@@ -495,8 +504,9 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client)
 	    return ret;
 
 	if (stuff->maskFormat)
-	    pFmt = SecurityLookupIDByType(client, stuff->maskFormat,
-					  PictFormatType, DixReadAccess);
+	    dixLookupResourceByType((pointer*) &pFmt,
+				    stuff->maskFormat, PictFormatType,
+				    client, DixReadAccess);
 	else
 	    pFmt = NULL;
 
@@ -546,8 +556,9 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client)
 	curGlyph = glyphs;
 	curElt = elts;
 
-	glyphSet = SecurityLookupIDByType(client, stuff->glyphset,
-					  GlyphSetType, DixReadAccess);
+	dixLookupResourceByType((pointer*) &glyphSet,
+				stuff->glyphset, GlyphSetType,
+				client, DixReadAccess);
 	glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
 
 	while (buffer + sizeof(xGlyphElt) < end) {
@@ -555,10 +566,11 @@ static int dmxProcRenderCompositeGlyphs(ClientPtr client)
 	    buffer += sizeof(xGlyphElt);
 
 	    if (elt->len == 0xff) {
-		glyphSet = SecurityLookupIDByType(client,
-						  *((CARD32 *)buffer),
-						  GlyphSetType,
-						  DixReadAccess);
+		dixLookupResourceByType((pointer*) &glyphSet,
+					*((CARD32 *)buffer),
+					GlyphSetType,
+					client,
+					DixReadAccess);
 		glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet);
 		buffer += 4;
 	    } else {
commit 28b4c02d7463ffe5c29f803f5656c5ecfc040185
Author: Cyril Brulebois <kibi at debian.org>
Date:   Thu Nov 11 18:36:45 2010 +0100

    Enable silent rules for cat and echo.
    
    One gets this:
    |   GEN    lf3-xaaBitmap.c
    |   GEN    lf3-xaaBitmap.c
    |   GEN    lf3-xaaBitmap.c
    |   GEN    lf3-xaaBitmap.c
    |   CC     lf3-xaaBitmap.lo
    
    instead of this:
    | echo "#define LSBFIRST" > l3-xaaBitmap.c
    | echo "#define TRIPLE_BITS" >> l3-xaaBitmap.c
    | echo '#include "../../../../hw/xfree86/xaa/xaaBitmap.c"' >> l3-xaaBitmap.c
    |   CC     l3-xaaBitmap.lo
    
    Occurrences found using:
    | git grep -E '(cat|echo)' -- '*Makefile.am'
    
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 989208f..4abf217 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -24,8 +24,8 @@ BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
 MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
 
 xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES)
-	cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@
-	echo >> $@
+	$(AM_V_GEN)cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@
+	$(AM_V_GEN)echo >> $@
 
 BUILT_SOURCES = xf86DefModeSet.c
 
diff --git a/hw/xfree86/ramdac/Makefile.am b/hw/xfree86/ramdac/Makefile.am
index 98e367c..3c37805 100644
--- a/hw/xfree86/ramdac/Makefile.am
+++ b/hw/xfree86/ramdac/Makefile.am
@@ -15,5 +15,5 @@ AM_CFLAGS = -DXAAReverseBitOrder=xf86ReverseBitOrder -DRAMDAC_MODULE \
 INCLUDES = $(XORG_INCS)
 
 xf86BitOrder.c:
-	echo "#define XAAReverseBitOrder xf86ReverseBitOrder" > $@
-	echo "#include \"$(srcdir)/../xaa/xaaBitOrder.c\"" >> $@
+	$(AM_V_GEN)echo "#define XAAReverseBitOrder xf86ReverseBitOrder" > $@
+	$(AM_V_GEN)echo "#include \"$(srcdir)/../xaa/xaaBitOrder.c\"" >> $@
diff --git a/hw/xfree86/xaa/Makefile.am b/hw/xfree86/xaa/Makefile.am
index 4ba1f78..5bfb4e9 100644
--- a/hw/xfree86/xaa/Makefile.am
+++ b/hw/xfree86/xaa/Makefile.am
@@ -25,40 +25,40 @@ libxaa_la_SOURCES = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c \
                    $(LSB_FIRST) $(MSB_FIRST) $(LSB_FIXED) $(MSB_FIXED) \
                    $(LSB_3_FIRST) $(MSB_3_FIRST) $(LSB_3_FIXED) $(MSB_3_FIXED)
 ${POLYSEG}:
-	echo "#define POLYSEGMENT" > $@
-	echo '#include "$(srcdir)/${@:s-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define POLYSEGMENT" > $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:s-%=%}"' >> $@
 ${LSB_FIRST}:
-	echo "#define LSBFIRST" > $@
-	echo '#include "$(srcdir)/${@:l-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define LSBFIRST" > $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:l-%=%}"' >> $@
 ${LSB_3_FIRST}:
-	echo "#define LSBFIRST" > $@
-	echo "#define TRIPLE_BITS" >> $@
-	echo '#include "$(srcdir)/${@:l3-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define LSBFIRST" > $@
+	$(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:l3-%=%}"' >> $@
 ${LSB_FIXED}:
-	echo "#define LSBFIRST" > $@
-	echo "#define FIXEDBASE" >> $@
-	echo '#include "$(srcdir)/${@:lf-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define LSBFIRST" > $@
+	$(AM_V_GEN)echo "#define FIXEDBASE" >> $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:lf-%=%}"' >> $@
 ${LSB_3_FIXED}:
-	echo "#define LSBFIRST" > $@
-	echo "#define TRIPLE_BITS" >> $@
-	echo "#define FIXEDBASE" >> $@
-	echo '#include "$(srcdir)/${@:lf3-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define LSBFIRST" > $@
+	$(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
+	$(AM_V_GEN)echo "#define FIXEDBASE" >> $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:lf3-%=%}"' >> $@
 ${MSB_FIRST}:
-	echo "#define MSBFIRST" > $@
-	echo '#include "$(srcdir)/${@:m-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define MSBFIRST" > $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:m-%=%}"' >> $@
 ${MSB_3_FIRST}:
-	echo "#define MSBFIRST" > $@
-	echo "#define TRIPLE_BITS" >> $@
-	echo '#include "$(srcdir)/${@:m3-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define MSBFIRST" > $@
+	$(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:m3-%=%}"' >> $@
 ${MSB_FIXED}:
-	echo "#define MSBFIRST" > $@
-	echo "#define FIXEDBASE" >> $@
-	echo '#include "$(srcdir)/${@:mf-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define MSBFIRST" > $@
+	$(AM_V_GEN)echo "#define FIXEDBASE" >> $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:mf-%=%}"' >> $@
 ${MSB_3_FIXED}:
-	echo "#define MSBFIRST" > $@
-	echo "#define TRIPLE_BITS" >> $@
-	echo "#define FIXEDBASE" >> $@
-	echo '#include "$(srcdir)/${@:mf3-%=%}"' >> $@
+	$(AM_V_GEN)echo "#define MSBFIRST" > $@
+	$(AM_V_GEN)echo "#define TRIPLE_BITS" >> $@
+	$(AM_V_GEN)echo "#define FIXEDBASE" >> $@
+	$(AM_V_GEN)echo '#include "$(srcdir)/${@:mf3-%=%}"' >> $@
 
 DISTCLEANFILES = $(POLYSEG) \
 	$(LSB_FIRST) $(LSB_FIXED) $(MSB_FIRST) $(MSB_FIXED) \
commit 838b9582280030a159878af566126cb0a523ec29
Author: Cyril Brulebois <kibi at debian.org>
Date:   Thu Nov 11 15:40:13 2010 +0100

    Replace LookupIDByType() with dixLookupResourceByType(), take 2.
    
    These occurrences are a bit harder to catch through a semantic patch,
    so process them “manually”.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/hw/dmx/dmxgcops.c b/hw/dmx/dmxgcops.c
index 425aa7c..bc8cd9e 100644
--- a/hw/dmx/dmxgcops.c
+++ b/hw/dmx/dmxgcops.c
@@ -523,8 +523,10 @@ static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw)
             
     if (noPanoramiXExtension)               return NULL;
     if (pDrawable->type != DRAWABLE_PIXMAP) return NULL;
-    
-    if (!(pXinPix = (PanoramiXRes *)LookupIDByType(pDrawable->id, XRT_PIXMAP)))
+
+    if (Success != dixLookupResourceByType((pointer*) &pXinPix,
+					   pDrawable->id, XRT_PIXMAP,
+					   NullClient, DixUnknownAccess))
         return NULL;
 
     for (i = 1; i < PanoramiXNumScreens; i++) {
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 050d1e3..4e2e62f 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -2897,6 +2897,7 @@ int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc)
     VisualPtr pVisual;
     VisualID visId;
     int i, rc;
+    pointer val;
 
     /*
     ** Check if windowId is valid 
@@ -2962,7 +2963,9 @@ int __glXCreateWindow(__GLXclientState *cl, GLbyte *pc)
     /*
     ** Check if there is already a fbconfig associated with this window
     */
-    if ( LookupIDByType(glxwindowId, __glXWindowRes) ) {
+    if (Success == dixLookupResourceByType(&val,
+					   glxwindowId, __glXWindowRes,
+					   NullClient, DixUnknownAccess)) {
 	client->errorValue = glxwindowId;
 	return BadAlloc;
     }
@@ -2994,11 +2997,14 @@ int __glXDestroyWindow(__GLXclientState *cl, GLbyte *pc)
     ClientPtr client = cl->client;
     xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
     XID glxwindow = req->glxwindow;
+    pointer val;
 
     /*
     ** Check if it's a valid GLX window.
     */
-    if (!LookupIDByType(glxwindow, __glXWindowRes)) {
+    if (Success != dixLookupResourceByType(&val,
+					   glxwindow, __glXWindowRes,
+					   NullClient, DixUnknownAccess)) {
 	client->errorValue = glxwindow;
 	return __glXBadDrawable;
     }
diff --git a/hw/dmx/glxProxy/glxext.c b/hw/dmx/glxProxy/glxext.c
index 886b317..7f63b6b 100644
--- a/hw/dmx/glxProxy/glxext.c
+++ b/hw/dmx/glxProxy/glxext.c
@@ -186,8 +186,12 @@ void __glXFreeGLXWindow(__glXWindow *pGlxWindow)
 {
     if (!pGlxWindow->idExists && !pGlxWindow->refcnt) {
 	WindowPtr pWindow = (WindowPtr) pGlxWindow->pDraw;
+	WindowPtr ret;
 
-        if (LookupIDByType(pWindow->drawable.id, RT_WINDOW) == pWindow) {
+	dixLookupResourceByType((pointer) &ret,
+				pWindow->drawable.id, RT_WINDOW,
+				NullClient, DixUnknownAccess);
+        if (ret == pWindow) {
             (*pGlxWindow->pScreen->DestroyWindow)(pWindow);
         }
 
commit ffb93533fd8067c7383aef5e0018a197af59b46c
Author: Cyril Brulebois <kibi at debian.org>
Date:   Thu Nov 11 15:30:15 2010 +0100

    Replace LookupIDByType() with dixLookupResourceByType(), take 1.
    
    This patch has been prepared with the following Coccinelle semantic patch:
    
    @@
    expression x, y;
    type t;
    identifier r;
    @@
    -r = (t) LookupIDByType(x, y);
    +dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
    
    @@
    expression x, y;
    type t;
    identifier r;
    @@
    -t r = (t) LookupIDByType(x, y);
    +t r;
    +dixLookupResourceByType((pointer*)&r, x, y, NullClient, DixUnknownAccess);
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index 0092835..45cb3db 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -699,7 +699,8 @@ static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type,
 	PixmapPtr      pPix;
 	int            i;
 
-	pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP);
+	dixLookupResourceByType((pointer*) &pPix, pXinPix->info[idx].id,
+				RT_PIXMAP, NullClient, DixUnknownAccess);
 	if (pPix != pDst) return; /* Not a match.... Next! */
 
 	for (i = 0; i < PanoramiXNumScreens; i++) {
@@ -708,8 +709,8 @@ static void dmxBERestorePixmapImage(pointer value, XID id, RESTYPE type,
 
 	    if (i == idx) continue; /* Self replication is bad */
 
-	    pSrc =
-		(PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP);
+	    dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
+				    RT_PIXMAP, NullClient, DixUnknownAccess);
 	    pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
 	    if (pSrcPriv->pixmap) {
 		DMXScreenInfo *dmxSrcScreen = &dmxScreens[i];
@@ -1365,7 +1366,8 @@ static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type,
 	PixmapPtr      pPix;
 	int            i;
 
-	pPix = (PixmapPtr)LookupIDByType(pXinPix->info[idx].id, RT_PIXMAP);
+	dixLookupResourceByType((pointer*) &pPix, pXinPix->info[idx].id,
+				RT_PIXMAP, NullClient, DixUnknownAccess);
 	if (pPix != pDst) return; /* Not a match.... Next! */
 
 	for (i = 0; i < PanoramiXNumScreens; i++) {
@@ -1374,8 +1376,8 @@ static void dmxBEFindPixmapImage(pointer value, XID id, RESTYPE type,
 
 	    if (i == idx) continue; /* Self replication is bad */
 
-	    pSrc =
-		(PixmapPtr)LookupIDByType(pXinPix->info[i].id, RT_PIXMAP);
+	    dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
+				    RT_PIXMAP, NullClient, DixUnknownAccess);
 	    pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
 	    if (pSrcPriv->pixmap) {
 		FoundPixImage = True;
diff --git a/hw/dmx/dmxgcops.c b/hw/dmx/dmxgcops.c
index 589c637..425aa7c 100644
--- a/hw/dmx/dmxgcops.c
+++ b/hw/dmx/dmxgcops.c
@@ -533,8 +533,8 @@ static DMXScreenInfo *dmxFindAlternatePixmap(DrawablePtr pDrawable, XID *draw)
             PixmapPtr     pSrc;
             dmxPixPrivPtr pSrcPriv;
             
-            pSrc = (PixmapPtr)LookupIDByType(pXinPix->info[i].id,
-                                             RT_PIXMAP);
+            dixLookupResourceByType((pointer*) &pSrc, pXinPix->info[i].id,
+				    RT_PIXMAP, NullClient, DixUnknownAccess);
             pSrcPriv = DMX_GET_PIXMAP_PRIV(pSrc);
             if (pSrcPriv->pixmap) {
                 *draw = pSrcPriv->pixmap;
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index 4484828..c3b4700 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -84,7 +84,8 @@ Window dmxCreateRootWindow(WindowPtr pWindow)
     parent = dmxScreen->scrnWin; /* This is our "Screen" window */
     visual = dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual;
 
-    pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow), RT_COLORMAP);
+    dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+			    RT_COLORMAP, NullClient, DixUnknownAccess);
     pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
 
     mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel;
@@ -191,8 +192,8 @@ void dmxGetDefaultWindowAttributes(WindowPtr pWindow,
 	    ColormapPtr         pCmap;
 	    dmxColormapPrivPtr  pCmapPriv;
 
-	    pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow),
-						RT_COLORMAP);
+	    dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+				    RT_COLORMAP, NullClient, DixUnknownAccess);
 	    pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
 	    *cmap = pCmapPriv->cmap;
 	} else {
@@ -545,7 +546,8 @@ static void dmxDoChangeWindowAttributes(WindowPtr pWindow,
 	ColormapPtr         pCmap;
 	dmxColormapPrivPtr  pCmapPriv;
 
-	pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow), RT_COLORMAP);
+	dixLookupResourceByType((pointer*) &pCmap, wColormap(pWindow),
+				RT_COLORMAP, NullClient, DixUnknownAccess);
 	pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap);
 	attribs->colormap = pCmapPriv->cmap;
     }
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 6a0aae7..050d1e3 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -129,7 +129,8 @@ static int CreateContext(__GLXclientState *cl,
     if (shareList == None) {
        shareglxc = NULL;
     } else {
-       shareglxc = (__GLXcontext *) LookupIDByType(shareList, __glXContextRes);
+       dixLookupResourceByType((pointer*) &shareglxc, shareList,
+                               __glXContextRes, NullClient, DixUnknownAccess);
        if (!shareglxc) {
 	  client->errorValue = shareList;
 	  return __glXBadContext;
@@ -420,14 +421,14 @@ int __glXBindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
 
     rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixGetAttrAccess);
     if (rc != Success) {
-	pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable,
-						    __glXPixmapRes);
+	dixLookupResourceByType((pointer*) &pGlxPixmap, req->drawable,
+				__glXPixmapRes, NullClient, DixUnknownAccess);
 	if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
     }
 
     if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-       pGlxWindow = (__glXWindow *) LookupIDByType(req->drawable,
-						   __glXWindowRes);
+       dixLookupResourceByType((pointer*) &pGlxWindow, req->drawable,
+                               __glXWindowRes, NullClient, DixUnknownAccess);
        if (pGlxWindow) pDraw = pGlxWindow->pDraw;
     }
 
@@ -450,14 +451,14 @@ int __glXJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc)
 
     rc = dixLookupDrawable(&pDraw, req->drawable, client, 0, DixManageAccess);
     if (rc != Success) {
-	pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->drawable,
-						    __glXPixmapRes);
+	dixLookupResourceByType((pointer*) &pGlxPixmap, req->drawable,
+				__glXPixmapRes, NullClient, DixUnknownAccess);
 	if (pGlxPixmap) pDraw = pGlxPixmap->pDraw;
     }
 
     if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-       pGlxWindow = (__glXWindow *) LookupIDByType(req->drawable,
-						   __glXWindowRes);
+       dixLookupResourceByType((pointer*) &pGlxWindow, req->drawable,
+                               __glXWindowRes, NullClient, DixUnknownAccess);
        if (pGlxWindow) pDraw = pGlxWindow->pDraw;
     }
 
@@ -470,14 +471,16 @@ int __glXJoinSwapGroupSGIX(__GLXclientState *cl, GLbyte *pc)
 	rc = dixLookupDrawable(&pMember, req->member, client, 0,
 			       DixGetAttrAccess);
 	if (rc != Success) {
-	    pGlxPixmap = (__GLXpixmap *) LookupIDByType(req->member,
-							__glXPixmapRes);
+	    dixLookupResourceByType((pointer*) &pGlxPixmap, req->member,
+                                    __glXPixmapRes, NullClient,
+                                    DixUnknownAccess);
 	    if (pGlxPixmap) pMember = pGlxPixmap->pDraw;
 	}
 
 	if (!pMember && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-	    pGlxWindow = (__glXWindow *) LookupIDByType(req->member,
-							__glXWindowRes);
+	    dixLookupResourceByType((pointer*) &pGlxWindow, req->member,
+                                    __glXWindowRes, NullClient,
+                                    DixUnknownAccess);
 	    if (pGlxWindow) pMember = pGlxWindow->pDraw;
 	}
 
@@ -505,7 +508,8 @@ int __glXDestroyContext(__GLXclientState *cl, GLbyte *pc)
     int to_screen = 0;
     int s;
     
-    glxc = (__GLXcontext *) LookupIDByType(gcId, __glXContextRes);
+    dixLookupResourceByType((pointer*) &glxc, gcId, __glXContextRes,
+			    NullClient, DixUnknownAccess);
     if (glxc) {
 	/*
 	** Just free the resource; don't actually destroy the context,
@@ -752,7 +756,8 @@ static int MakeCurrent(__GLXclientState *cl,
     ** Lookup new context.  It must not be current for someone else.
     */
     if (contextId != None) {
-	glxc = (__GLXcontext *) LookupIDByType(contextId, __glXContextRes);
+	dixLookupResourceByType((pointer*) &glxc, contextId, __glXContextRes,
+				NullClient, DixUnknownAccess);
 	if (!glxc) {
 	    client->errorValue = contextId;
 	    return __glXBadContext;
@@ -802,8 +807,9 @@ static int MakeCurrent(__GLXclientState *cl,
 	}
 
         if (!pDraw) {
-	    pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
-							__glXPixmapRes);
+	    dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
+				    __glXPixmapRes, NullClient,
+				    DixUnknownAccess);
 	    if (pGlxPixmap) {
 		/*
 		** Check if pixmap and context are similar.
@@ -826,7 +832,9 @@ static int MakeCurrent(__GLXclientState *cl,
 	}
 
 	if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-	   pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+	   dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
+                                   __glXWindowRes, NullClient,
+                                   DixUnknownAccess);
             if (pGlxWindow) {
                 /*
                 ** Drawable is a GLXWindow.
@@ -847,7 +855,9 @@ static int MakeCurrent(__GLXclientState *cl,
 	}
 
 	if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-	   pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
+	   dixLookupResourceByType((pointer*) &pGlxPbuffer, drawId,
+                                   __glXPbufferRes, NullClient,
+                                   DixUnknownAccess);
 	   if (pGlxPbuffer) {
                 if (pGlxPbuffer->pScreen != glxc->pScreen ||
                     pGlxPbuffer->pFBConfig != glxc->pFBConfig) {
@@ -908,8 +918,9 @@ static int MakeCurrent(__GLXclientState *cl,
 	}
 
 	if (!pReadDraw) {
-	    pReadGlxPixmap = (__GLXpixmap *) LookupIDByType(readId,
-							__glXPixmapRes);
+	    dixLookupResourceByType((pointer*) &pReadGlxPixmap, readId,
+				    __glXPixmapRes, NullClient,
+				    DixUnknownAccess);
 	    if (pReadGlxPixmap) {
 		/*
 		** Check if pixmap and context are similar.
@@ -929,8 +940,9 @@ static int MakeCurrent(__GLXclientState *cl,
 	}
 
 	if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-	   pGlxReadWindow = (__glXWindow *)
-                                LookupIDByType(readId, __glXWindowRes);
+	   dixLookupResourceByType((pointer*) &pGlxReadWindow, readId,
+                                   __glXWindowRes, NullClient,
+                                   DixUnknownAccess);
             if (pGlxReadWindow) {
                 /*
                 ** Drawable is a GLXWindow.
@@ -950,7 +962,9 @@ static int MakeCurrent(__GLXclientState *cl,
 	}
 
 	if (!pReadDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-	   pGlxReadPbuffer = (__glXPbuffer *)LookupIDByType(readId, __glXPbufferRes);
+	   dixLookupResourceByType((pointer*) &pGlxReadPbuffer, readId,
+                                   __glXPbufferRes, NullClient,
+                                   DixUnknownAccess);
 	   if (pGlxReadPbuffer) {
                 if (pGlxReadPbuffer->pScreen != glxc->pScreen ||
                     pGlxReadPbuffer->pFBConfig != glxc->pFBConfig) {
@@ -1303,7 +1317,8 @@ int __glXIsDirect(__GLXclientState *cl, GLbyte *pc)
     /*
     ** Find the GL context.
     */
-    glxc = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
+    dixLookupResourceByType((pointer*) &glxc, req->context, __glXContextRes,
+                            NullClient, DixUnknownAccess);
     if (!glxc) {
 	client->errorValue = req->context;
 	return __glXBadContext;
@@ -1449,12 +1464,14 @@ int __glXCopyContext(__GLXclientState *cl, GLbyte *pc)
     /*
     ** Check that each context exists.
     */
-    src = (__GLXcontext *) LookupIDByType(source, __glXContextRes);
+    dixLookupResourceByType((pointer*) &src, source, __glXContextRes,
+                            NullClient, DixUnknownAccess);
     if (!src) {
 	client->errorValue = source;
 	return __glXBadContext;
     }
-    dst = (__GLXcontext *) LookupIDByType(dest, __glXContextRes);
+    dixLookupResourceByType((pointer*) &dst, dest, __glXContextRes,
+                            NullClient, DixUnknownAccess);
     if (!dst) {
 	client->errorValue = dest;
 	return __glXBadContext;
@@ -1870,7 +1887,8 @@ int __glXDestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
     /*
     ** Check if it's a valid GLX pixmap.
     */
-    pGlxPixmap = (__GLXpixmap *)LookupIDByType(glxpixmap, __glXPixmapRes);
+    dixLookupResourceByType((pointer*) &pGlxPixmap, glxpixmap,
+                            __glXPixmapRes, NullClient, DixUnknownAccess);
     if (!pGlxPixmap) {
 	client->errorValue = glxpixmap;
 	return __glXBadPixmap;
@@ -1953,8 +1971,8 @@ int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag)
     } 
 
     if (!pDraw) {
-	pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
-						    __glXPixmapRes);
+	dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
+				__glXPixmapRes, NullClient, DixUnknownAccess);
 	if (pGlxPixmap) {
 	    /*
 	    ** Drawable is a GLX pixmap.
@@ -1965,7 +1983,8 @@ int __glXDoSwapBuffers(__GLXclientState *cl, XID drawId, GLXContextTag tag)
     }
 
     if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-       pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+       dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
+                               __glXWindowRes, NullClient, DixUnknownAccess);
        if (pGlxWindow) {
 	  /*
 	   ** Drawable is a GLXWindow.
@@ -2100,8 +2119,8 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc)
     } 
 
     if (!pDraw) {
-	pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
-						    __glXPixmapRes);
+	dixLookupResourceByType((pointer*) &pGlxPixmap, drawId,
+				__glXPixmapRes, NullClient, DixUnknownAccess);
 	if (pGlxPixmap) {
 	    /*
 	    ** Drawable is a GLX pixmap.
@@ -2111,7 +2130,8 @@ int __glXSwapBuffers(__GLXclientState *cl, GLbyte *pc)
     }
 
     if (!pDraw && __GLX_IS_VERSION_SUPPORTED(1,3) ) {
-       pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+       dixLookupResourceByType((pointer*) &pGlxWindow, drawId,
+                               __glXWindowRes, NullClient, DixUnknownAccess);
        if (pGlxWindow) {
 	  /*
 	   ** Drawable is a GLXWindow.
@@ -2620,9 +2640,13 @@ int __glXUseXFont(__GLXclientState *cl, GLbyte *pc)
     ** Font can actually be either the ID of a font or the ID of a GC
     ** containing a font.
     */
-    pFont = (FontPtr)LookupIDByType(req->font, RT_FONT);
+    dixLookupResourceByType((pointer*) &pFont, req->font, RT_FONT,
+                            NullClient, DixUnknownAccess);
     if (!pFont) {
-        GC *pGC = (GC *)LookupIDByType(req->font, RT_GC);
+        GC *pGC;
+        dixLookupResourceByType((pointer*) &pGC, req->font,
+				RT_GC, NullClient,
+				DixUnknownAccess);
         if (!pGC) {
 	    client->errorValue = req->font;
             return BadFont;
@@ -2998,7 +3022,8 @@ int __glXQueryContext(__GLXclientState *cl, GLbyte *pc)
     int nReplyBytes;
 
     req = (xGLXQueryContextReq *)pc;
-    ctx = (__GLXcontext *) LookupIDByType(req->context, __glXContextRes);
+    dixLookupResourceByType((pointer*) &ctx, req->context, __glXContextRes,
+                            NullClient, DixUnknownAccess);
     if (!ctx) {
         client->errorValue = req->context;
         return __glXBadContext;
@@ -3208,7 +3233,8 @@ int __glXDestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
     /*
     ** Check if it's a valid Pbuffer
     */
-    pGlxPbuffer = (__glXPbuffer *)LookupIDByType(pbuffer, __glXPbufferRes);
+    dixLookupResourceByType((pointer*) &pGlxPbuffer, pbuffer,
+                            __glXPbufferRes, NullClient, DixUnknownAccess);
     if (!pGlxPbuffer) {
 	client->errorValue = pbuffer;
 	return __glXBadPbuffer;
@@ -3280,8 +3306,10 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
       }
 
       if (!pDraw) {
-	 __GLXpixmap *pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
-							__glXPixmapRes);
+	 __GLXpixmap *pGlxPixmap;
+	 dixLookupResourceByType((pointer*) &pGlxPixmap,
+				 drawId, __glXPixmapRes,
+				 NullClient, DixUnknownAccess);
 	 if (pGlxPixmap) {
 		pDraw = pGlxPixmap->pDraw;
 		screen = pGlxPixmap->pScreen->myNum;
@@ -3290,7 +3318,10 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
       }
 
       if (!pDraw) {
-	 __glXWindow *pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+	 __glXWindow *pGlxWindow;
+	 dixLookupResourceByType((pointer*) &pGlxWindow,
+				 drawId, __glXWindowRes,
+				 NullClient, DixUnknownAccess);
 	 if (pGlxWindow) {
 	    pDraw = pGlxWindow->pDraw;
 	    screen = pGlxWindow->pScreen->myNum;
@@ -3299,7 +3330,10 @@ int __glXGetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
       }
 
       if (!pDraw) {
-	 __glXPbuffer *pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
+	 __glXPbuffer *pGlxPbuffer;
+	 dixLookupResourceByType((pointer*) &pGlxPbuffer,
+				 drawId, __glXPbufferRes,
+				 NullClient, DixUnknownAccess);
 	 if (pGlxPbuffer) {
     	    pDraw = (DrawablePtr)pGlxPbuffer;
 	    screen = pGlxPbuffer->pScreen->myNum;
@@ -3436,8 +3470,10 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
       }
 
       if (!pDraw) {
-	 __GLXpixmap *pGlxPixmap = (__GLXpixmap *) LookupIDByType(drawId,
-							__glXPixmapRes);
+	 __GLXpixmap *pGlxPixmap;
+	 dixLookupResourceByType((pointer*) &pGlxPixmap,
+				 drawId, __glXPixmapRes,
+				 NullClient, DixUnknownAccess);
 	 if (pGlxPixmap) {
 		pDraw = pGlxPixmap->pDraw;
 		screen = pGlxPixmap->pScreen->myNum;
@@ -3446,7 +3482,10 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
       }
 
       if (!pDraw) {
-	 __glXWindow *pGlxWindow = (__glXWindow *) LookupIDByType(drawId, __glXWindowRes);
+	 __glXWindow *pGlxWindow;
+	 dixLookupResourceByType((pointer*) &pGlxWindow,
+				 drawId, __glXWindowRes,
+				 NullClient, DixUnknownAccess);
 	 if (pGlxWindow) {
 	    pDraw = pGlxWindow->pDraw;
 	    screen = pGlxWindow->pScreen->myNum;
@@ -3455,7 +3494,10 @@ int __glXChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
       }
 
       if (!pDraw) {
-	 __glXPbuffer *pGlxPbuffer = (__glXPbuffer *)LookupIDByType(drawId, __glXPbufferRes);
+	 __glXPbuffer *pGlxPbuffer;
+	 dixLookupResourceByType((pointer*) &pGlxPbuffer,
+				 drawId, __glXPbufferRes,
+				 NullClient, DixUnknownAccess);
 	 if (pGlxPbuffer) {
     	    pDraw = (DrawablePtr)pGlxPbuffer;
 	    screen = pGlxPbuffer->pScreen->myNum;
commit d1b45b0fd54efb952f9ff435a516c1bfd85ca186
Author: Cyril Brulebois <kibi at debian.org>
Date:   Thu Nov 11 11:35:47 2010 +0100

    Fix missing <string.h> include.
    
    The following happens otherwise (with -Wall -Werror):
    | In file included from /usr/include/X11/Xfuncs.h:47,
    |                  from ../../include/misc.h:112,
    |                  from ../../include/screenint.h:52,
    |                  from ../../include/scrnintstr.h:52,
    |                  from ../../dix/cursor.c:58:
    | /usr/include/string.h:534: error: conflicting types for ‘xstrcasecmp’
    | ../../include/os.h:488: note: previous declaration of ‘xstrcasecmp’ was here
    | /usr/include/string.h:538: error: conflicting types for ‘xstrncasecmp’
    | ../../include/os.h:493: note: previous declaration of ‘xstrncasecmp’ was here
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Cyril Brulebois <kibi at debian.org>

diff --git a/include/os.h b/include/os.h
index 566514d..d587f34 100644
--- a/include/os.h
+++ b/include/os.h
@@ -51,6 +51,7 @@ SOFTWARE.
 
 #include "misc.h"
 #include <stdarg.h>
+#include <string.h>
 
 #define SCREEN_SAVER_ON   0
 #define SCREEN_SAVER_OFF  1


More information about the xorg-commit mailing list