aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2006-02-23 18:35:32 +0000
committerRoland Dreier <rolandd@cisco.com>2006-11-09 19:57:05 -0800
commitf38a5ef294e9b7ce80ca1c692da96370865d9a04 (patch)
tree4e440be97a4001e08258a45ab2750002bc00ddbe
parent2254cdab179da6be0c88630f6c3299bce17855dc (diff)
downloadlibmthca-f38a5ef294e9b7ce80ca1c692da96370865d9a04.tar.gz
Fix strict aliasing warning with gcc 4.1
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--ChangeLog4
-rw-r--r--src/memfree.c13
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 6aef55d..975764c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2006-02-16 Roland Dreier <rdreier@cisco.com>
+ * src/memfree.c (mthca_alloc_db): Introduce a temporary variable
+ to pass to posix_memalign() to avoid "warning: dereferencing
+ type-punned pointer will break strict-aliasing rules."
+
* Release version 1.0-rc7.
2006-02-15 Roland Dreier <rdreier@cisco.com>
diff --git a/src/memfree.c b/src/memfree.c
index f4863b9..0a65e72 100644
--- a/src/memfree.c
+++ b/src/memfree.c
@@ -100,10 +100,15 @@ int mthca_alloc_db(struct mthca_db_table *db_tab, enum mthca_db_type type,
goto out;
}
- if (posix_memalign((void **) &db_tab->page[i].db_rec, MTHCA_DB_REC_PAGE_SIZE,
- MTHCA_DB_REC_PAGE_SIZE)) {
- ret = -1;
- goto out;
+ {
+ void *tmp;
+
+ if (posix_memalign(&tmp, MTHCA_DB_REC_PAGE_SIZE,
+ MTHCA_DB_REC_PAGE_SIZE)) {
+ ret = -1;
+ goto out;
+ }
+ db_tab->page[i].db_rec = tmp;
}
memset(db_tab->page[i].db_rec, 0, MTHCA_DB_REC_PAGE_SIZE);