dovecot-2.2: Avoid strict aliasing warnings.
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 14 22:23:40 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/bf98dc25e3e4
changeset: 16349:bf98dc25e3e4
user: Timo Sirainen <tss at iki.fi>
date: Tue May 14 22:23:27 2013 +0300
description:
Avoid strict aliasing warnings.
diffstat:
src/lib/hash.h | 27 +++++++++++++++++++++------
src/plugins/fts-lucene/lucene-wrapper.cc | 5 ++---
2 files changed, 23 insertions(+), 9 deletions(-)
diffs (68 lines):
diff -r 0e3c924ff5b4 -r bf98dc25e3e4 src/lib/hash.h
--- a/src/lib/hash.h Tue May 14 16:46:08 2013 +0300
+++ b/src/lib/hash.h Tue May 14 22:23:27 2013 +0300
@@ -82,13 +82,20 @@
bool hash_table_lookup_full(const struct hash_table *table,
const void *lookup_key,
void **orig_key_r, void **value_r);
-#define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \
+#ifndef __cplusplus
+# define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \
hash_table_lookup_full((table)._table, \
(void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, lookup_key)), \
- (void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, orig_key_r) + \
+ (void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, orig_key_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*orig_key_r) != sizeof(void *))), \
- (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \
+ (void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*value_r) != sizeof(void *))))
+#else
+/* C++ requires (void **) casting, but that's not possible with strict
+ aliasing, so .. we'll just disable the type checks */
+# define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \
+ hash_table_lookup_full((table)._table, lookup_key, orig_key_r, value_r)
+#endif
/* Insert/update node in hash table. The difference is that hash_table_insert()
replaces the key in table to given one, while hash_table_update() doesnt. */
@@ -119,12 +126,20 @@
hash_table_iterate_init((table)._table)
bool hash_table_iterate(struct hash_iterate_context *ctx,
void **key_r, void **value_r);
-#define hash_table_iterate(ctx, table, key_r, value_r) \
+#ifndef __cplusplus
+# define hash_table_iterate(ctx, table, key_r, value_r) \
hash_table_iterate(ctx, \
- (void **)(void *)((key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, key_r) + \
+ (void *)((key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, key_r) + \
COMPILE_ERROR_IF_TRUE(sizeof(*key_r) != sizeof(void *)) + \
COMPILE_ERROR_IF_TRUE(sizeof(*value_r) != sizeof(void *))), \
- (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r)))
+ (void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r)))
+#else
+/* C++ requires (void **) casting, but that's not possible with strict
+ aliasing, so .. we'll just disable the type checks */
+# define hash_table_iterate(ctx, table, key_r, value_r) \
+ hash_table_iterate(ctx, key_r, value_r)
+#endif
+
void hash_table_iterate_deinit(struct hash_iterate_context **ctx);
/* Hash table isn't resized, and removed nodes aren't removed from
diff -r 0e3c924ff5b4 -r bf98dc25e3e4 src/plugins/fts-lucene/lucene-wrapper.cc
--- a/src/plugins/fts-lucene/lucene-wrapper.cc Tue May 14 16:46:08 2013 +0300
+++ b/src/plugins/fts-lucene/lucene-wrapper.cc Tue May 14 22:23:27 2013 +0300
@@ -1322,11 +1322,10 @@
BooleanQuery mailbox_query;
struct hash_iterate_context *iter;
- wchar_t *key;
- struct fts_result *value;
+ void *key, *value;
iter = hash_table_iterate_init(guids);
while (hash_table_iterate(iter, guids, &key, &value)) {
- Term *term = _CLNEW Term(_T("box"), key);
+ Term *term = _CLNEW Term(_T("box"), (wchar_t *)key);
TermQuery *q = _CLNEW TermQuery(term);
mailbox_query.add(q, true, BooleanClause::SHOULD);
}
More information about the dovecot-cvs
mailing list