Module: sip-router Branch: andrei/pointer_alias_warnings Commit: d44e8a81f8a955c5b0f2e1265019c91b1c3e5b3c URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d44e8a81...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Mon Oct 12 18:50:50 2009 +0200
db_postgres: pointer aliasing warnings fixes
- use a union to avoid the warnings
---
modules/db_postgres/pg_fld.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/modules/db_postgres/pg_fld.c b/modules/db_postgres/pg_fld.c index 4353e48..685d73b 100644 --- a/modules/db_postgres/pg_fld.c +++ b/modules/db_postgres/pg_fld.c @@ -91,17 +91,23 @@ int pg_fld(db_fld_t* fld, char* table) }
+union ull { + uint64_t ui64; + uint32_t ui32[2]; +}; + static inline uint64_t htonll(uint64_t in) { - uint32_t* p = (uint32_t*)∈ - return ((uint64_t)htonl(p[0]) << 32) + (uint64_t)htonl(p[1]); + union ull* p = (union ull*)∈ + + return ((uint64_t)htonl(p->ui32[0]) << 32) + (uint64_t)htonl(p->ui32[1]); }
static inline uint64_t ntohll(uint64_t in) { - uint32_t* p = (uint32_t*)∈ - return ((uint64_t)ntohl(p[0]) << 32) + (uint64_t)ntohl(p[1]); + union ull* p = (union ull*)∈ + return ((uint64_t)ntohl(p->ui32[0]) << 32) + (uint64_t)ntohl(p->ui32[1]); }