From 722704d9d92b1273aebb9f872b278fdccba61dc8 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Wed, 23 Jan 2013 16:18:53 +0000 Subject: [PATCH 1/2] Fix strict aliasing issue/warning For the levels 2 and 3 of the -Wstrict-aliasing flag, gcc (4.6.3) emitted the following warning: src/node_types.h: In function 'decode_kv_length': src/node_types.h:81:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] Which is dangerous since by default we compile with -O2. Change-Id: Ibffc6a4188715a7562d14bfd8d83e0843ab606d6 Reviewed-on: http://review.couchbase.org/24159 Reviewed-by: Fulu Li Reviewed-by: Aaron Miller Tested-by: Aaron Miller Tested-by: Filipe David Borba Manana --- src/node_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_types.h b/src/node_types.h index c3c50853..17beb2bd 100644 --- a/src/node_types.h +++ b/src/node_types.h @@ -78,7 +78,7 @@ size_t encode_root(void *buf, node_pointer *node); static inline void decode_kv_length(const raw_kv_length *kv, uint32_t *klen, uint32_t *vlen) { //12, 28 bit - *klen = ntohs(*(uint16_t*)&kv->raw_kv[0]) >> 4; + *klen = (uint16_t) ((kv->raw_kv[0] << 4) | ((kv->raw_kv[1] & 0xf0) >> 4)); *vlen = ntohl(*(uint32_t*)&kv->raw_kv[1]) & 0x0FFFFFFF; } From 162935b3309200a185a73128fb99796246bfaca1 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Wed, 23 Jan 2013 16:38:42 +0000 Subject: [PATCH 2/2] Fix implicit pointer to integral type cast From gcc: src/db_compact.c:87:5: warning: passing argument 3 of 'couchstore_compact_db_ex' makes integer from pointer without a cast [enabled by default] src/db_compact.c:40:20: note: expected 'uint64_t' but argument is of type 'void *' Change-Id: I9326c2bb4ff639fca995f1de4c0f5fe5172c11a1 Reviewed-on: http://review.couchbase.org/24162 Reviewed-by: Fulu Li Reviewed-by: Aaron Miller Tested-by: Aaron Miller Tested-by: Filipe David Borba Manana --- src/db_compact.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/db_compact.c b/src/db_compact.c index 872b36ea..4c3a4ecb 100644 --- a/src/db_compact.c +++ b/src/db_compact.c @@ -84,7 +84,7 @@ couchstore_error_t couchstore_compact_db_ex(Db* source, const char* target_filen couchstore_error_t couchstore_compact_db(Db* source, const char* target_filename) { - return couchstore_compact_db_ex(source, target_filename, NULL, couchstore_get_default_file_ops()); + return couchstore_compact_db_ex(source, target_filename, 0, couchstore_get_default_file_ops()); } static int read_id_record(FILE *in, void *buf, void *ctx)