diff options
author | Pete Batard <pete@akeo.ie> | 2012-06-25 19:13:42 +0100 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2012-07-02 18:28:37 +0100 |
commit | 0e0cbb6c27efa5a2ae58c30267a4be9486c766cc (patch) | |
tree | bb5a0fef2387ff49547595c58d4a90439e1b9460 /libusb/core.c | |
parent | 89b43a6929305eab8aad297a0ecb58b478857a10 (diff) | |
download | libusbx-0e0cbb6c27efa5a2ae58c30267a4be9486c766cc.tar.gz |
Windows: Address MSVC Level 4 & WDK's OACR/Prefast warnings
* The library is now compiled with warning level 4 for VS2010
* Move silencing of 4200, 28125 and 28719 to msvc/config.h
* Add fixes in core to silence unused variables warnings
* Ensure that spinlock is always set interlocked in poll_windows
* Add missing check for calloc return value
* Fix data assignation in conditionals warnings
* Fix an OACR/Prefast error related to the use of strncpy in xusb.c
* Also fixes whitespace inconsistencies in core
* Issues reported by Orin Eman and Xiaofan Chen. See:
https://sourceforge.net/mailarchive/message.php?msg_id=29412656
Diffstat (limited to 'libusb/core.c')
-rw-r--r-- | libusb/core.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/libusb/core.c b/libusb/core.c index dd352f9..82cf782 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -1611,7 +1611,7 @@ void API_EXPORTED libusb_set_debug(libusb_context *ctx, int level) */ int API_EXPORTED libusb_init(libusb_context **context) { - char *dbg = getenv("LIBUSB_DEBUG"); + char *dbg; struct libusb_context *ctx; int r = 0; @@ -1639,6 +1639,7 @@ int API_EXPORTED libusb_init(libusb_context **context) ctx->debug = LOG_LEVEL_DEBUG; #endif + dbg = getenv("LIBUSB_DEBUG"); if (dbg) { ctx->debug = atoi(dbg); if (ctx->debug) @@ -1774,21 +1775,21 @@ int API_EXPORTED libusb_has_capability(uint32_t capability) #define _W32_FT_OFFSET (116444736000000000) int usbi_gettimeofday(struct timeval *tp, void *tzp) - { - union { - unsigned __int64 ns100; /*time since 1 Jan 1601 in 100ns units */ - FILETIME ft; - } _now; - - if(tp) - { - GetSystemTimeAsFileTime (&_now.ft); - tp->tv_usec=(long)((_now.ns100 / 10) % 1000000 ); - tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000); - } - /* Always return 0 as per Open Group Base Specifications Issue 6. - Do not set errno on error. */ - return 0; +{ + union { + unsigned __int64 ns100; /* Time since 1 Jan 1601, in 100ns units */ + FILETIME ft; + } _now; + UNUSED(tzp); + + if(tp) { + GetSystemTimeAsFileTime (&_now.ft); + tp->tv_usec=(long)((_now.ns100 / 10) % 1000000 ); + tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000); + } + /* Always return 0 as per Open Group Base Specifications Issue 6. + Do not set errno on error. */ + return 0; } #endif |