rpms/libusb/devel libusb-0.1.12-openat.patch, NONE, 1.1 libusb.spec, 1.33, 1.34
Jindrich Novy (jnovy)
fedora-extras-commits at redhat.com
Tue Sep 4 07:38:03 UTC 2007
- Previous message (by thread): rpms/gimp/devel .cvsignore, 1.33, 1.34 gimp.spec, 1.138, 1.139 sources, 1.33, 1.34
- Next message (by thread): rpms/xmlrpc-c/devel xmlrpc-c.spec, 1.17, 1.18 sources, 1.10, 1.11 lastver, 1.1, 1.2 0001-make-cmake-transition.txt, 1.7, 1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: jnovy
Update of /cvs/extras/rpms/libusb/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv20021
Modified Files:
libusb.spec
Added Files:
libusb-0.1.12-openat.patch
Log Message:
- optimize usb_find_devices() and use openat() instead of open()
(#273901), thanks to Ulrich Drepper
libusb-0.1.12-openat.patch:
--- NEW FILE libusb-0.1.12-openat.patch ---
diff -up libusb-0.1.12/configure.in.openat libusb-0.1.12/configure.in
--- libusb-0.1.12/configure.in.openat 2006-03-04 03:53:04.000000000 +0100
+++ libusb-0.1.12/configure.in 2007-09-04 08:41:04.000000000 +0200
@@ -188,6 +188,7 @@ AC_CHECK_HEADERS(values.h, AC_DEFINE_UNQ
# Check for some functions
AC_CHECK_FUNCS(memmove)
+AC_CHECK_FUNCS(openat)
if test "$os_support" = "bsd"; then
AC_MSG_CHECKING(if dev/usb/usb.h uses new naming convention)
diff -up libusb-0.1.12/linux.c.openat libusb-0.1.12/linux.c
--- libusb-0.1.12/linux.c.openat 2006-03-04 03:52:46.000000000 +0100
+++ libusb-0.1.12/linux.c 2007-09-04 08:40:27.000000000 +0200
@@ -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;
Index: libusb.spec
===================================================================
RCS file: /cvs/extras/rpms/libusb/devel/libusb.spec,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- libusb.spec 23 Aug 2007 06:43:05 -0000 1.33
+++ libusb.spec 4 Sep 2007 07:37:30 -0000 1.34
@@ -1,17 +1,18 @@
Summary: A library which allows userspace access to USB devices
Name: libusb
Version: 0.1.12
-Release: 9%{?dist}
+Release: 10%{?dist}
Source0: http://prdownloads.sourceforge.net/libusb/%{name}-%{version}.tar.gz
Patch0: libusb-0.1.12-libusbconfig.patch
Patch1: libusb-0.1.12-memset.patch
+Patch2: libusb-0.1.12-openat.patch
License: LGPLv2+
Group: System Environment/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
URL: http://sourceforge.net/projects/libusb/
BuildRequires: docbook-utils, pkgconfig
BuildRequires: docbook-dtds >= 1.0-5, docbook-utils-pdf
-BuildRequires: openjade
+BuildRequires: openjade autoconf
ExcludeArch: s390 s390x
%description
@@ -39,8 +40,10 @@
%setup -q
%patch0 -p1 -b .libusbconfig
%patch1 -p1 -b .memset
+%patch2 -p1 -b .openat
%build
+autoconf
%configure
make CFLAGS="$RPM_OPT_FLAGS"
pushd doc
@@ -76,6 +79,10 @@
%{_libdir}/*.a
%changelog
+* Thu Aug 23 2007 Jindrich Novy <jnovy at redhat.com> 0.1.12-10
+- optimize usb_find_devices() and use openat() instead of open()
+ (#273901), thanks to Ulrich Drepper
+
* Thu Aug 23 2007 Jindrich Novy <jnovy at redhat.com> 0.1.12-9
- update License
- rebuild for BuildID
- Previous message (by thread): rpms/gimp/devel .cvsignore, 1.33, 1.34 gimp.spec, 1.138, 1.139 sources, 1.33, 1.34
- Next message (by thread): rpms/xmlrpc-c/devel xmlrpc-c.spec, 1.17, 1.18 sources, 1.10, 1.11 lastver, 1.1, 1.2 0001-make-cmake-transition.txt, 1.7, 1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the fedora-extras-commits
mailing list