Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 184501 Details for
Bug 273901
Set of small optimizations
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Small set of optimizations
d-libusb-opt1 (text/plain), 3.06 KB, created by
Ulrich Drepper
on 2007-09-01 15:40:28 UTC
(
hide
)
Description:
Small set of optimizations
Filename:
MIME Type:
Creator:
Ulrich Drepper
Created:
2007-09-01 15:40:28 UTC
Size:
3.06 KB
patch
obsolete
>--- libusb-0.1.12/linux.c-save 2007-08-31 23:56:32.000000000 -0700 >+++ libusb-0.1.12/linux.c 2007-09-01 00:16:09.000000000 -0700 >@@ -341,12 +341,10 @@ int usb_os_find_busses(struct usb_bus ** > continue; > } > >- bus = malloc(sizeof(*bus)); >+ bus = calloc(1, sizeof(*bus)); > if (!bus) > USB_ERROR(-ENOMEM); > >- memset((void *)bus, 0, sizeof(*bus)); >- > strncpy(bus->dirname, entry->d_name, sizeof(bus->dirname) - 1); > bus->dirname[sizeof(bus->dirname) - 1] = 0; > >@@ -367,6 +365,9 @@ int usb_os_find_devices(struct usb_bus * > { > struct usb_device *fdev = NULL; > DIR *dir; >+#ifdef HAVE_OPENAT >+ int dfd; >+#endif > struct dirent *entry; > char dirpath[PATH_MAX + 1]; > >@@ -376,37 +377,54 @@ int usb_os_find_devices(struct usb_bus * > if (!dir) > USB_ERROR_STR(-errno, "couldn't opendir(%s): %s", dirpath, > strerror(errno)); >+#ifdef HAVE_OPENAT >+ dfd = dirfd (dir); >+#endif > > while ((entry = readdir(dir)) != NULL) { > unsigned char device_desc[DEVICE_DESC_LENGTH]; >+#ifndef HAVE_OPENAT > char filename[PATH_MAX + 1]; >+#endif > struct usb_device *dev; > struct usb_connectinfo connectinfo; > int i, fd, ret; > >+#ifdef _DIRENT_HAVE_D_TYPE >+ /* If we know this is a directory don't bother any further. */ >+ if (entry->d_type == DT_DIR) >+ continue; >+#endif >+ > /* Skip anything starting with a . */ > if (entry->d_name[0] == '.') > continue; > >- dev = malloc(sizeof(*dev)); >+ dev = calloc(1, sizeof(*dev)); > if (!dev) > USB_ERROR(-ENOMEM); > >- memset((void *)dev, 0, sizeof(*dev)); >- > dev->bus = bus; > > strncpy(dev->filename, entry->d_name, sizeof(dev->filename) - 1); > dev->filename[sizeof(dev->filename) - 1] = 0; > >+#ifdef HAVE_OPENAT >+ fd = openat(dfd, entry->d_name, O_RDWR); >+#else > snprintf(filename, sizeof(filename) - 1, "%s/%s", dirpath, entry->d_name); > fd = open(filename, O_RDWR); >+#endif > if (fd < 0) { >+#ifdef HAVE_OPENAT >+ fd = openat(dfd, entry->d_name, O_RDONLY); >+#else > fd = open(filename, O_RDONLY); >+#endif > if (fd < 0) { > if (usb_debug >= 2) >- fprintf(stderr, "usb_os_find_devices: Couldn't open %s\n", >- filename); >+ fprintf(stderr, "usb_os_find_devices: Couldn't open %s/%s\n", >+ dirpath, entry->d_name); > > free(dev); > continue; >@@ -453,14 +471,11 @@ int usb_os_find_devices(struct usb_bus * > /* Silent since we'll try again later */ > goto err; > >- dev->config = (struct usb_config_descriptor *)malloc(dev->descriptor.bNumConfigurations * sizeof(struct usb_config_descriptor)); >+ dev->config = (struct usb_config_descriptor *)calloc(dev->descriptor.bNumConfigurations, sizeof(struct usb_config_descriptor)); > if (!dev->config) > /* Silent since we'll try again later */ > goto err; > >- memset(dev->config, 0, dev->descriptor.bNumConfigurations * >- sizeof(struct usb_config_descriptor)); >- > for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { > unsigned char buffer[8], *bigbuffer; > struct usb_config_descriptor config;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 273901
: 184501