From 7b893cc7cee185c0bf771166ca61a05b32800556 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 30 Jun 2013 00:32:10 +0100 Subject: [PATCH] Core: Fix writing of log lines a single fprintf call * fb4c208c33788068bbca67bdd6d11127b5be5a26 broke cygwin compilation due to __GCC__ not being defined * The actual issue is that __GNUC__ rather than __GCC__ should have been used all along * Also fixes gettimeofday() usage for MinGW/Cygwin * Also increase log buffer size to 1K, fix a broken fprintf in core.c and sort whitespaces --- libusb/core.c | 2 +- libusb/libusbi.h | 30 +++++++++++++----------------- libusb/version_nano.h | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/libusb/core.c b/libusb/core.c index 53f716f..ec37ba1 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -2020,7 +2020,7 @@ int usbi_gettimeofday(struct timeval *tp, void *tzp) static void usbi_log_str(struct libusb_context *ctx, const char * str) { UNUSED(ctx); - fprintf(stderr, str); + fprintf(stderr, "%s", str); } void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level, diff --git a/libusb/libusbi.h b/libusb/libusbi.h index 7293901..02efae3 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -57,9 +57,9 @@ #define USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER 0x00020000 /* Maximum number of bytes in a log line */ -#define USBI_MAX_LOG_LEN 256 +#define USBI_MAX_LOG_LEN 1024 /* Terminator for log lines */ -#define USBI_LOG_LINE_END "\n" +#define USBI_LOG_LINE_END "\n" /* The following is used to silence warnings for unused variables */ #define UNUSED(var) do { (void)(var); } while(0) @@ -73,18 +73,18 @@ struct list_head { }; /* Get an entry from the list - * ptr - the address of this list_head element in "type" - * type - the data type that contains "member" - * member - the list_head element in "type" + * ptr - the address of this list_head element in "type" + * type - the data type that contains "member" + * member - the list_head element in "type" */ #define list_entry(ptr, type, member) \ ((type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, member))) /* Get each entry from a list - * pos - A structure pointer has a "member" element - * head - list head - * member - the list_head element in "pos" - * type - the type of the first parameter + * pos - A structure pointer has a "member" element + * head - list head + * member - the list_head element in "pos" + * type - the type of the first parameter */ #define list_for_each_entry(pos, head, member, type) \ for (pos = list_entry((head)->next, type, member); \ @@ -437,11 +437,12 @@ void usbi_disconnect_device (struct libusb_device *dev); #include #include "os/poll_posix.h" #elif defined(OS_WINDOWS) || defined(OS_WINCE) -#include +#include "os/poll_windows.h" #endif -#if (defined(OS_WINDOWS) || defined(OS_WINCE)) && !defined(__GCC__) -#undef HAVE_GETTIMEOFDAY +#if (defined(OS_WINDOWS) || defined(OS_WINCE)) && !defined(__GNUC__) +#define snprintf _snprintf +#define vsnprintf _vsnprintf int usbi_gettimeofday(struct timeval *tp, void *tzp); #define LIBUSB_GETTIMEOFDAY_WIN32 #define HAVE_USBI_GETTIMEOFDAY @@ -452,11 +453,6 @@ int usbi_gettimeofday(struct timeval *tp, void *tzp); #endif #endif -#if (defined(OS_WINDOWS) || defined(OS_WINCE)) && !defined(__GCC__) -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#endif - struct usbi_pollfd { /* must come first */ struct libusb_pollfd pollfd; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 257b460..5ab4d98 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10764 +#define LIBUSB_NANO 10765 -- 2.7.4