From 3a20d23b48c1051e1f22295fd886cc7f643417f6 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 10 Dec 2010 19:06:59 +0000 Subject: xserver git update 10/12/2010 --- xorg-server/hw/xfree86/common/Makefile.am | 4 ++-- xorg-server/hw/xfree86/common/xf86AutoConfig.c | 4 ++-- xorg-server/hw/xfree86/common/xf86Config.c | 13 ++++------ xorg-server/hw/xfree86/common/xf86Configure.c | 33 +++++++++----------------- xorg-server/hw/xfree86/common/xf86Helper.c | 15 ++++++------ xorg-server/hw/xfree86/common/xf86Init.c | 3 +-- xorg-server/hw/xfree86/common/xf86Option.c | 5 +--- xorg-server/hw/xfree86/common/xf86ShowOpts.c | 10 ++++---- xorg-server/hw/xfree86/common/xf86pciBus.c | 4 ++-- xorg-server/hw/xfree86/common/xf86sbusBus.c | 6 ++--- 10 files changed, 39 insertions(+), 58 deletions(-) (limited to 'xorg-server/hw/xfree86/common') diff --git a/xorg-server/hw/xfree86/common/Makefile.am b/xorg-server/hw/xfree86/common/Makefile.am index c4067aa62..56caaa5ab 100644 --- a/xorg-server/hw/xfree86/common/Makefile.am +++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c index 14b266d38..384f08103 100644 --- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c +++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c index c439221f9..4246f6d71 100644 --- a/xorg-server/hw/xfree86/common/xf86Config.c +++ b/xorg-server/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)) @@ -585,12 +583,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/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c index 6cce1cdd5..c106f3754 100644 --- a/xorg-server/hw/xfree86/common/xf86Configure.c +++ b/xorg-server/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; idev_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/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c index 9b6daaf41..8f61c4c72 100644 --- a/xorg-server/hw/xfree86/common/xf86Helper.c +++ b/xorg-server/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 */ @@ -1280,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/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c index a6740e69f..f3ce3f696 100644 --- a/xorg-server/hw/xfree86/common/xf86Init.c +++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c index 97deb1436..d7b294a86 100644 --- a/xorg-server/hw/xfree86/common/xf86Option.c +++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86ShowOpts.c b/xorg-server/hw/xfree86/common/xf86ShowOpts.c index 831e6b787..7aa79eb6a 100644 --- a/xorg-server/hw/xfree86/common/xf86ShowOpts.c +++ b/xorg-server/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; @@ -111,6 +108,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/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c index aef7d277a..2f04ac12f 100644 --- a/xorg-server/hw/xfree86/common/xf86pciBus.c +++ b/xorg-server/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/xorg-server/hw/xfree86/common/xf86sbusBus.c b/xorg-server/hw/xfree86/common/xf86sbusBus.c index f9244bca7..c0de88dda 100644 --- a/xorg-server/hw/xfree86/common/xf86sbusBus.c +++ b/xorg-server/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); } } -- cgit v1.2.3