~ubuntu-branches/ubuntu/trusty/libusbx/trusty-proposed

« back to all changes in this revision

Viewing changes to libusb/io.c

  • Committer: Package Import Robot
  • Author(s): Aurelien Jarno
  • Date: 2012-06-30 01:14:07 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120630011407-pdveupm6ldtfnfh3
Tags: 2:1.0.12-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * I/O functions for libusbx
3
 
 * Copyright � 2007-2009 Daniel Drake <dsd@gentoo.org>
4
 
 * Copyright � 2001 Johannes Erdfelt <johannes@erdfelt.com>
 
3
 * Copyright © 2007-2009 Daniel Drake <dsd@gentoo.org>
 
4
 * Copyright © 2001 Johannes Erdfelt <johannes@erdfelt.com>
5
5
 *
6
6
 * This library is free software; you can redistribute it and/or
7
7
 * modify it under the terms of the GNU Lesser General Public
1857
1857
        int r;
1858
1858
        struct usbi_pollfd *ipollfd;
1859
1859
        POLL_NFDS_TYPE nfds = 0;
1860
 
        struct pollfd *fds;
 
1860
        struct pollfd *fds = NULL;
1861
1861
        int i = -1;
1862
1862
        int timeout_ms;
1863
1863
 
1866
1866
                nfds++;
1867
1867
 
1868
1868
        /* TODO: malloc when number of fd's changes, not on every poll */
1869
 
        fds = malloc(sizeof(*fds) * nfds);
 
1869
        if (nfds != 0)
 
1870
                fds = malloc(sizeof(*fds) * nfds);
1870
1871
        if (!fds) {
1871
1872
                usbi_mutex_unlock(&ctx->pollfds_lock);
1872
1873
                return LIBUSB_ERROR_NO_MEM;
2272
2273
        r = usbi_backend->clock_gettime(USBI_CLOCK_MONOTONIC, &cur_ts);
2273
2274
        if (r < 0) {
2274
2275
                usbi_err(ctx, "failed to read monotonic clock, errno=%d", errno);
2275
 
                return LIBUSB_ERROR_OTHER;
 
2276
                return 0;
2276
2277
        }
2277
2278
        TIMESPEC_TO_TIMEVAL(&cur_tv, &cur_ts);
2278
2279