diff options
author | marha <marha@users.sourceforge.net> | 2011-11-25 08:22:48 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-11-25 08:22:48 +0100 |
commit | a0b4a1330be6a36ad095222d2ea83927cd33514d (patch) | |
tree | 616920ca608751e843c92c9815069f43789e3097 /xorg-server/hw/xfree86/common/xf86pciBus.c | |
parent | 45710577f374972946a8eb37833a9c94e5a299bf (diff) | |
download | vcxsrv-a0b4a1330be6a36ad095222d2ea83927cd33514d.tar.gz vcxsrv-a0b4a1330be6a36ad095222d2ea83927cd33514d.tar.bz2 vcxsrv-a0b4a1330be6a36ad095222d2ea83927cd33514d.zip |
mesa xserver pixman git update 25 nov 2011
Diffstat (limited to 'xorg-server/hw/xfree86/common/xf86pciBus.c')
-rw-r--r-- | xorg-server/hw/xfree86/common/xf86pciBus.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c index 87dc02512..b95b25359 100644 --- a/xorg-server/hw/xfree86/common/xf86pciBus.c +++ b/xorg-server/hw/xfree86/common/xf86pciBus.c @@ -82,16 +82,6 @@ static struct pci_slot_match xf86IsolateDevice = { PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0 }; -void -xf86FormatPciBusNumber(int busnum, char *buffer) -{ - /* 'buffer' should be at least 8 characters long */ - if (busnum < 256) - sprintf(buffer, "%d", busnum); - else - sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8); -} - /* * xf86Bus.c interface */ @@ -1072,7 +1062,7 @@ videoPtrToDriverList(struct pci_device *dev, int i; /* Add more entries here if we ever return more than 4 drivers for any device */ - char *driverList[5] = { NULL, NULL, NULL, NULL, NULL }; + const char *driverList[5] = { NULL, NULL, NULL, NULL, NULL }; switch (dev->vendor_id) { @@ -1219,9 +1209,8 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip /* A tiny bit of sanity checking. We should probably do better */ if (strncmp(&(direntry->d_name[len-4]), ".ids", 4) == 0) { /* We need the full path name to open the file */ - strncpy(path_name, PCI_TXT_IDS_PATH, 256); - strncat(path_name, "/", 1); - strncat(path_name, direntry->d_name, (256 - strlen(path_name) - 1)); + snprintf(path_name, sizeof(path_name), "%s/%s", + PCI_TXT_IDS_PATH, direntry->d_name); fp = fopen(path_name, "r"); if (fp == NULL) { xf86Msg(X_ERROR, "Could not open %s for reading. Exiting.\n", path_name); @@ -1235,8 +1224,7 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip #endif /* __GLIBC __ */ xchomp(line); if (isdigit(line[0])) { - strncpy(vendor_str, line, 4); - vendor_str[4] = '\0'; + strlcpy(vendor_str, line, sizeof(vendor_str)); vendor = (int)strtol(vendor_str, NULL, 16); if ((strlen(&line[4])) == 0) { chip_str[0] = '\0'; @@ -1248,8 +1236,7 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip chip = -1; } else { /* Ok, it's a real ID */ - strncpy(chip_str, &line[4], 4); - chip_str[4] = '\0'; + strlcpy(chip_str, &line[4], sizeof(chip_str)); chip = (int)strtol(chip_str, NULL, 16); } } @@ -1349,7 +1336,12 @@ xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo, pVideo = (struct pci_device *) busData; - xf86FormatPciBusNumber(pVideo->bus, busnum); + if (pVideo->bus < 256) + snprintf(busnum, sizeof(busnum), "%d", pVideo->bus); + else + snprintf(busnum, sizeof(busnum), "%d@%d", + pVideo->bus & 0x00ff, pVideo->bus >> 8); + XNFasprintf(&GDev->busID, "PCI:%s:%d:%d", busnum, pVideo->dev, pVideo->func); |