~ubuntu-branches/ubuntu/quantal/libusbx/quantal

« back to all changes in this revision

Viewing changes to debian/patches/01-log_level.diff

  • Committer: Package Import Robot
  • Author(s): Aurelien Jarno
  • Date: 2012-07-09 07:45:56 UTC
  • Revision ID: package-import@ubuntu.com-20120709074556-ng1bhyqzphxflg2a
Tags: 2:1.0.12-2
01-log_level.diff: new patch from upstream to prefix LOG_LEVEL_* 
enum values with LIBUSB_ (closes: #680865). 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
commit 7ec94a45ed8155e7a1d4d5d75575099b09c78834
 
2
Author: Pete Batard <pete@akeo.ie>
 
3
Date:   Mon Jul 2 23:39:19 2012 +0100
 
4
 
 
5
    Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflicts
 
6
    
 
7
    * The LOG_LEVEL_ enums, that were moved to the public API
 
8
      in 933a319469bcccc962031c989e39d9d1f44f2885 may conflict
 
9
      with applications/headers that also define their own
 
10
      LOG_LEVEL_ values internally.
 
11
    * As a matter of fact, as per Trac #31, this produces a
 
12
      conflict with libusb-compat, as it defines its own levels.
 
13
 
 
14
diff --git a/examples/xusb.c b/examples/xusb.c
 
15
index 0eafd8c..3e8d262 100644
 
16
--- a/examples/xusb.c
 
17
+++ b/examples/xusb.c
 
18
@@ -1021,7 +1021,7 @@ int main(int argc, char** argv)
 
19
        if (r < 0)
 
20
                return r;
 
21
 
 
22
-       libusb_set_debug(NULL, debug_mode?LOG_LEVEL_DEBUG:LOG_LEVEL_INFO);
 
23
+       libusb_set_debug(NULL, debug_mode?LIBUSB_LOG_LEVEL_DEBUG:LIBUSB_LOG_LEVEL_INFO);
 
24
 
 
25
        test_device(VID, PID);
 
26
 
 
27
diff --git a/libusb/core.c b/libusb/core.c
 
28
index 8845909..e10d808 100644
 
29
--- a/libusb/core.c
 
30
+++ b/libusb/core.c
 
31
@@ -1567,11 +1567,11 @@ int API_EXPORTED libusb_attach_kernel_driver(libusb_device_handle *dev,
 
32
 /** \ingroup lib
 
33
  * Set log message verbosity.
 
34
  *
 
35
- * The default level is \ref LOG_LEVEL_NONE, which means no messages are ever
 
36
+ * The default level is LIBUSB_LOG_LEVEL_NONE, which means no messages are ever
 
37
  * printed. If you choose to increase the message verbosity level, ensure
 
38
  * that your application does not close the stdout/stderr file descriptors.
 
39
  *
 
40
- * You are advised to use level \ref LOG_LEVEL_WARNING. libusbx is conservative
 
41
+ * You are advised to use level LIBUSB_LOG_LEVEL_WARNING. libusbx is conservative
 
42
  * with its message logging and most of the time, will only log messages that
 
43
  * explain error conditions and other oddities. This will help you debug
 
44
  * your software.
 
45
@@ -1636,7 +1636,7 @@ int API_EXPORTED libusb_init(libusb_context **context)
 
46
        memset(ctx, 0, sizeof(*ctx));
 
47
 
 
48
 #ifdef ENABLE_DEBUG_LOGGING
 
49
-       ctx->debug = LOG_LEVEL_DEBUG;
 
50
+       ctx->debug = LIBUSB_LOG_LEVEL_DEBUG;
 
51
 #endif
 
52
 
 
53
        if (dbg) {
 
54
@@ -1793,7 +1793,7 @@ int usbi_gettimeofday(struct timeval *tp, void *tzp)
 
55
 }
 
56
 #endif
 
57
 
 
58
-void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
 
59
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
 
60
        const char *function, const char *format, va_list args)
 
61
 {
 
62
        const char *prefix = "";
 
63
@@ -1807,14 +1807,14 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
 
64
        USBI_GET_CONTEXT(ctx);
 
65
        if (ctx == NULL)
 
66
                return;
 
67
-       global_debug = (ctx->debug == LOG_LEVEL_DEBUG);
 
68
+       global_debug = (ctx->debug == LIBUSB_LOG_LEVEL_DEBUG);
 
69
        if (!ctx->debug)
 
70
                return;
 
71
-       if (level == LOG_LEVEL_WARNING && ctx->debug < LOG_LEVEL_WARNING)
 
72
+       if (level == LIBUSB_LOG_LEVEL_WARNING && ctx->debug < LIBUSB_LOG_LEVEL_WARNING)
 
73
                return;
 
74
-       if (level == LOG_LEVEL_INFO && ctx->debug < LOG_LEVEL_INFO)
 
75
+       if (level == LIBUSB_LOG_LEVEL_INFO && ctx->debug < LIBUSB_LOG_LEVEL_INFO)
 
76
                return;
 
77
-       if (level == LOG_LEVEL_DEBUG && ctx->debug < LOG_LEVEL_DEBUG)
 
78
+       if (level == LIBUSB_LOG_LEVEL_DEBUG && ctx->debug < LIBUSB_LOG_LEVEL_DEBUG)
 
79
                return;
 
80
 #endif
 
81
 
 
82
@@ -1832,19 +1832,19 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
 
83
        now.tv_usec -= timestamp_origin.tv_usec;
 
84
 
 
85
        switch (level) {
 
86
-       case LOG_LEVEL_INFO:
 
87
+       case LIBUSB_LOG_LEVEL_INFO:
 
88
                prefix = "info";
 
89
                break;
 
90
-       case LOG_LEVEL_WARNING:
 
91
+       case LIBUSB_LOG_LEVEL_WARNING:
 
92
                prefix = "warning";
 
93
                break;
 
94
-       case LOG_LEVEL_ERROR:
 
95
+       case LIBUSB_LOG_LEVEL_ERROR:
 
96
                prefix = "error";
 
97
                break;
 
98
-       case LOG_LEVEL_DEBUG:
 
99
+       case LIBUSB_LOG_LEVEL_DEBUG:
 
100
                prefix = "debug";
 
101
                break;
 
102
-       case LOG_LEVEL_NONE:
 
103
+       case LIBUSB_LOG_LEVEL_NONE:
 
104
                break;
 
105
        default:
 
106
                prefix = "unknown";
 
107
@@ -1863,7 +1863,7 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
 
108
        fprintf(stderr, "\n");
 
109
 }
 
110
 
 
111
-void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
 
112
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
 
113
        const char *function, const char *format, ...)
 
114
 {
 
115
        va_list args;
 
116
diff --git a/libusb/libusb.h b/libusb/libusb.h
 
117
index fd231ea..1dc12f8 100644
 
118
--- a/libusb/libusb.h
 
119
+++ b/libusb/libusb.h
 
120
@@ -951,20 +951,20 @@ enum libusb_capability {
 
121
 
 
122
 /** \ingroup lib
 
123
  *  Log message levels.
 
124
- *  - LOG_LEVEL_NONE (0)    : no messages ever printed by the library (default)
 
125
- *  - LOG_LEVEL_ERROR (1)   : error messages are printed to stderr
 
126
- *  - LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
 
127
- *  - LOG_LEVEL_INFO (3)    : informational messages are printed to stdout, warning
 
128
+ *  - LIBUSB_LOG_LEVEL_NONE (0)    : no messages ever printed by the library (default)
 
129
+ *  - LIBUSB_LOG_LEVEL_ERROR (1)   : error messages are printed to stderr
 
130
+ *  - LIBUSB_LOG_LEVEL_WARNING (2) : warning and error messages are printed to stderr
 
131
+ *  - LIBUSB_LOG_LEVEL_INFO (3)    : informational messages are printed to stdout, warning
 
132
  *    and error messages are printed to stderr
 
133
- *  - LOG_LEVEL_DEBUG (4)   : debug and informational messages are printed to stdout,
 
134
+ *  - LIBUSB_LOG_LEVEL_DEBUG (4)   : debug and informational messages are printed to stdout,
 
135
  *    warnings and errors to stderr
 
136
  */
 
137
-enum usbi_log_level {
 
138
-       LOG_LEVEL_NONE = 0,
 
139
-       LOG_LEVEL_ERROR,
 
140
-       LOG_LEVEL_WARNING,
 
141
-       LOG_LEVEL_INFO,
 
142
-       LOG_LEVEL_DEBUG,
 
143
+enum libusb_log_level {
 
144
+       LIBUSB_LOG_LEVEL_NONE = 0,
 
145
+       LIBUSB_LOG_LEVEL_ERROR,
 
146
+       LIBUSB_LOG_LEVEL_WARNING,
 
147
+       LIBUSB_LOG_LEVEL_INFO,
 
148
+       LIBUSB_LOG_LEVEL_DEBUG,
 
149
 };
 
150
 
 
151
 int LIBUSB_CALL libusb_init(libusb_context **ctx);
 
152
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
 
153
index 27362f7..3c4a059 100644
 
154
--- a/libusb/libusbi.h
 
155
+++ b/libusb/libusbi.h
 
156
@@ -130,25 +130,25 @@ static inline void *usbi_reallocf(void *ptr, size_t size)
 
157
 
 
158
 #define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0)
 
159
 
 
160
-void usbi_log(struct libusb_context *ctx, enum usbi_log_level level,
 
161
+void usbi_log(struct libusb_context *ctx, enum libusb_log_level level,
 
162
        const char *function, const char *format, ...);
 
163
 
 
164
-void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
 
165
+void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level,
 
166
        const char *function, const char *format, va_list args);
 
167
 
 
168
 #if !defined(_MSC_VER) || _MSC_VER >= 1400
 
169
 
 
170
 #ifdef ENABLE_LOGGING
 
171
 #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
 
172
-#define usbi_dbg(...) _usbi_log(NULL, LOG_LEVEL_DEBUG, __VA_ARGS__)
 
173
+#define usbi_dbg(...) _usbi_log(NULL, LIBUSB_LOG_LEVEL_DEBUG, __VA_ARGS__)
 
174
 #else
 
175
 #define _usbi_log(ctx, level, ...) do { (void)(ctx); } while(0)
 
176
 #define usbi_dbg(...) do {} while(0)
 
177
 #endif
 
178
 
 
179
-#define usbi_info(ctx, ...) _usbi_log(ctx, LOG_LEVEL_INFO, __VA_ARGS__)
 
180
-#define usbi_warn(ctx, ...) _usbi_log(ctx, LOG_LEVEL_WARNING, __VA_ARGS__)
 
181
-#define usbi_err(ctx, ...) _usbi_log(ctx, LOG_LEVEL_ERROR, __VA_ARGS__)
 
182
+#define usbi_info(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_INFO, __VA_ARGS__)
 
183
+#define usbi_warn(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_WARNING, __VA_ARGS__)
 
184
+#define usbi_err(ctx, ...) _usbi_log(ctx, LIBUSB_LOG_LEVEL_ERROR, __VA_ARGS__)
 
185
 
 
186
 #else /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
 
187
 
 
188
@@ -166,16 +166,16 @@ void usbi_log_v(struct libusb_context *ctx, enum usbi_log_level level,
 
189
 
 
190
 static inline void usbi_info(struct libusb_context *ctx, const char *format,
 
191
        ...)
 
192
-       LOG_BODY(ctx,LOG_LEVEL_INFO)
 
193
+       LOG_BODY(ctx,LIBUSB_LOG_LEVEL_INFO)
 
194
 static inline void usbi_warn(struct libusb_context *ctx, const char *format,
 
195
        ...)
 
196
-       LOG_BODY(ctx,LOG_LEVEL_WARNING)
 
197
+       LOG_BODY(ctx,LIBUSB_LOG_LEVEL_WARNING)
 
198
 static inline void usbi_err( struct libusb_context *ctx, const char *format,
 
199
        ...)
 
200
-       LOG_BODY(ctx,LOG_LEVEL_ERROR)
 
201
+       LOG_BODY(ctx,LIBUSB_LOG_LEVEL_ERROR)
 
202
 
 
203
 static inline void usbi_dbg(const char *format, ...)
 
204
-       LOG_BODY(NULL,LOG_LEVEL_DEBUG)
 
205
+       LOG_BODY(NULL,LIBUSB_LOG_LEVEL_DEBUG)
 
206
 
 
207
 #endif /* !defined(_MSC_VER) || _MSC_VER >= 1400 */
 
208