Core: Fix writing of log lines a single fprintf call
authorPete Batard <pete@akeo.ie>
Sat, 29 Jun 2013 23:32:10 +0000 (00:32 +0100)
committerPete Batard <pete@akeo.ie>
Sat, 29 Jun 2013 23:32:10 +0000 (00:32 +0100)
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
libusb/libusbi.h
libusb/version_nano.h

index 53f716f..ec37ba1 100644 (file)
@@ -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,
index 7293901..02efae3 100644 (file)
@@ -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 <unistd.h>
 #include "os/poll_posix.h"
 #elif defined(OS_WINDOWS) || defined(OS_WINCE)
-#include <os/poll_windows.h>
+#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;
index 257b460..5ab4d98 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10764
+#define LIBUSB_NANO 10765