Merge lp://staging/~trond-norbye/libmemcached/gcc_fix into lp://staging/~tangent-org/libmemcached/trunk
- gcc_fix
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp://staging/~trond-norbye/libmemcached/gcc_fix |
Merge into: | lp://staging/~tangent-org/libmemcached/trunk |
Diff against target: | None lines |
To merge this branch: | bzr merge lp://staging/~trond-norbye/libmemcached/gcc_fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Monty Taylor (community) | Needs Information | ||
Review via email: mp+9957@code.staging.launchpad.net |
Commit message
Description of the change
Trond Norbye (trond-norbye) wrote : | # |
Monty Taylor (mordred) wrote : | # |
Overall the patch looks fine - but what is this? I don't see CC used anywhere, and in general CC is a pretty terrible name for a macro (makes me think I'm looking at a Makefile talking about the C compiler. The other definition of OPTIONSTRING seems to be doing this instead?
8 +#ifdef __sun
9 + /* For some odd reason the option struct on solaris defines the argument
10 + * as char*
11 + */
12 +#define CC char*
13 +#else
14 +#define CC const char*
15 +#endif
16 +
- 570. By Trond Norbye
-
Fix problems reported by: -Wsign-conversion from gcc 4.4 on Solaris
Trond Norbye (trond-norbye) wrote : | # |
Monty Taylor wrote:
> Review: Needs Information
> Overall the patch looks fine - but what is this? I don't see CC used anywhere, and in general CC is a pretty terrible name for a macro (makes me think I'm looking at a Makefile talking about the C compiler. The other definition of OPTIONSTRING seems to be doing this instead?
>
> 8 +#ifdef __sun
> 9 + /* For some odd reason the option struct on solaris defines the argument
> 10 + * as char*
> 11 + */
> 12 +#define CC char*
> 13 +#else
> 14 +#define CC const char*
> 15 +#endif
> 16 +
>
Ah.. fixed that and re-pushed the branch...
Thanks!
Cheers,
Trond
Preview Diff
1 | === modified file 'clients/memcat.c' |
2 | --- clients/memcat.c 2009-06-15 13:03:47 +0000 |
3 | +++ clients/memcat.c 2009-08-10 22:32:01 +0000 |
4 | @@ -108,16 +108,25 @@ |
5 | {0}, |
6 | }; |
7 | |
8 | +#ifdef __sun |
9 | + /* For some odd reason the option struct on solaris defines the argument |
10 | + * as char* |
11 | + */ |
12 | +#define CC char* |
13 | +#else |
14 | +#define CC const char* |
15 | +#endif |
16 | + |
17 | static struct option long_options[]= |
18 | { |
19 | - {"version", no_argument, NULL, OPT_VERSION}, |
20 | - {"help", no_argument, NULL, OPT_HELP}, |
21 | - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
22 | - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
23 | - {"servers", required_argument, NULL, OPT_SERVERS}, |
24 | - {"flag", no_argument, &opt_displayflag, OPT_FLAG}, |
25 | - {"hash", required_argument, NULL, OPT_HASH}, |
26 | - {"binary", no_argument, NULL, OPT_BINARY}, |
27 | + {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, |
28 | + {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, |
29 | + {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
30 | + {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
31 | + {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, |
32 | + {(OPTIONSTRING)"flag", no_argument, &opt_displayflag, OPT_FLAG}, |
33 | + {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, |
34 | + {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, |
35 | {0, 0, 0, 0}, |
36 | }; |
37 | |
38 | |
39 | === modified file 'clients/memcp.c' |
40 | --- clients/memcp.c 2009-07-08 13:38:34 +0000 |
41 | +++ clients/memcp.c 2009-08-10 22:32:01 +0000 |
42 | @@ -165,18 +165,18 @@ |
43 | |
44 | static struct option long_options[]= |
45 | { |
46 | - {"version", no_argument, NULL, OPT_VERSION}, |
47 | - {"help", no_argument, NULL, OPT_HELP}, |
48 | - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
49 | - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
50 | - {"servers", required_argument, NULL, OPT_SERVERS}, |
51 | - {"flag", required_argument, NULL, OPT_FLAG}, |
52 | - {"expire", required_argument, NULL, OPT_EXPIRE}, |
53 | - {"set", no_argument, NULL, OPT_SET}, |
54 | - {"add", no_argument, NULL, OPT_ADD}, |
55 | - {"replace", no_argument, NULL, OPT_REPLACE}, |
56 | - {"hash", required_argument, NULL, OPT_HASH}, |
57 | - {"binary", no_argument, NULL, OPT_BINARY}, |
58 | + {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, |
59 | + {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, |
60 | + {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
61 | + {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
62 | + {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, |
63 | + {(OPTIONSTRING)"flag", required_argument, NULL, OPT_FLAG}, |
64 | + {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE}, |
65 | + {(OPTIONSTRING)"set", no_argument, NULL, OPT_SET}, |
66 | + {(OPTIONSTRING)"add", no_argument, NULL, OPT_ADD}, |
67 | + {(OPTIONSTRING)"replace", no_argument, NULL, OPT_REPLACE}, |
68 | + {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, |
69 | + {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, |
70 | {0, 0, 0, 0}, |
71 | }; |
72 | |
73 | |
74 | === modified file 'clients/memdump.c' |
75 | --- clients/memdump.c 2009-06-15 13:03:47 +0000 |
76 | +++ clients/memdump.c 2009-08-10 22:32:01 +0000 |
77 | @@ -102,13 +102,13 @@ |
78 | |
79 | static struct option long_options[]= |
80 | { |
81 | - {"version", no_argument, NULL, OPT_VERSION}, |
82 | - {"help", no_argument, NULL, OPT_HELP}, |
83 | - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
84 | - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
85 | - {"servers", required_argument, NULL, OPT_SERVERS}, |
86 | - {"hash", required_argument, NULL, OPT_HASH}, |
87 | - {"binary", no_argument, NULL, OPT_BINARY}, |
88 | + {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, |
89 | + {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, |
90 | + {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
91 | + {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
92 | + {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, |
93 | + {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, |
94 | + {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, |
95 | {0, 0, 0, 0} |
96 | }; |
97 | |
98 | |
99 | === modified file 'clients/memerror.c' |
100 | --- clients/memerror.c 2009-05-13 09:53:59 +0000 |
101 | +++ clients/memerror.c 2009-08-10 22:32:01 +0000 |
102 | @@ -43,10 +43,10 @@ |
103 | |
104 | static struct option long_options[]= |
105 | { |
106 | - {"version", no_argument, NULL, OPT_VERSION}, |
107 | - {"help", no_argument, NULL, OPT_HELP}, |
108 | - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
109 | - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
110 | + {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, |
111 | + {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, |
112 | + {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
113 | + {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
114 | {0, 0, 0, 0}, |
115 | }; |
116 | |
117 | |
118 | === modified file 'clients/memflush.c' |
119 | --- clients/memflush.c 2009-06-15 13:03:47 +0000 |
120 | +++ clients/memflush.c 2009-08-10 22:32:01 +0000 |
121 | @@ -74,13 +74,13 @@ |
122 | |
123 | static struct option long_options[]= |
124 | { |
125 | - {"version", no_argument, NULL, OPT_VERSION}, |
126 | - {"help", no_argument, NULL, OPT_HELP}, |
127 | - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
128 | - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
129 | - {"servers", required_argument, NULL, OPT_SERVERS}, |
130 | - {"expire", required_argument, NULL, OPT_EXPIRE}, |
131 | - {"binary", no_argument, NULL, OPT_BINARY}, |
132 | + {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, |
133 | + {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, |
134 | + {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
135 | + {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
136 | + {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, |
137 | + {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE}, |
138 | + {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, |
139 | {0, 0, 0, 0}, |
140 | }; |
141 | int option_index= 0; |
142 | |
143 | === modified file 'clients/memrm.c' |
144 | --- clients/memrm.c 2009-06-15 13:03:47 +0000 |
145 | +++ clients/memrm.c 2009-08-10 22:32:01 +0000 |
146 | @@ -87,14 +87,14 @@ |
147 | |
148 | static struct option long_options[]= |
149 | { |
150 | - {"version", no_argument, NULL, OPT_VERSION}, |
151 | - {"help", no_argument, NULL, OPT_HELP}, |
152 | - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
153 | - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
154 | - {"servers", required_argument, NULL, OPT_SERVERS}, |
155 | - {"expire", required_argument, NULL, OPT_EXPIRE}, |
156 | - {"hash", required_argument, NULL, OPT_HASH}, |
157 | - {"binary", no_argument, NULL, OPT_BINARY}, |
158 | + {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, |
159 | + {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, |
160 | + {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
161 | + {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
162 | + {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, |
163 | + {(OPTIONSTRING)"expire", required_argument, NULL, OPT_EXPIRE}, |
164 | + {(OPTIONSTRING)"hash", required_argument, NULL, OPT_HASH}, |
165 | + {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, |
166 | {0, 0, 0, 0}, |
167 | }; |
168 | int option_index= 0; |
169 | |
170 | === modified file 'clients/memslap.c' |
171 | --- clients/memslap.c 2009-06-15 13:03:47 +0000 |
172 | +++ clients/memslap.c 2009-08-10 22:32:01 +0000 |
173 | @@ -238,21 +238,21 @@ |
174 | |
175 | static struct option long_options[]= |
176 | { |
177 | - {"concurrency", required_argument, NULL, OPT_SLAP_CONCURRENCY}, |
178 | - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
179 | - {"execute-number", required_argument, NULL, OPT_SLAP_EXECUTE_NUMBER}, |
180 | - {"flag", no_argument, &opt_displayflag, OPT_FLAG}, |
181 | - {"flush", no_argument, &opt_flush, OPT_FLUSH}, |
182 | - {"help", no_argument, NULL, OPT_HELP}, |
183 | - {"initial-load", required_argument, NULL, OPT_SLAP_INITIAL_LOAD}, /* Number to load initially */ |
184 | - {"non-blocking", no_argument, &opt_non_blocking_io, OPT_SLAP_NON_BLOCK}, |
185 | - {"servers", required_argument, NULL, OPT_SERVERS}, |
186 | - {"tcp-nodelay", no_argument, &opt_tcp_nodelay, OPT_SLAP_TCP_NODELAY}, |
187 | - {"test", required_argument, NULL, OPT_SLAP_TEST}, |
188 | - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
189 | - {"version", no_argument, NULL, OPT_VERSION}, |
190 | - {"binary", no_argument, NULL, OPT_BINARY}, |
191 | - {"udp", no_argument, NULL, OPT_UDP}, |
192 | + {(OPTIONSTRING)"concurrency", required_argument, NULL, OPT_SLAP_CONCURRENCY}, |
193 | + {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
194 | + {(OPTIONSTRING)"execute-number", required_argument, NULL, OPT_SLAP_EXECUTE_NUMBER}, |
195 | + {(OPTIONSTRING)"flag", no_argument, &opt_displayflag, OPT_FLAG}, |
196 | + {(OPTIONSTRING)"flush", no_argument, &opt_flush, OPT_FLUSH}, |
197 | + {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, |
198 | + {(OPTIONSTRING)"initial-load", required_argument, NULL, OPT_SLAP_INITIAL_LOAD}, /* Number to load initially */ |
199 | + {(OPTIONSTRING)"non-blocking", no_argument, &opt_non_blocking_io, OPT_SLAP_NON_BLOCK}, |
200 | + {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, |
201 | + {(OPTIONSTRING)"tcp-nodelay", no_argument, &opt_tcp_nodelay, OPT_SLAP_TCP_NODELAY}, |
202 | + {(OPTIONSTRING)"test", required_argument, NULL, OPT_SLAP_TEST}, |
203 | + {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
204 | + {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, |
205 | + {(OPTIONSTRING)"binary", no_argument, NULL, OPT_BINARY}, |
206 | + {(OPTIONSTRING)"udp", no_argument, NULL, OPT_UDP}, |
207 | {0, 0, 0, 0}, |
208 | }; |
209 | |
210 | |
211 | === modified file 'clients/memstat.c' |
212 | --- clients/memstat.c 2009-07-14 02:17:13 +0000 |
213 | +++ clients/memstat.c 2009-08-10 22:32:01 +0000 |
214 | @@ -35,13 +35,13 @@ |
215 | |
216 | static struct option long_options[]= |
217 | { |
218 | - {"version", no_argument, NULL, OPT_VERSION}, |
219 | - {"help", no_argument, NULL, OPT_HELP}, |
220 | - {"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
221 | - {"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
222 | - {"servers", required_argument, NULL, OPT_SERVERS}, |
223 | - {"flag", no_argument, &opt_displayflag, OPT_FLAG}, |
224 | - {"analyze", optional_argument, NULL, OPT_ANALYZE}, |
225 | + {(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION}, |
226 | + {(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP}, |
227 | + {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE}, |
228 | + {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG}, |
229 | + {(OPTIONSTRING)"servers", required_argument, NULL, OPT_SERVERS}, |
230 | + {(OPTIONSTRING)"flag", no_argument, &opt_displayflag, OPT_FLAG}, |
231 | + {(OPTIONSTRING)"analyze", optional_argument, NULL, OPT_ANALYZE}, |
232 | {0, 0, 0, 0}, |
233 | }; |
234 | |
235 | |
236 | === modified file 'clients/utilities.h' |
237 | --- clients/utilities.h 2009-07-08 13:38:34 +0000 |
238 | +++ clients/utilities.h 2009-08-10 22:32:01 +0000 |
239 | @@ -13,6 +13,15 @@ |
240 | # endif |
241 | #endif |
242 | |
243 | +#ifdef __sun |
244 | + /* For some odd reason the option struct on solaris defines the argument |
245 | + * as char* and not const char* |
246 | + */ |
247 | +#define OPTIONSTRING char* |
248 | +#else |
249 | +#define OPTIONSTRING const char* |
250 | +#endif |
251 | + |
252 | typedef struct memcached_programs_help_st memcached_programs_help_st; |
253 | |
254 | struct memcached_programs_help_st |
255 | |
256 | === modified file 'libmemcached/crc.c' |
257 | --- libmemcached/crc.c 2009-06-14 21:24:48 +0000 |
258 | +++ libmemcached/crc.c 2009-08-10 22:32:01 +0000 |
259 | @@ -80,7 +80,7 @@ |
260 | uint32_t crc= UINT32_MAX; |
261 | |
262 | for (x= 0; x < key_length; x++) |
263 | - crc= (crc >> 8) ^ crc32tab[(crc ^ (key[x])) & 0xff]; |
264 | + crc= (crc >> 8) ^ crc32tab[(crc ^ (uint64_t)key[x]) & 0xff]; |
265 | |
266 | return ~crc; |
267 | } |
268 | |
269 | === modified file 'libmemcached/memcached_hash.c' |
270 | --- libmemcached/memcached_hash.c 2009-07-30 06:04:28 +0000 |
271 | +++ libmemcached/memcached_hash.c 2009-08-10 22:32:01 +0000 |
272 | @@ -40,7 +40,7 @@ |
273 | for (x= 0; x < key_length; x++) |
274 | { |
275 | temp_hash *= FNV_64_PRIME; |
276 | - temp_hash ^= key[x]; |
277 | + temp_hash ^= (uint64_t)key[x]; |
278 | } |
279 | hash= (uint32_t)temp_hash; |
280 | } |
281 | @@ -50,7 +50,8 @@ |
282 | hash= (uint32_t) FNV_64_INIT; |
283 | for (x= 0; x < key_length; x++) |
284 | { |
285 | - hash ^= key[x]; |
286 | + uint32_t val= (uint32_t)key[x]; |
287 | + hash ^= val; |
288 | hash *= (uint32_t) FNV_64_PRIME; |
289 | } |
290 | } |
291 | @@ -60,8 +61,9 @@ |
292 | hash= FNV_32_INIT; |
293 | for (x= 0; x < key_length; x++) |
294 | { |
295 | + uint32_t val= (uint32_t)key[x]; |
296 | hash *= FNV_32_PRIME; |
297 | - hash ^= key[x]; |
298 | + hash ^= val; |
299 | } |
300 | } |
301 | break; |
302 | @@ -70,7 +72,8 @@ |
303 | hash= FNV_32_INIT; |
304 | for (x= 0; x < key_length; x++) |
305 | { |
306 | - hash ^= key[x]; |
307 | + uint32_t val= (uint32_t)key[x]; |
308 | + hash ^= val; |
309 | hash *= FNV_32_PRIME; |
310 | } |
311 | } |
312 | @@ -205,7 +208,8 @@ |
313 | |
314 | while (key_length--) |
315 | { |
316 | - value += (uint32_t) *ptr++; |
317 | + uint32_t val= (uint32_t) *ptr++; |
318 | + value += val; |
319 | value += (value << 10); |
320 | value ^= (value >> 6); |
321 | } |
322 | |
323 | === modified file 'libmemcached/murmur_hash.c' |
324 | --- libmemcached/murmur_hash.c 2009-07-18 17:37:40 +0000 |
325 | +++ libmemcached/murmur_hash.c 2009-08-10 22:32:01 +0000 |
326 | @@ -25,13 +25,13 @@ |
327 | */ |
328 | |
329 | const unsigned int m= 0x5bd1e995; |
330 | - const size_t seed= (0xdeadbeef * length); |
331 | + const uint32_t seed= (0xdeadbeef * (uint32_t)length); |
332 | const int r= 24; |
333 | |
334 | |
335 | // Initialize the hash to a 'random' value |
336 | |
337 | - size_t h= seed ^ length; |
338 | + uint32_t h= seed ^ (uint32_t)length; |
339 | |
340 | // Mix 4 bytes at a time into the hash |
341 | |
342 | @@ -56,8 +56,8 @@ |
343 | |
344 | switch(length) |
345 | { |
346 | - case 3: h ^= data[2] << 16; |
347 | - case 2: h ^= data[1] << 8; |
348 | + case 3: h ^= ((uint32_t)data[2]) << 16; |
349 | + case 2: h ^= ((uint32_t)data[1]) << 8; |
350 | case 1: h ^= data[0]; |
351 | h *= m; |
352 | default: break; |
353 | |
354 | === modified file 'tests/function.c' |
355 | --- tests/function.c 2009-07-16 11:28:19 +0000 |
356 | +++ tests/function.c 2009-08-10 22:32:01 +0000 |
357 | @@ -2312,6 +2312,7 @@ |
358 | return 0; |
359 | } |
360 | |
361 | +#ifndef __sun |
362 | /* Check the validity of chinese key*/ |
363 | static test_return user_supplied_bug17(memcached_st *memc) |
364 | { |
365 | @@ -2338,6 +2339,7 @@ |
366 | |
367 | return 0; |
368 | } |
369 | +#endif |
370 | |
371 | /* |
372 | From Andrei on IRC |
Fix compilation problems reported by gcc 4.4 with -Wsign-conversion. Due to a problem with the definition of struct option on Solaris (defining name as char* and not const char*) I had to add a macro to explicitly cast the strings to char* on Solaris. :(